:root {
  --bg: #ebe6db;
  --paper: #f8f5ee;
  --panel: rgba(248, 245, 238, 0.84);
  --panel-strong: rgba(255, 252, 247, 0.94);
  --ink: #152224;
  --muted: #536564;
  --soft: #8ea3a1;
  --line: rgba(21, 34, 36, 0.12);
  --accent: #b24b35;
  --accent-soft: rgba(178, 75, 53, 0.14);
  --accent-2: #275e63;
  --accent-2-soft: rgba(39, 94, 99, 0.12);
  --ok: #2d7653;
  --warn: #b06a23;
  --danger: #b33a3a;
  --shadow: 0 24px 60px rgba(34, 34, 29, 0.12);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Bahnschrift", "Segoe UI Variable", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(178, 75, 53, 0.16), transparent 32%),
    radial-gradient(circle at bottom right, rgba(39, 94, 99, 0.18), transparent 34%),
    linear-gradient(145deg, #f1ecdf 0%, #e7e0d1 100%);
}

a {
  color: inherit;
}

.shell {
  min-height: 100vh;
  padding: 24px;
}

.frame {
  max-width: 1600px;
  margin: 0 auto;
  background: rgba(255, 251, 246, 0.76);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 32px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) auto;
  gap: 24px;
  align-items: end;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(178, 75, 53, 0.12), transparent 45%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.28));
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.masthead h1 {
  margin: 14px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.masthead p {
  margin: 0;
  max-width: 860px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.credit-line {
  margin-top: 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.topnav a {
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 14px;
  transition: transform 160ms ease, border-color 160ms ease, color 160ms ease;
}

.topnav a:hover,
.topnav a[aria-current="page"] {
  transform: translateY(-1px);
  border-color: rgba(178, 75, 53, 0.26);
  color: var(--ink);
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(400px, 440px) minmax(0, 1fr);
  min-height: calc(100vh - 220px);
}

.rail {
  padding: 24px 22px 28px 24px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(39, 94, 99, 0.06), rgba(255, 255, 255, 0.24));
  overflow-x: hidden;
}

.rail,
.stack,
.field-grid,
.field-row,
.field,
.workspace,
.pane,
.pane-body {
  min-width: 0;
}

.workspace {
  display: grid;
  grid-template-rows: minmax(440px, 62vh) auto;
  min-width: 0;
}

.stage {
  padding: 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0.18));
}

.stage-panel {
  height: 100%;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-xl);
  box-shadow: 0 18px 34px rgba(42, 43, 39, 0.08);
  overflow: hidden;
}

.stage-head {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 10px;
}

.stage-head h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0.01em;
}

.stage-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.plot-frame {
  height: calc(100% - 74px);
  min-height: 360px;
}

.plot-frame > div {
  width: 100%;
  height: 100%;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: 20px;
  padding: 22px;
}

.pane {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.58);
  border-radius: var(--radius-xl);
  box-shadow: 0 18px 34px rgba(42, 43, 39, 0.06);
  min-width: 0;
}

.pane-head {
  padding: 18px 20px 8px;
}

.pane-head h3 {
  margin: 0;
  font-size: 18px;
}

.pane-head p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.pane-body {
  padding: 0 20px 20px;
}

.stack {
  display: grid;
  gap: 16px;
}

.section-title {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-grid {
  display: grid;
  gap: 12px;
}

.field-group {
  display: grid;
  gap: 12px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label,
.toggle-line span {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(21, 34, 36, 0.14);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font: inherit;
}

.field textarea {
  resize: vertical;
  min-height: 180px;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(39, 94, 99, 0.36);
  box-shadow: 0 0 0 4px rgba(39, 94, 99, 0.08);
}

.field small,
.hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.file-picker-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.file-picker-button {
  cursor: pointer;
}

.file-picker-name {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.file-picker-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.toggle-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle-line input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  appearance: none;
  border: none;
  padding: 12px 16px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #b24b35, #8e3827);
  box-shadow: 0 12px 24px rgba(178, 75, 53, 0.24);
}

.btn-secondary {
  color: var(--ink);
  background: rgba(39, 94, 99, 0.1);
  border: 1px solid rgba(39, 94, 99, 0.14);
}

.status {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(39, 94, 99, 0.08);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.status[data-level="warn"] {
  background: rgba(176, 106, 35, 0.12);
  color: #7f4c18;
}

.status[data-level="error"] {
  background: rgba(179, 58, 58, 0.12);
  color: #8f2c2c;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(21, 34, 36, 0.08);
}

.metric strong {
  display: block;
  font-size: 28px;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
}

.metric span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.metric[data-tone="accent"] {
  background: rgba(178, 75, 53, 0.08);
}

.metric[data-tone="accent-2"] {
  background: rgba(39, 94, 99, 0.08);
}

.metric[data-tone="ok"] {
  background: rgba(45, 118, 83, 0.08);
}

.metric[data-tone="warn"] {
  background: rgba(176, 106, 35, 0.1);
}

.metric[data-tone="danger"] {
  background: rgba(179, 58, 58, 0.1);
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(39, 94, 99, 0.08);
  color: var(--accent-2);
}

.pill[data-tone="warn"] {
  background: rgba(176, 106, 35, 0.12);
  color: #86521d;
}

.pill[data-tone="danger"] {
  background: rgba(179, 58, 58, 0.12);
  color: #8f2c2c;
}

.pill[data-tone="accent"] {
  background: rgba(178, 75, 53, 0.12);
  color: var(--accent);
}

.table-wrap {
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid rgba(21, 34, 36, 0.08);
  background: rgba(255, 255, 255, 0.56);
}

.batch-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.batch-input-preview {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(21, 34, 36, 0.08);
}

.batch-input-preview .placeholder-copy {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.batch-preview-group + .batch-preview-group {
  margin-top: 14px;
}

.batch-preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.batch-preview-head strong {
  font-size: 13px;
}

.batch-preview-head span {
  color: var(--muted);
  font-size: 12px;
}

.batch-preview-list {
  display: grid;
  gap: 8px;
}

.batch-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(250, 248, 242, 0.95);
  border: 1px solid rgba(21, 34, 36, 0.08);
}

.batch-preview-copy {
  min-width: 0;
}

.batch-preview-copy strong,
.batch-preview-copy span {
  display: block;
}

.batch-preview-copy strong {
  font-size: 13px;
}

.batch-preview-copy span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  word-break: break-word;
}

.batch-preview-item .btn {
  flex: 0 0 auto;
}

.batch-kpi {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(21, 34, 36, 0.08);
}

.batch-kpi strong {
  display: block;
  font-size: 22px;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
}

.batch-kpi span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.batch-select {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(39, 94, 99, 0.18);
  background: rgba(39, 94, 99, 0.1);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.batch-select:hover {
  transform: translateY(-1px);
}

.batch-row-active td {
  background: rgba(178, 75, 53, 0.08);
}

.coordinate-grid {
  display: grid;
  gap: 10px;
}

.coordinate-grid-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
}

.coordinate-grid-head,
.coordinate-grid-row {
  display: grid;
  grid-template-columns: 56px repeat(6, minmax(72px, 1fr));
  gap: 8px;
  align-items: center;
  min-width: 612px;
}

.coordinate-grid-head {
  padding: 0 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.coordinate-grid-row {
  padding: 10px;
  border: 1px solid rgba(21, 34, 36, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.54);
}

.coordinate-grid-row span {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.coordinate-grid-row input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(21, 34, 36, 0.14);
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font: inherit;
}

.coordinate-grid-row input:focus {
  outline: none;
  border-color: rgba(39, 94, 99, 0.36);
  box-shadow: 0 0 0 4px rgba(39, 94, 99, 0.08);
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.section-card {
  padding: 14px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(21, 34, 36, 0.08);
}

.section-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.section-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.section-figure {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.92), rgba(242, 239, 233, 0.94));
  border: 1px solid rgba(21, 34, 36, 0.08);
}

.section-plot {
  overflow: hidden;
}

.section-coordinates {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(250, 248, 242, 0.92);
  border: 1px solid rgba(21, 34, 36, 0.08);
}

.section-coordinate-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  font-size: 11px;
}

.section-coordinate-row strong {
  font-size: 12px;
}

.section-coordinate-row span {
  color: var(--muted);
  line-height: 1.4;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(21, 34, 36, 0.08);
  text-align: left;
  font-size: 13px;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: rgba(248, 245, 238, 0.96);
  z-index: 1;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

td code,
.code-inline {
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.split-note {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(21, 34, 36, 0.08);
}

.split-note strong {
  font-size: 14px;
}

.docs-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  padding: 22px;
}

.article {
  padding: 22px 24px;
}

.article h2 {
  margin: 0 0 14px;
  font-size: 28px;
  font-family: Georgia, "Times New Roman", serif;
}

.article h3 {
  margin: 28px 0 12px;
  font-size: 18px;
}

.article p,
.article li {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.article ul,
.article ol {
  margin: 0;
  padding-left: 22px;
}

.equation {
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(21, 34, 36, 0.08);
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
  overflow: auto;
}

.equation mjx-container {
  margin: 0 !important;
  min-width: max-content;
}

.equation mjx-container[display="true"] {
  padding: 2px 0;
}

.source-note {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: rgba(205, 233, 228, 0.5);
  border: 1px solid rgba(26, 71, 66, 0.12);
  font-size: 13px;
  line-height: 1.65;
}

.source-note strong {
  color: var(--ink-strong);
}

.heuristic-note {
  background: rgba(245, 230, 205, 0.55);
  border-color: rgba(112, 76, 24, 0.14);
}

.reference-list {
  display: grid;
  gap: 14px;
}

.reference-item {
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(21, 34, 36, 0.08);
}

.reference-item strong {
  display: block;
  margin-bottom: 6px;
  font-size: 15px;
}

.reference-item a {
  color: var(--accent-2);
}

.footer-note {
  padding: 16px 24px 24px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

details {
  border: 1px solid rgba(21, 34, 36, 0.08);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.48);
}

details summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 700;
}

details summary::-webkit-details-marker {
  display: none;
}

details > div {
  padding: 0 16px 16px;
}

@media (max-width: 1280px) {
  .app-layout {
    grid-template-columns: 320px minmax(0, 1fr);
  }
}

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

  .app-layout {
    grid-template-columns: 1fr;
  }

  .rail {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .shell {
    padding: 12px;
  }

  .frame {
    border-radius: 22px;
  }

  .masthead,
  .rail,
  .stage,
  .detail-grid,
  .docs-layout {
    padding-left: 14px;
    padding-right: 14px;
  }

  .field-row,
  .metric-grid,
  .batch-summary,
  .section-grid,
  .coordinate-grid-head,
  .coordinate-grid-row {
    grid-template-columns: 1fr;
  }

  .topnav {
    justify-content: flex-start;
  }
}
