:root {
  --gold: #e8b84a;
  --gold-2: #fb7f18;
  --burgundy: #c43b4a;
  --ink: #f4efe4;
  --muted: #9a9388;
  --line: rgba(232, 184, 74, .18);
  --glass: rgba(10, 12, 18, .72);
  --glass-2: rgba(16, 18, 26, .88);
  --ok: #3dcea0;
  --warn: #e0a23a;
  --bad: #e05a4f;
  --ocean: #0a0d14;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--ocean);
  color: var(--ink);
  line-height: 1.45;
  overflow: hidden;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow {
  font-size: .68rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--gold); margin: 0 0 6px; font-weight: 600;
}
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 560; letter-spacing: -.02em; }
a { color: var(--gold); }

#workspace {
  position: fixed; top: 70px; left: 0; right: 0; bottom: 360px;
  display: grid; grid-template-columns: 1fr 140px; gap: 12px;
  padding: 0 14px 8px; z-index: 1; pointer-events: none;
}
#boardPane, #locator, #board { pointer-events: auto; }
#boardPane { overflow: auto; min-width: 0; }
#boardEmpty { color: var(--muted); max-width: 36rem; padding: 8px 4px 16px; }
#boardTools {
  display: flex; align-items: center; gap: 10px; margin: 0 0 14px;
  position: sticky; top: 0; z-index: 3;
  background: var(--ocean); padding: 4px 0 8px;
}
#boardTools label {
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
#catFilter {
  min-width: min(280px, 70vw); min-height: 44px; font: inherit; color: var(--ink);
  background: #0c1018; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px;
}
#catFilter:focus { outline: 1px solid var(--gold); }
#board { display: flex; flex-direction: column; gap: 16px; padding-bottom: 12px; }
.board-group h2 {
  font-size: .78rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 8px; font-family: inherit; font-weight: 600;
}
.board-row { display: flex; flex-wrap: wrap; gap: 8px; }
.rate-block {
  width: 108px; min-height: 118px; border-radius: 14px; padding: 10px 8px 8px;
  border: 2px solid transparent; color: #fff; cursor: pointer; text-align: left;
  display: flex; flex-direction: column; justify-content: space-between;
}
.rate-block.is-preferred { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(232,184,74,.4); }
.rate-block.is-locked { outline: 2px solid #fff; }
.rate-block .rb-score { font-family: Fraunces, serif; font-size: 1.8rem; line-height: 1; }
.rate-block .rb-name { font-size: .72rem; font-weight: 600; line-height: 1.25; }
.rate-block .rb-meta { font-size: .62rem; opacity: .85; }
#locator {
  height: 120px; width: 140px; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line); background: #0a0d14; align-self: start;
  position: sticky; top: 0; justify-self: end;
}
#map { width: 100%; height: 100%; }
#map svg { width: 100%; height: 100%; display: block; }
#credit {
  font-size: .68rem; color: var(--muted); margin: 6px 0 0;
}
#credit a { color: var(--muted); }
.country { fill: #1b2230; stroke: #0a0d14; stroke-width: .35; cursor: pointer; }
.country:hover { fill: #2a3346; }
.country.region-middle-east { fill: #242016; }
.country.region-europe { fill: #1c2432; }
.country.region-indian-ocean { fill: #1f1c18; }
.country.region-asia { fill: #1a2130; }
.country.region-americas { fill: #17202c; }
.country.region-africa { fill: #221c16; }
.country.has-pattern {
  fill: #5a1c24;
  stroke: var(--gold);
  stroke-width: .85;
  filter: drop-shadow(0 0 6px rgba(232,184,74,.35));
}
.country.has-pattern:hover { fill: #7a2430; }
.country.is-active { fill: #e8b84a !important; stroke: #fff !important; stroke-width: 1.1; }
.country.oos { fill: #151820; }
.locator-cap {
  margin: 0; padding: 6px 10px; font-size: .65rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted); background: rgba(10,12,18,.75);
  position: absolute; z-index: 2;
}
#locator { position: relative; }
.pin { cursor: pointer; }
.chip { cursor: pointer; }

#view-gate {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(900px 500px at 50% 40%, rgba(196,59,74,.18), transparent 55%),
              rgba(6, 8, 12, .45);
  backdrop-filter: blur(8px);
}
.gate-card {
  width: min(440px, calc(100% - 32px));
  background: var(--glass-2);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 26px 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
}
.gate-kicker { display: flex; justify-content: space-between; align-items: center; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.gate-card h1 { font-size: 2.4rem; margin: 8px 0 6px; }
.lede { color: #d5cfc4; margin: 0 0 18px; }
.field { margin: 12px 0; }
.field label { display: block; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field input, #dock input, #dock select, .overlay-card input, .overlay-card select {
  width: 100%; background: #0c1018; color: var(--ink); border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px; padding: 12px 12px; font: inherit; min-height: 46px;
}
.field input:focus, #dock input:focus, #q:focus { outline: 1px solid var(--gold); }
.err { color: var(--bad); font-size: .85rem; }
.btn {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer; min-height: 46px;
  font-family: inherit;
}
.btn-primary {
  background: linear-gradient(180deg, #ffd27a, var(--gold) 40%, #c4891e);
  color: #2a1a00;
}
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.icon-btn { background: transparent; border: 0; color: var(--ink); cursor: pointer; min-height: 42px; min-width: 42px; opacity: .85; }

#hud {
  position: fixed; top: 14px; left: 14px; right: 14px; z-index: 5;
  display: flex; gap: 10px; align-items: center;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  padding: 8px 10px 8px 14px; backdrop-filter: blur(16px);
}
.hud-brand strong { font-family: Fraunces, serif; font-size: 1.15rem; }
.hud-brand span { display: block; font-size: .68rem; color: var(--muted); }
#q {
  flex: 1; min-width: 160px; min-height: 44px; border: 0; border-radius: 12px;
  background: #0c1018; color: var(--ink); padding: 8px 14px; font: inherit;
}
.hud-actions { display: flex; gap: 2px; }
#searchHits {
  position: fixed; top: 72px; left: 18px; width: min(380px, calc(100% - 36px));
  background: var(--glass-2); border: 1px solid var(--line); border-radius: 14px; z-index: 6; overflow: hidden;
}
#searchHits button {
  display: block; width: 100%; text-align: left; background: transparent; border: 0;
  color: var(--ink); padding: 12px 14px; min-height: 44px; cursor: pointer;
}
#searchHits button:hover { background: rgba(232,184,74,.08); }
#chips {
  position: fixed; top: 78px; left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
}
.dest-chip {
  background: var(--glass-2); color: var(--ink); border: 1px solid var(--gold);
  border-radius: 999px; padding: 10px 16px; min-height: 44px; font-weight: 600; cursor: pointer;
}
#starters { margin: 8px 0 18px; }
#starters .dest-chip { font-size: .95rem; }
#legend {
  position: fixed; top: 78px; right: 16px; z-index: 4;
  background: var(--glass); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: .7rem; color: var(--muted); line-height: 1.55;
}
#toast {
  position: fixed; top: 78px; left: 50%; transform: translateX(-50%); z-index: 8;
  background: #111; color: #fff; padding: 10px 14px; border-radius: 10px; max-width: 90%;
  border: 1px solid var(--line);
}

#dock {
  position: fixed; left: 14px; right: 14px; bottom: 292px; z-index: 5;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  backdrop-filter: blur(16px);
}
#dockDest { font-family: Fraunces, serif; font-size: 1.15rem; margin-right: 8px; }
#dock label { font-size: .68rem; color: var(--muted); letter-spacing: .04em; }

#pkgRow {
  position: fixed; left: 14px; right: 14px; bottom: 8px; z-index: 5;
  height: 276px; display: flex; flex-direction: column; min-height: 0;
}
#pkgHead {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 8px;
}
#sliderWrap { flex: 1; min-width: 200px; font-size: .72rem; color: var(--muted); }
#slider { width: 100%; accent-color: var(--gold); display: block; }
#mixNote { margin: 0; flex: 1; min-width: 160px; }
#pkgHead #btnFind { min-height: 36px; padding: 6px 12px; font-size: .78rem; }
#cards {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  flex: 1; min-height: 0;
}
.pkg-card {
  background: var(--glass-2); border: 1px solid var(--line); border-radius: 16px;
  padding: 12px 12px 10px; overflow: auto; font-size: .78rem;
}
.pkg-card.best { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(232,184,74,.25); }
.pkg-card header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.pkg-card .trip-title { font-family: Fraunces, serif; font-size: 1rem; margin: 0; line-height: 1.25; }
.pkg-card .pos { font-size: .62rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); white-space: nowrap; }
.pkg-card .comm-line { margin: 6px 0 2px; }
.pkg-card .comm-line strong { font-family: Fraunces, serif; font-size: 1.25rem; color: #fff; }
.pkg-card .comp { list-style: none; margin: 8px 0 6px; padding: 0; }
.pkg-card .comp li { display: grid; grid-template-columns: 64px 1fr auto 22px; gap: 6px; align-items: center; margin: 4px 0; }
.pkg-card .slot { font-size: .62rem; color: var(--muted); letter-spacing: .04em; }
.pip { font-weight: 700; }
.card-actions { display: flex; gap: 6px; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .66rem; font-weight: 700; }
.pill-green { background: rgba(61,206,160,.15); color: var(--ok); }
.pill-grey { background: rgba(255,255,255,.06); color: var(--muted); }

#inspScrim {
  position: fixed; inset: 0; z-index: 11;
  background: rgba(6, 8, 12, .62);
}
#inspector {
  position: fixed; top: 86px; right: 16px; width: min(380px, calc(100% - 28px));
  max-height: calc(100vh - 120px); overflow: auto; z-index: 12;
  background: #12151d; border: 1px solid var(--line); border-radius: 16px; padding: 18px 16px 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,.65);
}
#inspector h3 { margin: 0 0 10px; font-size: 1.35rem; }
.inspector-close {
  float: right; margin: -6px -6px 0 8px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 10px; min-height: 36px; min-width: auto; padding: 0 10px;
}
.insp-score { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 2px; }
.insp-score-num { font-family: Fraunces, serif; font-size: 2rem; line-height: 1; }
.insp-score-num small { font-size: 1rem; color: var(--muted); }
.insp-score-label { color: var(--muted); font-size: .78rem; letter-spacing: .04em; }
.risk-bar { height: 8px; background: #1a1d24; border-radius: 99px; overflow: hidden; margin: 8px 0; }
.risk-fill { display: block; height: 100%; }
.lock-row { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
#inspUse { margin-top: 12px; }

#overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 9;
  display: flex; align-items: flex-start; justify-content: center; padding: 56px 14px 14px;
}
.overlay-card {
  background: var(--glass-2); border: 1px solid var(--line); border-radius: 18px;
  padding: 18px; width: min(740px, 100%); max-height: calc(100vh - 80px); overflow: auto;
}
.overlay-head { display: flex; justify-content: space-between; align-items: center; }
.admin-stats { display: flex; gap: 12px; margin: 12px 0; }
.admin-filters { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0; }
.admin-filters label { min-width: 180px; flex: 1; font-size: .72rem; color: var(--muted); }
.admin-stats div { background: #0c1018; border-radius: 12px; padding: 10px 12px; border: 1px solid var(--line); }
.admin-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.overlay-card h3 { font-size: 1rem; margin: 16px 0 6px; }
.admin-row {
  display: grid; grid-template-columns: 1fr 90px auto; gap: 8px; align-items: center;
  border: 1px solid var(--line); border-radius: 12px; padding: 8px;
}
.mkweli-list { padding-left: 18px; }

body.locked #hud, body.locked #legend, body.locked #dock, body.locked #pkgRow, body.locked #cards, body.locked #inspector { display: none !important; }
body.unlocked #view-gate { display: none !important; }

@media (max-width: 800px) {
  #workspace { grid-template-columns: 1fr; bottom: 380px; }
  #locator { display: none; }
  #dock { bottom: 310px; }
  #pkgRow { height: 294px; }
  #cards { grid-template-columns: 1fr; }
  #inspector { left: 14px; right: 14px; width: auto; top: 78px; bottom: auto; max-height: calc(100vh - 100px); }
  #legend { display: none; }
  .gate-card h1 { font-size: 1.9rem; }
}
