/* Lantern — a travel companion.
   Phone first. Big targets, high contrast, readable in Kyoto sun and in a dark izakaya. */

:root {
  --amber:  #b46b00;
  --jade:   #067a55;
  --sky:    #1d63c9;
  --violet: #6d43c8;
  --coral:  #c14a20;

  --bg:      #f6f4ef;
  --surface: #ffffff;
  --sunk:    #ece8e0;
  --line:    #e0dad0;
  --line-2:  #cfc7ba;
  --text:    #15181d;
  --muted:   #5d6470;
  --faint:   #8b929e;
  --shadow:  0 1px 2px rgba(24, 20, 12, .05), 0 8px 24px -12px rgba(24, 20, 12, .18);
  --glow:    transparent;

  --r-lg: 22px;
  --r-md: 15px;
  --r-sm: 10px;
  --pad: 18px;
  --tap: 52px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --amber:  #f2b23f;
    --jade:   #45d3a2;
    --sky:    #6fa8ff;
    --violet: #b294f8;
    --coral:  #ff8b64;

    --bg:      #0c0e13;
    --surface: #151922;
    --sunk:    #1b202b;
    --line:    #242a37;
    --line-2:  #333b4b;
    --text:    #eef1f7;
    --muted:   #98a1b4;
    --faint:   #6b7385;
    --shadow:  0 1px 0 rgba(255,255,255,.03) inset, 0 12px 32px -18px rgba(0,0,0,.9);
    --glow:    rgba(255,255,255,.04);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 17px/1.55 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3 { margin: 0; font-weight: 640; letter-spacing: -.02em; line-height: 1.15; }
p { margin: 0 0 .9em; }
p:last-child { margin-bottom: 0; }
a { color: inherit; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- shell ---------- */

.app {
  max-width: 620px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 14px) var(--pad) calc(var(--safe-b) + 96px);
}

.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  margin: calc(-1 * (var(--safe-t) + 14px)) calc(-1 * var(--pad)) 18px;
  padding: calc(var(--safe-t) + 10px) var(--pad) 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
}
.bar.is-stuck { border-bottom-color: var(--line); }
.bar h1 { font-size: 19px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .spacer { flex: 1; }

.icon-btn {
  display: grid; place-items: center;
  width: 40px; height: 40px; flex: none;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted);
  text-decoration: none; cursor: pointer;
}
.icon-btn:active { background: var(--sunk); }

/* ---------- home ---------- */

.greeting { margin-bottom: 22px; }
.greeting h1 { font-size: 27px; margin-bottom: 6px; }
.greeting .where { color: var(--muted); font-size: 16px; }
.greeting .where strong { color: var(--text); font-weight: 600; }

.actions { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.actions > * { min-width: 0; }
.actions .wide { grid-column: 1 / -1; }

.action {
  --accent: var(--amber);
  position: relative;
  display: flex; flex-direction: column; justify-content: space-between;
  gap: 14px; min-height: 112px; padding: 15px;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow);
  text-decoration: none; color: inherit; cursor: pointer; text-align: left;
  transition: transform .12s ease, border-color .12s ease;
}
.action:active { transform: scale(.975); border-color: var(--line-2); }
.action .glyph {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
}
.action .label { display: block; font-size: 17.5px; font-weight: 620; letter-spacing: -.015em; }
.action .sub { display: block; margin-top: 3px; font-size: 14px; font-weight: 400; color: var(--muted); }
.action.wide { min-height: 0; flex-direction: row; align-items: center; gap: 16px; padding: 18px; }
.action.wide .glyph { width: 50px; height: 50px; border-radius: 15px; }
.action.wide .label { font-size: 22px; flex: 1; }

.a-identify  { --accent: var(--amber); }
.a-menu      { --accent: var(--jade); }
.a-price     { --accent: var(--sky); }
.a-translate { --accent: var(--violet); }
.a-nearby    { --accent: var(--coral); }

/* ---------- generic bits ---------- */

.section-title {
  margin: 30px 0 10px; font-size: 13px; font-weight: 620;
  letter-spacing: .07em; text-transform: uppercase; color: var(--faint);
}

.card {
  padding: var(--pad);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow);
}
.card + .card { margin-top: 12px; }

.stack { display: grid; gap: 10px; }
.stack > * { min-width: 0; }  /* grid items default to min-width:auto and refuse to shrink */

.row {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 15px; min-height: var(--tap);
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); text-decoration: none; color: inherit;
}
.row:active { background: var(--sunk); }
.row .dot { width: 9px; height: 9px; border-radius: 999px; flex: none; background: var(--accent, var(--muted)); }
.row .grow { flex: 1; min-width: 0; display: block; }
.row .title { display: block; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { display: block; font-size: 13.5px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .thumb { width: 44px; height: 44px; border-radius: 11px; object-fit: cover; flex: none; background: var(--sunk); }

.k-identify  { --accent: var(--amber); }
.k-menu      { --accent: var(--jade); }
.k-price     { --accent: var(--sky); }
.k-translate { --accent: var(--violet); }
.k-nearby    { --accent: var(--coral); }
.k-nearby .where { display: inline-block; margin-bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: var(--tap); padding: 0 22px; width: 100%;
  border: 0; border-radius: 999px; cursor: pointer;
  background: var(--text); color: var(--bg);
  font-size: 17px; font-weight: 600; text-decoration: none;
  transition: transform .12s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .38; cursor: default; transform: none; }
.btn.accent { background: var(--accent, var(--amber)); color: #12140f; }
.btn.quiet { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: none; color: var(--coral); border: 1px solid var(--line); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--sunk);
  font-size: 13px; color: var(--muted); white-space: nowrap;
}
.pill.hot { border-color: color-mix(in srgb, var(--amber) 45%, transparent); color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); }

.hint { color: var(--muted); font-size: 14.5px; }
.empty { padding: 34px 20px; text-align: center; color: var(--faint); }

.flash {
  margin-bottom: 14px; padding: 12px 15px; border-radius: var(--r-md);
  background: color-mix(in srgb, var(--amber) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--amber) 35%, transparent);
  font-size: 15px;
}

/* ---------- capture ---------- */

.capture { display: grid; gap: 14px; }
.where {
  justify-self: start; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--muted); font-size: 13.5px; font-variant-numeric: tabular-nums;
}
.pin-picker {
  width: min(100%, 440px); max-width: calc(100vw - 24px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
}
.pin-picker::backdrop { background: rgba(12, 14, 19, .55); }
.pin-map { height: min(62vh, 420px); border-radius: var(--r-lg) var(--r-lg) 0 0; }
.pin-reading { padding: 10px 16px 0; }
.pin-actions { display: flex; gap: 8px; padding: 12px 14px 14px; }
.pin-actions .btn { flex: 1; padding: 12px 8px; font-size: 14.5px; }
.pin-mark {
  width: 22px; height: 22px; border-radius: 999px;
  background: var(--amber); border: 3px solid #fff;
  box-shadow: 0 1px 6px rgba(0,0,0,.35);
}
.capture .frame {
  position: relative; display: grid; place-items: center;
  aspect-ratio: 4 / 3; border-radius: var(--r-lg);
  border: 1px dashed var(--line-2); background: var(--sunk);
  color: var(--faint); text-align: center; padding: 20px; overflow: hidden;
}
.capture .frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.capture .frame .prompt { display: grid; gap: 10px; justify-items: center; }
.capture .frame svg { color: var(--accent); }
.capture input[type=file] { display: none; }
.field {
  width: 100%; min-height: var(--tap); padding: 13px 16px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--surface); outline: none;
}
.field:focus { border-color: var(--accent, var(--line-2)); }
textarea.field { min-height: 84px; resize: vertical; }
label.lbl { display: block; font-size: 13.5px; font-weight: 600; color: var(--muted); margin: 0 0 6px 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
  padding: 10px 15px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 15px; user-select: none;
}
.chip input { position: absolute; width: 1px; height: 1px; opacity: 0; margin: 0; }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent, var(--amber)); outline-offset: 2px; }
.chip:has(input:checked) {
  border-color: var(--accent, var(--amber));
  background: color-mix(in srgb, var(--accent, var(--amber)) 14%, transparent);
  color: var(--accent, var(--amber)); font-weight: 560;
}

/* ---------- answer ---------- */

.answer-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.answer-head .kind { font-size: 13px; font-weight: 620; letter-spacing: .07em; text-transform: uppercase; color: var(--accent); }
.answer-head .meta { font-size: 13.5px; color: var(--faint); }

.shot { border-radius: var(--r-lg); border: 1px solid var(--line); margin-bottom: 18px; max-height: 46vh; object-fit: cover; width: 100%; }

.prose { font-size: 17.5px; line-height: 1.62; }
.prose p { margin: 0 0 1.05em; }
.prose p:last-child { margin-bottom: 0; }

.caret { display: inline-block; width: .5em; height: 1.05em; margin-left: 2px; vertical-align: -.16em;
  background: var(--accent); border-radius: 2px; animation: blink 1.1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.thinking { display: flex; align-items: center; gap: 11px; color: var(--muted); font-size: 15.5px; }
.thinking .pill { margin-left: auto; font-variant-numeric: tabular-nums; }
.thinking .orb { width: 11px; height: 11px; border-radius: 999px; background: var(--accent); animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .28; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }

.skeleton { border-radius: var(--r-sm); background: linear-gradient(90deg, var(--sunk) 25%, var(--line) 37%, var(--sunk) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; height: 14px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.failed { border-color: color-mix(in srgb, var(--coral) 40%, transparent); }
.failed .why { color: var(--coral); font-size: 15px; }

.verdict { margin-bottom: 16px; }
.verdict .what { font-size: 22px; font-weight: 640; letter-spacing: -.02em; line-height: 1.3; }
.verdict .grade {
  display: inline-block; margin-top: 9px; padding: 5px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 560;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 11%, transparent); color: var(--accent);
}
.verdict.unsure { --accent: var(--muted); }
.verdict.likely { --accent: var(--amber); }
.verdict.certain { --accent: var(--jade); }

.card.seen { background: var(--sunk); box-shadow: none; }
.seen-title { font-size: 12.5px; font-weight: 620; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); margin-bottom: 7px; }

/* ---------- menu ---------- */

.menu-item {
  display: grid; gap: 4px; padding: 15px 16px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
  width: 100%; text-align: left; cursor: pointer;
}
.menu-item .original { font-size: 22px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.menu-item .romaji { font-size: 13.5px; color: var(--faint); letter-spacing: .02em; }
.menu-item .english { font-size: 16.5px; font-weight: 560; margin-top: 4px; }
.menu-item .blunt { font-size: 15.5px; color: var(--jade); }
.menu-item .note { font-size: 15px; color: var(--muted); margin-top: 6px; }
.menu-item .warn {
  margin-top: 8px; padding: 8px 11px; border-radius: var(--r-sm); font-size: 14.5px;
  color: var(--coral); background: color-mix(in srgb, var(--coral) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--coral) 32%, transparent);
}
.menu-item .foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.menu-item .price { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 560; }
.menu-item.low { border-style: dashed; }

.tag { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--sunk); color: var(--faint); }

.point {
  position: fixed; inset: 0; z-index: 60; display: none;
  place-items: center; padding: 28px;
  background: color-mix(in srgb, var(--bg) 96%, transparent); backdrop-filter: blur(8px);
}
.point[open] { display: grid; }
.point .sheet { text-align: center; display: grid; gap: 18px; max-width: 100%; }
.point .big { font-size: clamp(34px, 11vw, 64px); font-weight: 660; line-height: 1.25; word-break: break-word; }
.point .sub { font-size: 18px; color: var(--muted); }
.point .tip { font-size: 14px; color: var(--faint); }

/* ---------- price ---------- */

.converted { text-align: center; padding: 26px 18px 22px; }
.converted .big { font-size: clamp(40px, 13vw, 62px); font-weight: 660; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.converted .from { margin-top: 4px; font-size: 19px; color: var(--muted); font-variant-numeric: tabular-nums; }
.converted .rate { margin-top: 12px; font-size: 13.5px; color: var(--faint); }
.calc { display: flex; align-items: center; gap: 10px; }
.calc .field { text-align: right; font-variant-numeric: tabular-nums; font-size: 19px; font-weight: 560; }
.calc .cur { font-size: 15px; font-weight: 620; color: var(--muted); min-width: 42px; }
.calc .swap { flex: none; }

/* ---------- nearby ---------- */

.place { display: grid; gap: 6px; padding: 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.place .top { display: flex; align-items: baseline; gap: 10px; }
.place .name { font-size: 18px; font-weight: 620; flex: 1; }
.place .walk { font-size: 13px; color: var(--coral); font-weight: 560; white-space: nowrap; }
.place .cat { font-size: 13px; color: var(--faint); text-transform: lowercase; }
.place .local { font-size: 15px; color: var(--muted); }
.place .why { font-size: 16px; }
.place .aside { font-size: 14.5px; color: var(--muted); }
.place .aside b { color: var(--text); font-weight: 600; }
.place .links { display: flex; gap: 9px; margin-top: 6px; }
.place .maps { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 999px;
  border: 1px solid var(--line); font-size: 14.5px; text-decoration: none; color: var(--text); }

/* ---------- bottom nav ---------- */

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 8px 8px calc(var(--safe-b) + 8px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--line);
}
.tabs a {
  display: grid; justify-items: center; gap: 3px; padding: 7px 0;
  text-decoration: none; color: var(--faint); font-size: 11.5px; font-weight: 560;
  border-radius: 12px;
}
.tabs a[aria-current] { color: var(--text); }
.tabs a[aria-current] svg { color: var(--amber); }

/* ---------- offline queue badge ---------- */

.queued {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 78px); z-index: 40;
  display: none; align-items: center; gap: 9px;
  padding: 10px 16px; border-radius: 999px;
  background: var(--text); color: var(--bg);
  font-size: 14.5px; font-weight: 560; box-shadow: var(--shadow);
}
.queued[data-count]:not([data-count="0"]) { display: flex; }

.footnote .delete-link { text-decoration: underline; }
.footnote form { display: inline; }
.footnote .plain-link { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
.footnote { margin-top: 26px; font-size: 12.5px; color: var(--faint); text-align: center; line-height: 1.7; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
