:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #22201c;
  --muted: #6c675d;
  --border: #ddd7ca;
  --accent: #6d4fc2;
  --accent-text: #ffffff;
  --accent-soft: #ece6fb;
  --ok: #2f7d4f;
  --warn: #9a5b00;
  --error: #b3261e;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 5%);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15141a;
    --surface: #1f1d26;
    --surface-2: #2a2733;
    --text: #ece9f3;
    --muted: #a39fb0;
    --border: #383444;
    --accent: #a48bf0;
    --accent-text: #15141a;
    --accent-soft: #2f2847;
    --ok: #6fcf97;
    --warn: #f2b45a;
    --error: #ff8a80;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); line-height: 1.5; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .5rem; }
h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .4rem; }
.muted { color: var(--muted); }

button {
  font: inherit; border: 1px solid transparent; border-radius: 999px; padding: .5rem 1rem; cursor: pointer;
  background: var(--accent); color: var(--accent-text);
}
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
button.small { padding: .25rem .75rem; font-size: .85rem; }
button:focus-visible, textarea:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.notice { background: var(--accent-soft); border-radius: var(--radius); padding: .5rem .75rem; margin: .5rem 0; }
.notice.error { color: var(--error); background: color-mix(in srgb, var(--error) 12%, transparent); }

/* Login */
.narrow { max-width: 26rem; margin: 12vh auto 2rem; padding: 0 16px; }
.lead { color: var(--muted); }
.login-form { display: grid; gap: .5rem; margin-top: 1.5rem; }
.login-form input {
  font: inherit; padding: .65rem .8rem; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
.login-form button { justify-self: start; margin-top: .5rem; }

/* Chat layout: the page scrolls, the composer sticks to the bottom. */
.app { max-width: 52rem; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; padding: 0 16px; }
.topbar {
  position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .75rem 0; background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand .muted { font-size: .8rem; }
.actions { display: flex; gap: .5rem; align-items: center; }
.actions form { margin: 0; }
@media (max-width: 40rem) {
  .topbar { flex-wrap: wrap; gap: .5rem; }
  .actions { flex-wrap: wrap; gap: .4rem; }
  .actions .ghost { padding: .35rem .75rem; font-size: .9rem; }
}
.transcript { flex: 1; padding: 1rem 0 2rem; }

.welcome { margin-top: 4vh; }
.welcome h1 { font-size: 1.75rem; }
.welcome-lead { color: var(--muted); margin: 0 0 1.25rem; max-width: 38rem; }
.topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: .75rem; }
.topic {
  display: flex; flex-direction: column; gap: .4rem; padding: .9rem 1rem 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.topic h2 { font-size: 1rem; margin: 0; }
.topic p { color: var(--muted); font-size: .85rem; margin: 0 0 .25rem; }
.suggestion {
  background: var(--surface-2); color: var(--text); border: 1px solid transparent; border-radius: 8px;
  text-align: left; padding: .45rem .7rem; font-size: .9rem;
}
.suggestion:hover { border-color: var(--accent); background: var(--accent-soft); }
.welcome-tip { color: var(--muted); font-size: .85rem; margin-top: 1rem; }

.turn { margin: 1.25rem 0; }
.question {
  margin-left: auto; width: fit-content; max-width: 85%; background: var(--accent); color: var(--accent-text);
  padding: .55rem .9rem; border-radius: var(--radius) var(--radius) 4px var(--radius); white-space: pre-wrap;
}
.answer {
  margin-top: .75rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem 1rem; box-shadow: var(--shadow); overflow-wrap: anywhere;
}
.status { color: var(--muted); margin: .25rem 0; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .5rem; }
.chip {
  font-size: .78rem; padding: .15rem .6rem; border-radius: 999px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border);
}
.chip::before { content: "↻ "; }
.chip.running::before { display: inline-block; animation: spin 1s linear infinite; }
.chip.done::before { content: "✓ "; color: var(--ok); }
.chip.failed::before { content: "! "; color: var(--warn); }

/* "Bad answer?" under an answer: quiet until needed. */
.report { margin-top: .5rem; }
.report p { margin: 0; font-size: .85rem; }
.report-button {
  background: transparent; color: var(--muted); border: none; padding: .15rem 0; font-size: .8rem;
  text-decoration: underline; text-underline-offset: 2px;
}
.report-button:hover { color: var(--text); }
.report-form { display: grid; gap: .4rem; }
.report-form label { font-size: .85rem; color: var(--muted); }
.report-form textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: .4rem .6rem; resize: vertical;
}
.report-actions { display: flex; gap: .4rem; }
.report-actions button { padding: .25rem .75rem; font-size: .85rem; }

/* /feedback: the saved reports. */
.reports { list-style: none; padding: 0; display: grid; gap: .75rem; }
.reports li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; }
.reports .meta { color: var(--muted); font-size: .8rem; }
.reports .asked { font-weight: 600; margin: .2rem 0; }
.reports .comment { margin: .2rem 0; }
.reports details { font-size: .85rem; margin-top: .3rem; }
.reports pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: .5rem; border-radius: 8px; max-height: 20rem; overflow: auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown ul, .markdown ol { padding-left: 1.3rem; }
.markdown table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: .92rem; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: .3rem .5rem; text-align: left; }
.markdown code { background: var(--surface-2); padding: .05rem .3rem; border-radius: 4px; }

/* Checklist */
.checklist { margin-top: 1rem; border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem; background: var(--surface-2); }
.checklist header { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.checklist .progress { color: var(--muted); font-size: .9rem; }
.checklist ul, .checklist ol { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.checklist li label { display: flex; gap: .4rem; align-items: baseline; cursor: pointer; }
.checklist input[type=checkbox] { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; flex: none; translate: 0 .15rem; }
.checklist .qty { font-variant-numeric: tabular-nums; font-weight: 600; }
.checklist .where { color: var(--muted); font-size: .82rem; margin-left: 1.5rem; }
.checklist .where.warn { color: var(--warn); }
.checklist li.checked .name, .checklist li.checked .qty { text-decoration: line-through; color: var(--muted); }
.checklist button { margin-top: .75rem; }

/* Composer */
.composer { position: sticky; bottom: 0; background: var(--bg); padding: .5rem 0 .75rem; border-top: 1px solid var(--border); }
.input-row { display: flex; gap: .5rem; align-items: flex-end; }
.input-row textarea {
  flex: 1; font: inherit; resize: none; min-height: 2.8rem; max-height: 10rem; padding: .6rem .8rem;
  border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.input-row .stop { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.fineprint { color: var(--muted); font-size: .75rem; margin: .4rem 0 0; }

.actions button { white-space: nowrap; }

@media (max-width: 600px) {
  .brand .muted { display: none; }
  .actions { gap: .35rem; }
  .actions button { padding: .35rem .7rem; font-size: .85rem; }
  .question { max-width: 95%; }
  .answer { padding: .6rem .75rem; }
}

/* My stations */
.overlay {
  position: fixed; inset: 0; z-index: 10; background: rgb(0 0 0 / 45%); display: flex; align-items: flex-start;
  justify-content: center; padding: 5vh 16px;
}
.panel {
  width: 100%; max-width: 40rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem 1.25rem; max-height: 90vh; display: flex; flex-direction: column;
}
.panel h2 { font-size: 1.2rem; margin: 0 0 .25rem; }
.panel header p { margin: 0 0 .5rem; font-size: .9rem; }
.panel .groups { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; overflow-y: auto; min-height: 0; }
.panel ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .3rem; }
.panel label { display: flex; gap: .45rem; align-items: baseline; cursor: pointer; flex-wrap: wrap; }
.panel input[type=checkbox] { accent-color: var(--accent); width: 1.05rem; height: 1.05rem; flex: none; translate: 0 .15rem; }
.panel .small { font-size: .78rem; }
.panel footer {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap;
  margin-top: .75rem; padding-top: .75rem; border-top: 1px solid var(--border);
}
.panel .buttons { display: flex; gap: .4rem; }
.checklist .needs { color: var(--warn); font-size: .88rem; margin: .4rem 0 0; }

@media (max-width: 600px) {
  .panel .groups { grid-template-columns: 1fr; }
  .overlay { padding: 2vh 8px; }
  .panel { max-height: 96vh; padding: .75rem 1rem; }
}

/* Links that look like ghost buttons (topbar "Map", "Chat"). */
a.button {
  display: inline-block; font: inherit; text-decoration: none; border: 1px solid var(--border); border-radius: 999px;
  padding: .5rem 1rem; white-space: nowrap; color: var(--text);
}
a.button:focus-visible, .map-links a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.map-links { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0 0; }
.map-links a {
  font-size: .88rem; padding: .25rem .75rem; border-radius: 999px; background: var(--accent-soft); text-decoration: none;
}
.map-links a::before { content: "◎ "; }
@media (max-width: 600px) { .actions a.button { padding: .35rem .7rem; font-size: .85rem; } }

/* World map: filters on the left, the map fills the rest of the screen. */
.map-app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }
.map-app .topbar { padding: .6rem 16px; }
.map-body { flex: 1; min-height: 0; display: flex; }
.map-panel {
  width: 17rem; flex: none; overflow-y: auto; padding: .25rem 16px 1rem; border-right: 1px solid var(--border);
  background: var(--surface);
}
.map-panel h3:first-child { margin-top: .75rem; }
.map-panel label { display: flex; align-items: center; gap: .45rem; padding: .15rem 0; cursor: pointer; }
.map-panel input[type=checkbox] { accent-color: var(--accent); width: 1rem; height: 1rem; }
.map-panel input[type=number], .map-panel input[type=search] {
  font: inherit; width: 100%; padding: .4rem .6rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text);
}
.map-panel .levels { display: flex; align-items: center; gap: .4rem; }
.map-panel .levels input { width: 4.5rem; }
.map-panel .small { font-size: .78rem; margin: .3rem 0 0; }
.map-results ol { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; counter-reset: hl; }
.map-results .hl {
  width: 100%; text-align: left; border-radius: 8px; padding: .4rem .55rem .4rem 2.1rem; position: relative;
  background: var(--bg); color: var(--text); border: 1px solid var(--border); display: grid; line-height: 1.3;
}
.map-results .hl::before {
  counter-increment: hl; content: counter(hl); position: absolute; left: .5rem; top: .45rem; width: 1.2rem; height: 1.2rem;
  border-radius: 50%; background: #6d4fc2; color: #fff; font-size: .72rem; display: grid; place-items: center; font-weight: 600;
}
.map-results .hl span { color: var(--muted); font-size: .8rem; }
.swatch { display: inline-block; width: .7rem; height: .7rem; flex: none; }
.swatch.gold { background: #e2b13c; transform: rotate(45deg) scale(.85); border: 1px solid #3a2f1c; }
.swatch.silver { background: #cfd3da; transform: rotate(45deg) scale(.85); border: 1px solid #3a2f1c; }
.swatch.enemy { background: rgb(196 64 52 / 60%); border-radius: 50%; border: 1px solid rgb(110 24 18); }
.map-view { flex: 1; min-width: 0; position: relative; overflow: hidden; background: #2a282d; touch-action: none; }
.map-view canvas { display: block; cursor: grab; }
.map-view canvas:active { cursor: grabbing; }
.map-tip {
  position: absolute; z-index: 1; max-width: 20rem; pointer-events: none; padding: .45rem .65rem; border-radius: 8px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: .85rem;
  line-height: 1.35;
}
.map-tip .muted { font-size: .8rem; }
.map-hint {
  position: absolute; left: 50%; bottom: .6rem; translate: -50% 0; font-size: .75rem; padding: .2rem .6rem; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 85%, transparent); pointer-events: none; white-space: nowrap;
}
@media (max-width: 700px) {
  .map-body { flex-direction: column-reverse; }
  .map-panel { width: auto; max-height: 38vh; border-right: 0; border-top: 1px solid var(--border); }
  .map-hint { display: none; }
}
.swatch.node { background: rgb(64 160 72 / 85%); border-radius: 50%; border: 1px solid #173d1b; }
.swatch.drop { background: rgb(52 110 200 / 85%); border-radius: 50%; border: 1px solid #0f2a55; }
.swatch.mine { background: #7a4a24; border: 1px solid #fff; outline: 1px solid #7a4a24; }
.map-dig { margin: .5rem 0 0; padding: .45rem .6rem; border-radius: 8px; background: color-mix(in srgb, rgb(150 70 210) 14%, transparent); line-height: 1.35; }
.swatch.spire { background: #e9e2cf; border: 1px solid #2b2620; clip-path: polygon(20% 100%, 40% 0, 60% 0, 80% 100%); width: .8rem; height: .9rem; }
.base-row { display: flex; gap: .4rem; }
.checklist .stations { list-style: none; padding: 0; margin: 0; display: grid; gap: .45rem; }
.checklist .stations .where { margin-left: 0; }
.swatch.night { background: rgb(70 60 140 / 70%); border-radius: 50%; border: 1px solid rgb(30 22 80); }
.map-panel label.sub { padding-left: 1.4rem; font-size: .92rem; }
.map-results.route ol { counter-reset: hl -1; }
.map-results.route li:first-child .hl::before { content: "S"; }
.swatch.well { background: #2d2438; border: 2px solid #8fd16a; border-radius: 50%; }
