:root {
  --ink: #17130d;
  --paper: #f4ead8;
  --panel: rgba(255, 249, 237, 0.82);
  --muted: rgba(23, 19, 13, 0.62);
  --line: rgba(23, 19, 13, 0.15);
  --night: #132732;
  --blue: #244c63;
  --sage: #6f9072;
  --gold: #dcaa43;
  --ember: #d95532;
  --shadow: 0 28px 90px rgba(31, 22, 10, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(rgba(23, 19, 13, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 19, 13, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 10% 4%, rgba(217, 85, 50, 0.28), transparent 28rem),
    radial-gradient(circle at 92% 16%, rgba(36, 76, 99, 0.22), transparent 34rem),
    linear-gradient(135deg, #efe4cd, #eef1e4 45%, #ead8b9);
  background-size: 44px 44px, 44px 44px, auto, auto, auto;
  font-family: Georgia, "Times New Roman", serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 11px 16px;
  color: #fff8ed;
  background: var(--ink);
  cursor: pointer;
  font-family: "Trebuchet MS", sans-serif;
  font-weight: 900;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

button.secondary,
.ghost-button {
  color: var(--ink);
  background: rgba(23, 19, 13, 0.1);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.68);
}

textarea {
  min-height: 150px;
  resize: vertical;
}

label {
  display: grid;
  gap: 7px;
  color: rgba(23, 19, 13, 0.7);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}

.sector-rail {
  position: sticky;
  top: 0;
  align-self: start;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 28px;
  min-height: 100vh;
  padding: 28px;
  color: #fff8ed;
  background:
    radial-gradient(circle at 20% 0, rgba(220, 170, 67, 0.22), transparent 26rem),
    linear-gradient(160deg, #10191f, var(--night));
}

.brand {
  color: inherit;
  text-decoration: none;
}

.brand span {
  display: block;
  color: rgba(255, 248, 237, 0.62);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.brand strong {
  display: block;
  font-size: 4rem;
  line-height: 0.82;
  letter-spacing: -0.08em;
}

.sector-rail nav {
  display: grid;
  gap: 9px;
}

.sector-rail nav a {
  border: 1px solid rgba(255, 248, 237, 0.12);
  border-radius: 18px;
  padding: 13px 14px;
  color: rgba(255, 248, 237, 0.78);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.045);
}

.sector-rail nav a.is-active {
  color: #fff8ed;
  border-color: rgba(220, 170, 67, 0.5);
  background: rgba(220, 170, 67, 0.13);
}

.rail-note {
  align-self: end;
  color: rgba(255, 248, 237, 0.54);
  line-height: 1.5;
}

.sector-main {
  width: min(1340px, 100%);
  padding: 34px clamp(18px, 4vw, 54px) 72px;
}

.sector-header {
  margin-bottom: 24px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 36px;
  background:
    radial-gradient(circle at 24% 16%, rgba(255, 255, 255, 0.72), transparent 38%),
    rgba(255, 249, 237, 0.72);
  box-shadow: var(--shadow);
}

.route-kicker,
.zone-kicker {
  margin: 0 0 8px;
  color: var(--ember);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(3.6rem, 8vw, 8.5rem);
  line-height: 0.86;
  letter-spacing: -0.09em;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.75rem;
  line-height: 1;
}

h3 {
  margin: 18px 0 8px;
  font-size: 1rem;
}

.stage-panel,
.control-panel {
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 22px;
  background: var(--panel);
  box-shadow: 0 16px 45px rgba(31, 22, 10, 0.1);
}

.atlas-hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 24px;
  border-radius: 38px 16px 38px 16px;
  color: #fff8ed;
  background:
    radial-gradient(circle at 90% 10%, rgba(220, 170, 67, 0.24), transparent 32%),
    linear-gradient(150deg, var(--night), #101a20);
}

.atlas-hero .zone-kicker {
  color: rgba(220, 170, 67, 0.9);
}

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

.stat-card {
  border: 1px solid rgba(23, 19, 13, 0.1);
  border-radius: 20px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.44);
}

.atlas-hero .stat-card {
  border-color: rgba(255, 248, 237, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.stat-card span,
.stat-card em {
  display: block;
  color: var(--muted);
  font-family: "Trebuchet MS", sans-serif;
  font-style: normal;
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.atlas-hero .stat-card span,
.atlas-hero .stat-card em {
  color: rgba(255, 248, 237, 0.58);
}

.stat-card strong {
  display: block;
  font-size: 2rem;
}

.basin-stage {
  margin-bottom: 18px;
  color: #fff8ed;
  background:
    radial-gradient(circle at 10% 20%, rgba(122, 181, 212, 0.16), transparent 28%),
    linear-gradient(150deg, #112631, #1e3440 55%, #101a20);
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.basin-map {
  overflow-x: auto;
  border: 1px solid rgba(255, 248, 237, 0.12);
  border-radius: 26px;
  background:
    linear-gradient(90deg, rgba(255, 248, 237, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(255, 248, 237, 0.035) 1px, transparent 1px),
    rgba(255, 255, 255, 0.035);
  background-size: 32px 32px;
}

.basin-map svg {
  display: block;
  min-width: 920px;
  width: 100%;
  height: auto;
}

.map-axis,
.node-detail,
.source-estuary text + text {
  font-family: "Trebuchet MS", sans-serif;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.map-axis,
.node-detail,
.source-estuary text + text {
  fill: rgba(255, 248, 237, 0.55);
}

.source-estuary circle {
  fill: rgba(220, 170, 67, 0.16);
  stroke: rgba(220, 170, 67, 0.5);
  stroke-width: 2;
}

.source-estuary text,
.map-node text {
  fill: #fff8ed;
  font-weight: 900;
}

.river-path {
  fill: none;
  stroke: rgba(122, 181, 212, 0.36);
  stroke-linecap: round;
  mix-blend-mode: screen;
}

.river-path:nth-child(3n + 1) {
  stroke: rgba(111, 144, 114, 0.36);
}

.river-path:nth-child(3n + 2) {
  stroke: rgba(220, 170, 67, 0.3);
}

.map-node {
  cursor: pointer;
}

.trunk-node circle,
.basin-node rect {
  fill: rgba(255, 248, 237, 0.1);
  stroke: rgba(255, 248, 237, 0.32);
  stroke-width: 1.5;
}

.philosophy-node rect {
  fill: rgba(111, 144, 114, 0.2);
  stroke: rgba(111, 144, 114, 0.75);
}

.map-node:hover circle,
.map-node:hover rect {
  fill: rgba(217, 85, 50, 0.24);
  stroke: rgba(217, 85, 50, 0.8);
}

.atlas-grid,
.archive-grid,
.lab-grid,
.expedition-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.wide {
  grid-column: 1 / -1;
}

.ranked-list,
.archive-list {
  display: grid;
  gap: 8px;
}

.ranked-row,
.archive-row,
.catalog-tile {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid rgba(23, 19, 13, 0.12);
  border-radius: 16px;
  padding: 12px;
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.42);
}

.ranked-row {
  grid-template-columns: 64px 1fr;
  align-items: center;
}

.ranked-row strong {
  color: var(--blue);
  font-size: 1.3rem;
}

.bar-list {
  display: grid;
  gap: 9px;
}

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 48px;
  gap: 9px;
  align-items: center;
}

.bar-row div {
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 19, 13, 0.1);
}

.bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--ember), var(--gold));
}

.path-ribbon {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  align-items: center;
  padding: 10px 0;
}

.path-node {
  min-width: 145px;
  max-width: 210px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.48);
}

.path-node span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-bottom: 6px;
  border-radius: 99px;
  color: #fff8ed;
  background: var(--blue);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.74rem;
  font-weight: 900;
}

.path-node.is-terminal span {
  background: var(--ember);
}

.path-edge {
  flex: 0 0 38px;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ember), var(--gold));
}

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

.control-panel {
  min-height: 350px;
}

.topic-control {
  background: radial-gradient(circle at 10% 0, rgba(111, 144, 114, 0.22), transparent 34%), var(--panel);
}

.random-control {
  background: radial-gradient(circle at 90% 0, rgba(36, 76, 99, 0.2), transparent 34%), var(--panel);
}

.manual-control {
  color: #fff8ed;
  background: linear-gradient(150deg, #1b1714, #112631);
}

.manual-control p,
.manual-control label {
  color: rgba(255, 248, 237, 0.75);
}

.manual-control input,
.manual-control textarea {
  color: #fff8ed;
  border-color: rgba(255, 248, 237, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.deployment-lock {
  color: #fff8ed;
  background:
    radial-gradient(circle at 12% 0, rgba(220, 170, 67, 0.22), transparent 28rem),
    linear-gradient(150deg, #1b1714, #112631);
}

.deployment-lock p {
  color: rgba(255, 248, 237, 0.76);
}

.lock-chip {
  display: inline-block;
  margin-bottom: 10px;
  border: 1px solid rgba(220, 170, 67, 0.45);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--gold);
  background: rgba(220, 170, 67, 0.1);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.output-box,
.loading,
.empty {
  border: 1px dashed rgba(23, 19, 13, 0.18);
  border-radius: 16px;
  padding: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.28);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.catalog-tile span,
.catalog-tile em,
.archive-row span,
.archive-row em {
  color: var(--muted);
  font-family: "Trebuchet MS", sans-serif;
  font-style: normal;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pill {
  display: inline-block;
  margin: 5px 6px 0 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, 0.44);
  font-family: "Trebuchet MS", sans-serif;
  font-size: 0.78rem;
}

.path-line {
  color: var(--blue);
  line-height: 1.6;
}

.audit-list {
  display: grid;
  gap: 6px;
}

.audit-list div {
  display: grid;
  grid-template-columns: 1fr 1fr 140px;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding: 8px 0;
}

.audit-list .accepted {
  color: var(--blue);
  font-weight: 900;
}

.error-panel {
  border-color: rgba(217, 85, 50, 0.4);
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sector-rail {
    position: relative;
    min-height: auto;
  }

  .sector-rail nav {
    grid-template-columns: repeat(2, 1fr);
  }

  .atlas-hero,
  .expedition-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .atlas-grid,
  .archive-grid,
  .lab-grid,
  .stat-grid,
  .input-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 3.5rem;
  }
}
