/* Winenotes. One phone-width column with a fixed tab bar (Journal, + Taste, Insights, Data) at every screen size.
   The tasting wizard follows the WSET Systematic Approach to Tasting: appearance, nose, palate, conclusions.
   No web fonts or other external requests: system fonts keep the page fast and the CSP strict. */
:root {
  --bg: #F4F2F1; --surface: #FFFFFF; --ink: #1D1A1B; --muted: #6F6568; --line: #E2DBDD;
  --accent: #7D1D3F; --accent-ink: #FFFFFF; --accent-soft: #F3E3E9;
  --warn: #8F3F1A; --warn-soft: #F7E8DE;
  --font-display: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, 'Times New Roman', serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141113; --surface: #1E191C; --ink: #F1ECEE; --muted: #A49A9F; --line: #3A3237;
    --accent: #E8859C; --accent-ink: #1A1417; --accent-soft: #3A2630;
    --warn: #F2A584; --warn-soft: #3A2820;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
a { color: var(--accent); }
.app { max-width: 560px; margin-inline: auto; padding-inline: 16px; position: relative; }
.appbar {
  position: sticky; top: 0; z-index: 6;
  margin-inline: -16px; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 10px;
  display: flex; align-items: center; justify-content: space-between; min-height: 52px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.brand svg { color: var(--accent); }
main { padding-block: 14px 120px; }
main:focus { outline: none; }
.kicker {
  display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 6px;
}
h1 { font-family: var(--font-display); font-weight: 600; font-size: 28px; line-height: 1.12; letter-spacing: -0.01em; margin: 0 0 6px; text-wrap: balance; }
h2 { font-family: var(--font-display); font-weight: 600; font-size: 18px; margin: 0 0 10px; }
p { margin: 0; }
.sub, .meta { color: var(--muted); font-size: 13px; margin: 0; }
.lead { color: var(--muted); margin: 4px 0 18px; max-width: 60ch; }
.hint { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; }
.muted { color: var(--muted); }
.page-head { margin-bottom: 14px; }
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-bottom: 10px; }
input, select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
  width: 100%; min-width: 0;
}
textarea { min-height: 88px; resize: vertical; }
select { width: 100%; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input.invalid { border-color: var(--warn); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--accent); }

.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--surface); color: var(--ink); padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line); }
.skip:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  font: inherit; font-size: 14px; min-height: 40px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); font-weight: 600; }
.list { display: grid; gap: 10px; }
.card {
  display: grid; gap: 6px; width: 100%; text-align: left; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; cursor: pointer; min-width: 0;
}
.card:hover { border-color: var(--muted); }
.card-top { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; line-height: 1.2; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.date { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; background: #888; }
.dot.big { width: 16px; height: 16px; margin-top: 8px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { font-size: 12px; line-height: 1; padding: 5px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); background: transparent; }
.pill.q { background: var(--accent-soft); border-color: transparent; font-weight: 600; }
.empty { text-align: center; padding: 36px 12px; color: var(--muted); }
.empty p { margin: 0 0 12px; }
.banner { background: var(--accent-soft); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.banner.warn { background: var(--warn-soft); }
.banner.row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; font: inherit;
  font-weight: 600; font-size: 15px; min-height: 44px; padding: 10px 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none;
}
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); padding-inline: 6px; }
.btn.warn { color: var(--warn); border-color: var(--warn); }
.btn.warn-solid { background: var(--warn); border-color: var(--warn); color: var(--accent-ink); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-row { display: grid; gap: 10px; margin-bottom: 10px; }
.btn-row .btn { width: 100%; }
.empty .btn { width: 100%; max-width: 320px; }
.sect label.btn { width: 100%; margin-top: 10px; }
.actions { display: grid; gap: 10px; margin: 22px 0 8px; }
.actions .btn { width: 100%; min-height: 48px; }
.actions .btn.warn { margin-top: 14px; }
.sect { margin-top: 22px; }
.sheet { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 14px 0; }
.sheet-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.back { margin: 0 0 4px; }
.kvs { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 10px 0; border-top: 1px solid var(--line); }
.kv:first-child { border-top: 0; }
.kv dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.prose { white-space: pre-wrap; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 13px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); }
.ok { color: var(--accent); font-weight: 600; }
.miss { color: var(--warn); font-weight: 600; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 14px; }
.bar-label { min-width: 0; overflow-wrap: anywhere; }
.bar-num { font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.bar-track { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; }
.bar-track span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.list-plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.list-plain li {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; display: flex; justify-content: space-between; gap: 10px; min-width: 0;
}
.list-plain li > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.status { min-height: 1.4em; color: var(--muted); font-size: 14px; }

/* wizard */
.steps { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.step {
  width: 100%; min-height: 40px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); font: inherit; font-family: var(--font-mono); font-size: 13px; cursor: pointer;
}
.step.done { color: var(--ink); }
.step.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.wiz-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 8px; min-width: 0; }
.lbl { font-size: 14px; font-weight: 600; }
.req { font-weight: 400; color: var(--muted); font-size: 12px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.seg { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: 6px; }
.opt {
  font: inherit; font-size: 14px; min-height: 44px; padding: 8px 6px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; overflow-wrap: anywhere;
}
.opt[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.lex-group { display: grid; gap: 6px; margin-bottom: 8px; }
.lex-group .kicker { margin: 0; }
.add-input { margin-top: 4px; }
.blic-row { display: grid; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.blic-row:last-child { border-bottom: 0; }
.suggest { display: flex; justify-content: space-between; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.suggest .meta { display: block; margin-top: 2px; }
details.ded { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
details.ded summary { font-weight: 600; cursor: pointer; min-height: 32px; }
details.ded[open] summary { margin-bottom: 12px; }
.wiz-foot { position: sticky; bottom: env(safe-area-inset-bottom, 0px); background: var(--bg); padding-block: 10px calc(8px + env(safe-area-inset-bottom, 0px)); margin-top: 20px; border-top: 1px solid var(--line); }
.foot-btns { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 10px; }
.foot-btns .btn { width: 100%; min-height: 48px; }
.err { color: var(--warn); font-size: 14px; margin: 0 0 8px; }
.mode-group { display: grid; gap: 10px; }
.mode {
  display: grid; gap: 4px; text-align: left; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; cursor: pointer; min-height: 44px;
}
.mode[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.mode-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; }
#jcats { flex-wrap: nowrap; overflow-x: auto; margin-inline: -16px; padding: 2px 16px 6px; scrollbar-width: none; }
#jcats::-webkit-scrollbar { display: none; }
#jcats .chip { flex: none; }

/* label photo */
.photo-box { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.photo-prev { width: 96px; height: 120px; border-radius: 10px; overflow: hidden; background: var(--bg); border: 1px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 12px; text-align: center; flex: none; }
.photo-prev img { width: 100%; height: 100%; object-fit: cover; }
.photo-actions { display: grid; gap: 8px; justify-items: start; }
.label-photo { margin: 14px 0 0; border-radius: 12px; border: 1px solid var(--line); max-height: 360px; width: auto; max-width: 100%; }

/* tab bar: always visible except in the wizard and the sign-in screens */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabbar-in { max-width: 560px; margin-inline: auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: center; gap: 4px; padding: 8px 12px; }
.tab {
  display: flex; align-items: center; justify-content: center; font: inherit; font-size: 13px; min-height: 44px;
  background: transparent; border: 0; color: var(--muted); cursor: pointer; border-radius: 10px; font-weight: 500; text-decoration: none;
}
.tab[aria-current="page"] { color: var(--ink); font-weight: 600; }
.tab.tab-taste { background: var(--accent); color: var(--accent-ink); font-weight: 600; margin-top: -16px; min-height: 52px; border-radius: 16px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18); }
body[data-route="wizard"] .tabbar, body[data-route="auth"] .tabbar, body[data-route="loading"] .tabbar { display: none; }
body[data-route="auth"] main, body[data-route="loading"] main { padding-bottom: 40px; }

/* sign in / setup */
.auth-tabs { margin-bottom: 14px; }
.auth-tabs .chip { margin: 0; }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 36px; cursor: pointer; font-size: 14px; }
.form .btn.primary { width: 100%; min-height: 48px; }
.noscript { padding: 24px; }

/* toasts */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: grid; justify-items: center; gap: 8px; padding: 0 16px; pointer-events: none; }
.toast { pointer-events: auto; max-width: 520px; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); box-shadow: 0 8px 28px rgba(0, 0, 0, .3); font-size: 14px; }
.toast.err { background: var(--warn); color: #fff; }

@media (max-width: 380px) { .two { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .appbar, .tabbar, .actions, .back, #toasts, .wiz-foot { display: none !important; } body { background: #fff; color: #000; } }
