:root {
  --bg: #11161f;
  --panel: #1a212d;
  --panel-2: #222b3a;
  --line: #2c3647;
  --text: #e8e4da;
  --muted: #9aa3b2;
  --gold: #d9b26a;
  --gold-dim: #8a7444;
  --link: #8fb8e8;
  --indigo: #6c7fd8;
  --ruby: #d0607a;
  --danger: #e07a6a;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  min-height: 100vh;
}
[hidden] { display: none !important; }
a { color: var(--link); text-decoration: none; }
button, input { font: inherit; color: inherit; }

/* ---------- layout ---------- */
.view {
  padding: calc(var(--safe-t) + 52px) 16px calc(var(--safe-b) + 96px);
  max-width: 640px;
  margin: 0 auto;
}
.view-head h1 {
  margin: 0;
  font: 700 30px/1.15 "Iowan Old Style", "Palatino", Georgia, serif;
  letter-spacing: .01em;
}
.view-head .sub { margin: 2px 0 16px; color: var(--gold); font-size: 13px; letter-spacing: .06em; text-transform: uppercase; }
.note { color: var(--muted); font-size: 13px; text-align: center; margin: 18px 0 0; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(2, 1fr);
  padding: 6px 8px calc(var(--safe-b) + 6px);
  background: rgba(17, 22, 31, .92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  z-index: 10;
}
.tabs button {
  background: none; border: 0; padding: 6px 0 2px;
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  font-size: 11px; color: var(--muted);
}
.tabs button span { font-size: 22px; filter: grayscale(1) opacity(.6); transition: filter .15s; }
.tabs button.active { color: var(--gold); }
.tabs button.active span { filter: none; }

/* ---------- search ---------- */
.search { display: flex; gap: 8px; }
.search input {
  flex: 1; min-width: 0;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font-size: 17px; outline: none;
}
.search input:focus { border-color: var(--gold-dim); }
.search button, .quick button, .choices button, .login button {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 0 16px; font-weight: 600;
}
.search button { background: var(--gold); color: #1b1608; border-color: var(--gold); }
.quick { display: flex; gap: 8px; margin: 10px 0 0; flex-wrap: wrap; }
.quick button { padding: 9px 14px; font-size: 14px; }
.quick button:active, .choices button:active { background: var(--line); }

.recent { display: flex; gap: 6px; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px; scrollbar-width: none; }
.recent::-webkit-scrollbar { display: none; }
.recent button {
  flex: none; background: none; border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 11px; font-size: 13px; color: var(--muted);
}
.results { margin-top: 16px; }

/* ---------- embed card (Discord-style) ---------- */
.embed {
  background: var(--panel); border-radius: 12px; overflow: hidden;
  border-left: 4px solid var(--bar, var(--gold-dim));
  padding: 14px 14px 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 0 12px;
  animation: rise .2s ease-out;
}
.embed > * { grid-column: 1; }
.embed .thumb { grid-column: 2; grid-row: 1 / span 3; width: 72px; height: 72px; object-fit: contain; border-radius: 6px; }
.embed .author { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.embed .author img { width: 20px; height: 20px; border-radius: 50%; }
.embed .title { font-weight: 700; font-size: 18px; line-height: 1.25; margin-bottom: 6px; }
.embed .title a { color: var(--text); }
.embed .desc { font-size: 15px; white-space: normal; overflow-wrap: anywhere; }
.embed .fields { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 14px; margin-top: 10px; }
.embed .field { flex: 1 1 100%; min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.embed .field.inline { flex: 1 1 calc(50% - 14px); }
.embed .field .name { font-weight: 700; font-size: 13px; color: var(--gold); margin-bottom: 2px; }
.embed .image { grid-column: 1 / -1; width: 100%; border-radius: 8px; margin-top: 12px; max-height: 320px; object-fit: cover; }
.embed .footer { grid-column: 1 / -1; color: var(--muted); font-size: 12px; margin-top: 10px; }
.embed code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.embed blockquote { margin: 4px 0; padding-left: 10px; border-left: 3px solid var(--line); }
.open-wiki { display: block; text-align: center; margin: 10px 0 0; font-size: 14px; color: var(--muted); }

/* ---------- choices ---------- */
.choices h2 { font-size: 15px; font-weight: 500; color: var(--muted); margin: 0 0 10px; }
.choices h2 b { color: var(--text); }
.choices .list { display: grid; gap: 6px; }
.choices button { text-align: left; padding: 12px 14px; font-weight: 500; }

/* ---------- ocean ---------- */
.route {
  background: var(--panel); border-radius: 14px; padding: 16px; margin-bottom: 14px;
  border-top: 3px solid var(--accent);
}
.route.indigo { --accent: var(--indigo); }
.route.ruby { --accent: var(--ruby); }
.route .label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.route .dest { font: 700 24px/1.2 "Iowan Old Style", "Palatino", Georgia, serif; margin: 4px 0 2px; }
.route .tod { color: var(--muted); font-size: 14px; }
.route .count { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 10px 0 0; }
.route .count small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.route .stops { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 10px 0; font-size: 13px; }
.route .stops span { background: var(--panel-2); border-radius: 6px; padding: 3px 8px; }
.route .fabled { font-size: 14px; }
.route .fabled b { color: var(--gold); font-weight: 600; }
.route .later { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.route .later div { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; padding: 5px 0; }
.route .later .when { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.route .later .fab { color: var(--muted); font-size: 12px; display: block; }

/* ---------- states ---------- */
.loading { display: flex; justify-content: center; padding: 30px 0; }
.loading::after {
  content: ""; width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--gold);
  animation: spin .8s linear infinite;
}
.error { color: var(--danger); font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 8px; }
.login-icon { width: 84px; height: 84px; border-radius: 20px; }
.login h1 { font: 700 26px "Iowan Old Style", "Palatino", Georgia, serif; margin: 8px 0 12px; }
.login form { display: grid; gap: 10px; width: 100%; max-width: 300px; }
.login input { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 17px; }
.login button { background: var(--gold); color: #1b1608; border: 0; padding: 12px; }
.route .stops span:not(:last-child)::after { content: " →"; color: var(--muted); }
.ocean-banner { width: 100%; height: 150px; object-fit: cover; border-radius: 14px; margin-bottom: 14px; display: block; }
.recent button.clear { border-style: dashed; color: var(--danger); }
.ocean-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.ocean-head h2 { margin: 0; font: 700 24px/1.2 "Iowan Old Style", "Palatino", Georgia, serif; }
.ocean-head .sub { margin: 2px 0 0; color: var(--gold); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.ocean-head .head-icon { width: 56px; height: 56px; object-fit: contain; border-radius: 8px; flex: none; }
.view-head.with-avatar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.view-head.with-avatar .sub { margin-bottom: 0; }
.avatar { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; flex: none; border: 2px solid var(--gold-dim); }
