:root {
  --bg: #faf6f0;
  --surface: #ffffff;
  --ink: #2a1f1a;
  --muted: #66564c;
  --line: #eadfd3;
  --accent: #7a1f1f;
  --accent-ink: #ffffff;
  --bubble-me: #7a1f1f;
  --bubble-me-ink: #ffffff;
  --bubble-them: #f3ebe1;
  --spice: #c2410c;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(60, 30, 10, 0.08);
  --ok: #15803d;
  --warn: #b45309;
  --off: #8a7c72;
  --fs-xs: 0.8rem;    /* fine print, tags, small buttons */
  --fs-sm: 0.9rem;    /* secondary text, pills, descriptions */
  --fs-md: 1rem;      /* body, dish names */
  --fs-lg: 1.25rem;   /* section headings */
  --fs-xl: 1.75rem;   /* the restaurant name */
  --tap: 44px;        /* comfortable touch target */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120f;
    --surface: #211a16;
    --ink: #f3ebe1;
    --muted: #b3a498;
    --line: #3a2f28;
    --accent: #e0a458;
    --accent-ink: #1a120c;
    --bubble-me: #e0a458;
    --bubble-me-ink: #1a120c;
    --bubble-them: #2d241f;
    --spice: #fb923c;
    --shadow: none;
    --ok: #4ade80;
    --warn: #fbbf24;
    --off: #8a7c72;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: inherit; }
h1, h2, .tag { text-wrap: balance; }
p { text-wrap: pretty; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* Korean wraps between words, not inside them. Georgia has no Korean letters, so Korean headings name a Korean
   face right after it (otherwise the browser picks a thin fallback that looks weaker than the Latin headings). */
:lang(ko) { word-break: keep-all; }
:lang(ko) .brand, :lang(ko) .menu h2, :lang(ko) .band h2 {
  font-family: Georgia, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
}

/* Keyboard focus: one clear ring everywhere, drawn outside the element so it also shows on accent-coloured buttons */
:where(a, button, input, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Skip links: out of sight until a keyboard user tabs to them */
.skips { position: fixed; left: 12px; top: -120px; z-index: 100; display: flex; gap: 8px; }
.skips:focus-within { top: 8px; }
.skips a {
  background: var(--accent); color: var(--accent-ink); padding: 10px 16px; border-radius: 999px; font-weight: 600;
  text-decoration: none;
}

/* Header */
.top { position: relative; overflow: hidden; padding: 16px 0 12px; }
.top .wrap { position: relative; z-index: 1; }
.brandrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.brand { margin: 0; font: 700 clamp(1.2rem, 5.6vw, var(--fs-xl))/1.15 Georgia, "Times New Roman", serif; letter-spacing: 0.01em; }
.langs { display: flex; gap: 4px; flex: none; margin-left: auto; }
.langs button {
  font: inherit; font-size: var(--fs-xs); border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 4px 10px; min-height: 28px; cursor: pointer;
}
.langs button:hover { border-color: var(--accent); color: var(--ink); }
.langs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.tag { margin: 4px 0 10px; color: var(--muted); }
.quick { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; font-size: var(--fs-sm); }
.quick a { display: inline-flex; align-items: center; min-height: 28px; text-decoration: none; color: var(--muted); }
.quick a:hover { color: var(--ink); }
.quick .cta {
  color: var(--accent-ink); background: var(--accent); padding: 6px 14px; border-radius: 999px; font-weight: 600;
}

/* Layout: chat first on mobile, side by side on desktop */
.layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding-bottom: 24px; }
.layout > * { min-width: 0; }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(360px, 440px) 1fr; align-items: start; }
  .chat {
    position: sticky; top: calc(var(--bar-offset, 40px) + 12px); height: calc(100vh - var(--bar-offset, 40px) - 24px);
    transition: top 0.2s ease, height 0.2s ease;   /* follows the status bar sliding away and back */
  }
  .log { max-height: none; }
}

/* Chat. On a phone the card is only as tall as its conversation (the message box stays on the first screen); the
   message list scrolls inside it once it gets long. On desktop the card fills the side panel. */
.chat {
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.chat-head { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-head small { display: block; color: var(--muted); font-size: var(--fs-xs); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #16a34a; flex: none; }
.log {
  list-style: none; margin: 0; padding: 16px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  max-height: 58vh; max-height: 58dvh;
}
.msg { max-width: 86%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.them { background: var(--bubble-them); border-bottom-left-radius: 6px; align-self: flex-start; }
.msg.me { background: var(--bubble-me); color: var(--bubble-me-ink); border-bottom-right-radius: 6px; align-self: flex-end; }
.msg.typing { color: var(--muted); font-style: italic; }
/* A dish name in a reply: tap it to see that dish on the menu */
.dish-link {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-align: inherit;
  text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.dish-link:hover { color: var(--accent); }
.chips { display: flex; gap: 8px; padding: 0 16px 10px; overflow-x: auto; scrollbar-width: none; }
.chips[hidden] { display: none; }
.chips button, .tabs button {
  font: inherit; font-size: var(--fs-sm); border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 6px 12px; white-space: nowrap; cursor: pointer;
}
.chips button:hover, .tabs button:hover { border-color: var(--accent); }
.composer { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.composer input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 10px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.composer button {
  font: inherit; font-weight: 600; border: 0; border-radius: 999px; padding: 0 18px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
}
.composer button:disabled { opacity: 0.5; cursor: wait; }

/* Menu */
.menu h2 { font: 700 var(--fs-lg)/1.2 Georgia, serif; margin: 4px 0 6px; }
.menu-note { margin: 0 0 12px; color: var(--muted); font-size: var(--fs-sm); }

/* "Right now" picks: 2-3 dishes that fit the restaurant's own weather, shown above the menu tabs */
.picks { margin: 0 0 12px; }
.picks[hidden] { display: none; }
.picks-label { margin: 0 0 8px; font-size: var(--fs-sm); color: var(--muted); }
.picks-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pick {
  font: inherit; font-size: var(--fs-sm); color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px; cursor: pointer;
}
.pick::after { content: " \203A"; color: var(--muted); }
.pick:hover { border-color: var(--accent); color: var(--accent); }

/* Menu categories. The bar stays under the status bar while a long list scrolls. On a phone the categories scroll
   sideways with a soft fade at the edge that has more; from tablet width they wrap so every category is visible. */
.tabbar {
  position: sticky; top: var(--bar-offset, 40px); z-index: 20; background: var(--bg); padding: 6px 0 8px; margin-bottom: 4px;
  box-shadow: 0 1px 0 var(--line); transition: top 0.2s ease;
}
.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs[data-fade="end"] {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
}
.tabs[data-fade="start"] {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent);
}
.tabs[data-fade="both"] {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent);
}
@media (min-width: 700px) {
  .tabs { flex-wrap: wrap; overflow: visible; -webkit-mask-image: none; mask-image: none; }
}
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.item-top { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; align-items: baseline; }
.item h3 { margin: 0; font-size: var(--fs-md); min-width: 0; overflow-wrap: anywhere; }
/* Dishes with several sizes have a long price line. Each "Regular $19.95" stays together, but the line may wrap
   between sizes (or drop under the name) so it can never push the page wider than the screen. */
.price { font-weight: 600; font-size: var(--fs-sm); margin-left: auto; text-align: right; min-width: 0; }
.price-part { white-space: nowrap; }
.desc { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-sm); }
.explain { margin: 6px 0 0; font-size: var(--fs-sm); font-style: italic; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 8px; align-items: center; font-size: var(--fs-xs); color: var(--muted); }
.meta .hot { color: var(--spice); font-weight: 600; }
/* "Ask about this" repeats on every dish, so it is a quiet text button rather than a pill */
.ask {
  font: inherit; font-size: var(--fs-xs); margin-left: auto; padding: 4px 2px; background: none; border: 0; cursor: pointer;
  color: var(--accent); text-decoration: underline; text-underline-offset: 3px;
}
.ask:hover { color: var(--ink); }
.fine, .foot { color: var(--muted); font-size: var(--fs-xs); }
.foot { padding-bottom: 24px; }

/* Jump links, buttons */
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
[id] { scroll-margin-top: calc(var(--bar-h, 40px) + 12px); }   /* jump links must not land under the sticky bar */
.jump { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 12px; }
.jump a {
  display: inline-flex; align-items: center; min-height: 30px; font-size: var(--fs-sm); text-decoration: none; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px;
}
.jump a:hover { color: var(--ink); border-color: var(--accent); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; font: inherit; font-size: var(--fs-sm); font-weight: 600;
  text-decoration: none; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Hours, location, about */
.band { padding-top: 8px; padding-bottom: 28px; }
.band h2 { font: 700 var(--fs-lg)/1.2 Georgia, serif; margin: 4px 0 12px; }
.band h3 { margin: 0 0 8px; font-size: var(--fs-md); }
.hours-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 800px) { .hours-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card .fine { margin: 10px 0 0; }
.status { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-bottom: 12px; }
.status .sub { color: var(--muted); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--off); flex: none; }
.status.open .pulse { background: var(--ok); }
.status.break .pulse { background: var(--warn); }
.hours-table { width: 100%; border-collapse: collapse; }
.hours-table th, .hours-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.hours-table th { font-weight: 600; width: 38%; }
.hours-table th::first-letter { text-transform: uppercase; }
.hours-table tr.today { background: var(--bubble-them); }
.hours-table tr.today th { color: var(--accent); }
address { font-style: normal; margin: 0 0 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.contact { margin: 0; }
.contact a { color: var(--ink); }
.contact a, .foot a { display: inline-flex; align-items: center; min-height: 24px; }
.strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 16px; }
.follow { color: var(--muted); margin-left: 6px; }
.about { max-width: 68ch; }
.about p { margin: 0 0 12px; }
.favorites { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 8px; }
.favorites li { margin: 0; }
.favorite {
  font: inherit; font-size: var(--fs-sm); color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 12px; cursor: pointer;
}
.favorite::after { content: " \203A"; color: var(--muted); }   /* a small arrow: it goes somewhere */
.favorite:hover { border-color: var(--accent); color: var(--accent); }

/* A dish that a house favorite (or anything else) brought to the front */
.item:focus { outline: none; }
.item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.item.spotlight { margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 12px; animation: spotlight 3.2s ease-out; }
@keyframes spotlight {
  0%, 55% { background: var(--bubble-them); box-shadow: 0 0 0 2px var(--accent); }
  100% { background: transparent; box-shadow: 0 0 0 0 transparent; }
}
@media (prefers-reduced-motion: reduce) { .item.spotlight { animation: none; background: var(--bubble-them); box-shadow: 0 0 0 2px var(--accent); } }

/* Open / closed bar at the very top of the page; tapping it jumps to the full hours */
.statusbar {
  display: block; min-height: 38px; text-decoration: none; color: var(--ink); background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;                   /* follows the visitor down the page */
  transition: transform 0.2s ease;
  padding-top: env(safe-area-inset-top, 0px);              /* keeps clear of a phone notch */
}
.statusbar .status { justify-content: center; margin: 0; padding: 8px 16px; font-size: var(--fs-sm); }
.statusbar:hover .status .sub { color: var(--ink); }
.statusbar:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* The bar slides away while scrolling down and returns on any scroll up (frontend/src/autohide.js toggles the class).
   --bar-offset is how much room the bar currently takes: its height, or 0 while hidden. Sticky things use it. */
:root { --bar-offset: var(--bar-h, 40px); }
html.bar-hidden { --bar-offset: 0px; }
html.bar-hidden .statusbar { transform: translateY(-100%); }
@media (prefers-reduced-motion: reduce) { .statusbar, .chat, .tabbar { transition: none; } }

/* ---- Living place: the light outside, the weather, and a calmer look when we are not open ------------------------
   The sky is a soft TINT behind the header, never a theme: the visitor's own light or dark theme stays in charge and
   text stays readable. --sky-a is the strongest point (top of the header). frontend/tests/contrast.test.mjs reads the
   two palette blocks below and fails if any text would fall below 4.5:1 on any tint. Keep their format. */
.top { background: linear-gradient(180deg, var(--sky-a, transparent), var(--sky-b, transparent) 78%, transparent); }

/* Rain/snow animation behind the header, matching the restaurant's own weather (frontend/src/weatherfx.js).
   Purely decorative: it never sits over anything but the header's own tint, at low opacity, and stops for
   prefers-reduced-motion (the JS checks the same media query app.js already relies on for the bar/chat). */
.weatherfx { position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0.6; }
@media (prefers-reduced-motion: reduce) { .weatherfx { display: none; } }

/* sky-palette:light */
html.phase-dawn   { --sky-a: rgba(255, 166, 120, 0.22); --sky-b: rgba(255, 228, 196, 0.10); --sw-a: #ff9f6b; --sw-b: #ffd4a8; --sw-ink: #3b2410; }
html.phase-day    { --sky-a: rgba(147, 197, 253, 0.18); --sky-b: rgba(147, 197, 253, 0.05); --sw-a: #2b78d0; --sw-b: #4f9bea; --sw-ink: #ffffff; }
html.phase-golden { --sky-a: rgba(251, 176, 64, 0.26);  --sky-b: rgba(253, 224, 171, 0.10); --sw-a: #f59e0b; --sw-b: #fcd34d; --sw-ink: #3b2410; }
html.phase-dusk   { --sky-a: rgba(167, 139, 250, 0.22); --sky-b: rgba(244, 171, 186, 0.10); --sw-a: #6d4fb8; --sw-b: #b7638a; --sw-ink: #ffffff; }
html.phase-night  { --sky-a: rgba(71, 85, 155, 0.16);   --sky-b: rgba(99, 110, 170, 0.05);  --sw-a: #1e2a5a; --sw-b: #3a4b8f; --sw-ink: #ffffff; }
/* calm-look:light */
html.is-calm { --accent: #86484a; --shadow: 0 2px 10px rgba(60, 30, 10, 0.05); }

@media (prefers-color-scheme: dark) {
  /* sky-palette:dark */
  html.phase-dawn   { --sky-a: rgba(255, 150, 100, 0.20); --sky-b: rgba(255, 190, 140, 0.06); }
  html.phase-day    { --sky-a: rgba(96, 165, 250, 0.16);  --sky-b: rgba(96, 165, 250, 0.04); }
  html.phase-golden { --sky-a: rgba(251, 176, 64, 0.22);  --sky-b: rgba(251, 176, 64, 0.06); }
  html.phase-dusk   { --sky-a: rgba(167, 139, 250, 0.22); --sky-b: rgba(244, 114, 182, 0.06); }
  html.phase-night  { --sky-a: rgba(99, 102, 241, 0.18);  --sky-b: rgba(99, 102, 241, 0.05); }
  /* calm-look:dark */
  html.is-calm { --accent: #c9b08a; --shadow: none; }
}

.btn[hidden] { display: none; }   /* .btn sets its own display, which would otherwise beat the hidden attribute */

/* Small phones: keep the message box on the first screen. The chat greeting already says what the tagline and the
   chat subtitle say, so those two lines give way here. */
@media (max-width: 599px) {
  .tag, .chat-head small { display: none; }
  .top { padding: 12px 0 10px; }
  .jump { margin-top: 8px; }
  .log { padding: 12px; }
  .chips { padding-bottom: 8px; }
  .composer { padding-top: 10px; }
}

/* Touch screens: every button and link a finger has to hit is at least 44px tall */
@media (pointer: coarse) {
  .langs button, .jump a, .tabs button, .pick, .favorite, .chips button, .btn, .quick a, .composer button { min-height: var(--tap); }
  .langs button { padding-left: 12px; padding-right: 12px; }
  .ask { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 6px; }
  .contact a, .foot a { min-height: var(--tap); }
}
