:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d9dee7;
  --accent: #176b5d;
  --accent-dark: #0f5147;
  --blue: #2764c5;
  --green: #15803d;
  --red: #b42318;
  --shadow: 0 18px 40px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 500px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 20px;
  line-height: 1.25;
}

h3 {
  font-size: 15px;
  margin-bottom: 8px;
}

.panel-header p,
small,
.metrics span {
  color: var(--muted);
}

.badge,
.status {
  min-width: 74px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status.idle {
  color: var(--muted);
}

.status.running,
.status.queued {
  color: var(--blue);
  border-color: rgba(39, 100, 197, 0.28);
}

.status.completed {
  color: var(--green);
  border-color: rgba(21, 128, 61, 0.28);
}

.status.failed {
  color: var(--red);
  border-color: rgba(180, 35, 24, 0.28);
}

.file-drop {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 14px;
  min-height: 90px;
  border: 1px dashed #aeb7c5;
  border-radius: 8px;
  padding: 16px;
  cursor: pointer;
  background: #fafbfc;
}

.file-drop input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.file-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 8px;
  background: #e7f4f1;
  color: var(--accent-dark);
  font-weight: 800;
}

.file-drop strong,
.file-drop small {
  display: block;
}

.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 18px;
}

label span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
}

select,
input[type="number"],
input[type="range"] {
  width: 100%;
}

select,
input[type="number"] {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

input[type="range"] {
  accent-color: var(--accent);
}

.toggle-group {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
}

.toggle span {
  margin: 0;
}

.compact-toggle {
  min-height: 34px;
  border-radius: 6px;
  background: #fff;
}

.primary,
.secondary,
.ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.primary {
  width: 100%;
  margin-top: 18px;
  background: var(--accent);
  color: #fff;
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.secondary {
  background: var(--blue);
  color: #fff;
}

.ghost {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.compact {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.log-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--blue);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metrics div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-width: 0;
}

.metrics span,
.metrics strong {
  display: block;
}

.metrics strong {
  margin-top: 6px;
  font-size: 15px;
  overflow-wrap: anywhere;
}

.download-row {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.task-lookup {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  margin-bottom: 18px;
}

.task-lookup input,
.task-lookup select {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
}

.log-controls {
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr) 150px 100px auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.log-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.diagnostic-panel {
  background: #fbfcfd;
}

.review {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
}

.review p {
  line-height: 1.6;
}

#difference-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.details {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.details summary {
  cursor: pointer;
  font-weight: 800;
}

.attempt-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-top: 10px;
  background: #fff;
}

.attempt-card dl {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 6px 12px;
  margin: 0;
}

.attempt-card dt {
  color: var(--muted);
}

.attempt-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

pre {
  max-height: 320px;
  overflow: auto;
  white-space: pre-wrap;
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
}

#parameter-log,
#orientation-log {
  max-height: 220px;
  margin: 0;
}

.hidden {
  display: none;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .metrics,
  .control-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 620px) {
  .shell {
    width: min(100vw - 20px, 1380px);
    padding: 10px 0;
  }

  .panel {
    padding: 14px;
  }

  .metrics,
  .control-grid,
  .toggle-group {
    grid-template-columns: 1fr;
  }

  .panel-header,
  .download-row,
  .task-lookup {
    flex-direction: column;
    align-items: stretch;
  }

  .task-lookup,
  .log-controls,
  .log-detail-grid {
    grid-template-columns: 1fr;
  }
}
