/* KinRai — mobile-first, palette from the design canvas. */
:root {
  --bg: #F4F5F1;
  --surface: #FFFFFF;
  --ink: #1B1F1A;
  --muted: #5B6359;
  --line: #E3E5DE;
  --line-strong: #D9DCD3;
  --placeholder: #E6E1D6;
  --accent: #C2410C;
  --accent-dark: #9A3412;
  --accent-soft: #FBEDE6;
  --good: #2F5D50;
  --good-soft: #E3EBE6;
  --bad: #8A3B12;
  --font: 'IBM Plex Sans Thai', 'Noto Sans Thai', system-ui, sans-serif;
  --display: 'Bai Jamjuree', 'IBM Plex Sans Thai', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
a:hover { color: var(--accent-dark); }
img { display: block; max-width: 100%; }
input, select, textarea, button { font: inherit; color: inherit; }

.app { max-width: 480px; margin: 0 auto; min-height: 100vh; position: relative; }
.app.has-nav { padding-bottom: 88px; }
.page { padding: 24px 20px; display: flex; flex-direction: column; gap: 16px; }
.page-flush { padding: 0 0 96px; gap: 8px; }
.pad { padding: 8px 20px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.section { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

.h1 { margin: 0; font-family: var(--display); font-size: 28px; font-weight: 700; line-height: 1.2; }
.h2 { margin: 0; font-family: var(--display); font-size: 18px; font-weight: 700; }
.h2.big { font-size: 24px; }
.count { font-size: 16px; font-weight: 500; font-family: var(--font); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; }
.good { color: var(--good); font-weight: 600; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: .04em; }
.note { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
p { margin: 0; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 16px; border-radius: 14px; border: 1px solid transparent; font-weight: 600; font-size: 16px; text-decoration: none; cursor: pointer; background: var(--surface); }
.btn-primary { background: var(--accent); color: #FFFFFF; }
.btn-primary:hover { background: var(--accent-dark); color: #FFFFFF; }
.btn-outline { border-color: var(--ink); color: var(--ink); }
.btn-outline:hover { color: var(--ink); background: var(--bg); }
.btn-dark { background: var(--ink); color: #FFFFFF; }
.btn-danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn-dashed { border: 1px dashed #8A8F86; background: transparent; color: var(--muted); font-weight: 500; min-height: 44px; }
.btn-small { min-height: 44px; font-size: 14px; padding: 0 14px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; }
.btn-row > .btn { flex: 1; }
.btn-google { border-color: var(--line-strong); color: var(--ink); width: 100%; }
.icon-btn { width: 44px; height: 44px; flex-shrink: 0; border-radius: 22px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; overflow: hidden; }
.avatar { width: 100%; height: 100%; object-fit: cover; }
.link-btn { background: none; border: 0; padding: 10px 4px; color: var(--accent); font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; }
.link-btn.danger { color: var(--bad); }

/* Chips & tags */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 36px; padding: 6px 14px; border-radius: 18px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); text-decoration: none; font-size: 14px; }
.chip.on { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }
.chip:hover { color: var(--ink); }
.chip.on:hover { color: #FFFFFF; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; padding: 4px 10px; border-radius: 10px; background: var(--good-soft); color: var(--good); }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; }
.card.empty { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.pick-photo { width: 100%; height: 160px; object-fit: cover; }
.placeholder { background: var(--placeholder); color: #6B6455; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.pick-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.inset { background: var(--bg); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.menu-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-decoration: none; color: var(--ink); display: flex; flex-direction: column; gap: 2px; }
.tile:hover { color: var(--ink); border-color: var(--line-strong); }

/* Lists */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item, .menu-item { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; gap: 12px; align-items: center; color: var(--ink); text-decoration: none; }
a.list-item:hover { color: var(--ink); border-color: var(--line-strong); }
.list-item a { color: var(--ink); text-decoration: none; }
.menu-item { padding: 8px 8px 8px 12px; border-radius: 12px; }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex-shrink: 0; }
.thumb.sm { width: 40px; height: 40px; border-radius: 8px; }
.rating { font-size: 12px; font-weight: 600; color: var(--good); white-space: nowrap; }
.rating-meh { color: var(--muted); }
.rating-never { color: var(--bad); }

/* Search */
.search label { min-height: 44px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-strong); display: flex; align-items: center; gap: 8px; padding: 0 12px; color: var(--muted); }
.search input { border: 0; outline: none; flex: 1; background: transparent; color: var(--ink); min-height: 42px; }

/* Detail */
.hero { height: 200px; background: var(--placeholder); position: relative; display: flex; align-items: center; justify-content: center; }
.hero img { width: 100%; height: 100%; object-fit: cover; }
.hero-left, .hero-right { position: absolute; top: 16px; border: 0; }
.hero-left { left: 16px; }
.hero-right { right: 16px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; }
.stats strong { font-family: var(--display); font-size: 20px; }
.inline-add { display: flex; gap: 6px; align-items: center; border: 1px dashed #8A8F86; border-radius: 12px; padding: 6px; }
.inline-add input, .inline-add select { min-height: 40px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 8px; background: var(--surface); width: 100%; }
.w-price { width: 84px; flex-shrink: 0; }
.upload { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.photo-card { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.photo-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.photo-card figcaption { padding: 8px; display: flex; flex-direction: column; gap: 4px; }
.caption-form { display: flex; gap: 4px; align-items: center; }
.caption-form label { flex: 1; min-width: 0; }
.caption-form input { width: 100%; min-height: 36px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 8px; font-size: 13px; }
.sticky-cta { position: fixed; left: 0; right: 0; bottom: 72px; padding: 12px 20px; background: var(--bg); border-top: 1px solid var(--line); max-width: 480px; margin: 0 auto; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label, .upload label, .new-item label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form input:not([type=radio]):not([type=checkbox]), .form select, .form textarea,
.upload input, .upload select {
  min-height: 48px; border-radius: 12px; border: 1px solid var(--line-strong); padding: 10px 12px; font-size: 16px; color: var(--ink); background: var(--surface); width: 100%;
}
.form textarea { resize: vertical; }
.form-row { display: flex; gap: 8px; }
.form-row > label { flex: 1; min-width: 0; }
.form-row > .w-price { flex: 0 0 84px; }
.new-item { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 6px; }
.segmented { display: flex; gap: 6px; flex-wrap: wrap; }
.segmented legend { width: 100%; }
.segmented label { flex: 1; flex-direction: row; }
.segmented input, .pick-chips input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { flex: 1; min-height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 14px; cursor: pointer; padding: 0 8px; white-space: nowrap; }
.segmented input:checked + span { background: var(--ink); color: #FFFFFF; border-color: var(--ink); }
.segmented input:focus-visible + span, .pick-chips input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.pick-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.pick-chips legend { width: 100%; }
.pick-chips label { flex-direction: row; }
.pick-chips span { min-height: 44px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 14px; cursor: pointer; }
.pick-chips input:checked + span { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--bad); font-weight: 600; }

/* Feedback */
.flash { position: sticky; top: 0; z-index: 10; background: var(--good); color: #FFFFFF; padding: 10px 20px; font-size: 14px; }
.alert { background: var(--accent-soft); color: var(--bad); border-radius: 12px; padding: 10px 12px; font-size: 14px; }

/* Login */
.login { min-height: 100vh; padding: 48px 24px; display: flex; flex-direction: column; justify-content: center; gap: 24px; }
.login-brand h1 { margin: 0; font-family: var(--display); font-size: 48px; color: var(--accent); }
.login-brand p { color: var(--muted); font-size: 16px; }

/* Bottom tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; max-width: 480px; margin: 0 auto; height: 72px; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: center; z-index: 5; }
.tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 12px; min-height: 56px; justify-content: center; }
.tabbar a.active { color: var(--accent); font-weight: 600; }
