/* ============================================================================
   Vino — Design A: "Cupertino"
   Apple HIG purist. System font ramp, semantic surfaces, hairline separators,
   translucent materials, one tint colour (deep burgundy) used like iOS uses
   tint: for what you can touch, and nothing else.
   Drop-in replacement — every legacy class name is preserved.
   ========================================================================== */

/* ---------------------------------------------------------------- tokens -- */

:root {
  color-scheme: light;

  /* --- neutral ramp (warm-grey, a whisper of rose) --- */
  --bg:            #f6f4f4;   /* grouped background      */
  --bg-elevated:   #fbfafa;   /* under sheets            */
  --surface:       #ffffff;   /* card / cell             */
  --surface2:      #eeeaea;   /* secondary fill          */
  --fill:          rgba(120, 108, 114, .10);  /* input / chip fill */
  --fill-strong:   rgba(120, 108, 114, .17);  /* pressed           */

  --text:          #1b1418;
  --text2:         #6e6469;   /* secondary label */
  --text3:         #9c9399;   /* tertiary label, chevrons, placeholders */

  --separator:     rgba(27, 20, 24, .09);
  --separator-2:   rgba(27, 20, 24, .06);

  /* --- the single accent --- */
  --accent:        #7a1e2e;                    /* tint: text, icons, focus */
  --accent-fill:   #7a1e2e;                    /* filled controls          */
  --accent-press:  #661726;
  --on-accent:     #ffffff;
  --accent-soft:   rgba(122, 30, 46, .085);    /* tinted surfaces          */
  --accent-soft-2: rgba(122, 30, 46, .14);     /* tinted glyph tiles       */
  --accent-ring:   rgba(122, 30, 46, .22);
  --accent-grad:   linear-gradient(180deg, #8a2436, #6d1a29);

  /* muted companion tints — only ever used behind a 44px glyph tile */
  --tile-ink:      rgba(52, 46, 62, .10);
  --tile-ink-fg:   #4a4356;
  --tile-sand:     rgba(112, 84, 54, .12);
  --tile-sand-fg:  #6d5535;

  --danger:        #c0392b;

  /* --- elevation --- */
  --shadow:    0 1px 1px rgba(27, 20, 24, .04), 0 3px 10px rgba(27, 20, 24, .05);
  --shadow-md: 0 1px 2px rgba(27, 20, 24, .05), 0 8px 24px rgba(27, 20, 24, .08);
  --shadow-lg: 0 2px 6px rgba(27, 20, 24, .07), 0 20px 48px rgba(27, 20, 24, .16);
  --shadow-accent: 0 4px 12px rgba(122, 30, 46, .24), 0 12px 30px rgba(122, 30, 46, .22);

  /* --- geometry --- */
  --radius:    18px;   /* legacy token, still honoured */
  --r-sheet:   22px;
  --r-card:    16px;
  --r-control: 12px;
  --hair:      1px;

  --tabbar-h:  58px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
  --safe-t:    env(safe-area-inset-top, 0px);
  --gutter:    16px;

  /* --- motion (iOS curves) --- */
  --ease-out:    cubic-bezier(.22, 1, .36, 1);
  --ease-sheet:  cubic-bezier(.32, .72, 0, 1);
  --ease-spring: cubic-bezier(.2, .9, .3, 1.02);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg:            #121013;
    --bg-elevated:   #1a171a;
    --surface:       #1d1a1e;
    --surface2:      #272328;
    --fill:          rgba(235, 226, 231, .10);
    --fill-strong:   rgba(235, 226, 231, .18);

    --text:          #f5eff1;
    --text2:         #a69ba1;
    --text3:         #797076;

    --separator:     rgba(245, 239, 241, .12);
    --separator-2:   rgba(245, 239, 241, .07);

    --accent:        #d9848f;
    --accent-fill:   #8e2437;
    --accent-press:  #7a1e2e;
    --on-accent:     #ffffff;
    --accent-soft:   rgba(217, 132, 143, .12);
    --accent-soft-2: rgba(217, 132, 143, .18);
    --accent-ring:   rgba(217, 132, 143, .30);
    --accent-grad:   linear-gradient(180deg, #9c2a3e, #7a1e2e);

    --tile-ink:      rgba(178, 172, 200, .14);
    --tile-ink-fg:   #b8b1c8;
    --tile-sand:     rgba(206, 172, 128, .14);
    --tile-sand-fg:  #cbae86;

    --danger:        #ff6b60;

    --shadow:    0 1px 1px rgba(0, 0, 0, .35), 0 3px 10px rgba(0, 0, 0, .30);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, .40), 0 10px 28px rgba(0, 0, 0, .42);
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, .50), 0 24px 56px rgba(0, 0, 0, .60);
    --shadow-accent: 0 4px 14px rgba(0, 0, 0, .45), 0 12px 30px rgba(142, 36, 55, .38);
  }
}

/* ------------------------------------------------------------------ base -- */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
               system-ui, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  letter-spacing: -.011em;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis-weight: none;
}

button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

input, textarea, select {
  font: inherit;
  letter-spacing: inherit;
  color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:active { opacity: .6; }

img { display: block; }

::selection { background: var(--accent-soft-2); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* horizontal rails scroll without ever showing a bar */
.photo-strip,
.attach-preview,
.search-results,
.chat-scroll,
.modal { scrollbar-width: none; }
.photo-strip::-webkit-scrollbar,
.attach-preview::-webkit-scrollbar,
.search-results::-webkit-scrollbar,
.chat-scroll::-webkit-scrollbar,
.modal::-webkit-scrollbar { width: 0; height: 0; }

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 var(--gutter) calc(var(--tabbar-h) + 40px + var(--safe-b));
}

.hidden { display: none !important; }

/* ---------------------------------------------------------- typography ---- */

.page-title {
  font-size: 34px;
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: -.024em;
  margin: 14px 0 4px;
  text-wrap: balance;
}

.page-sub {
  color: var(--text2);
  font-size: 15px;
  line-height: 1.4;
  letter-spacing: -.006em;
  margin-bottom: 20px;
  text-wrap: pretty;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .005em;
  text-transform: none;          /* HIG: sentence case, not shouting */
  color: var(--text2);
  margin: 26px 0 10px 2px;
}

/* ------------------------------------------------------------- top bar ---- */
/* Sticky translucent chrome; content scrolls beneath it, iOS-style. */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 calc(var(--gutter) * -1) 2px;
  padding: max(10px, env(safe-area-inset-top, 0px)) var(--gutter) 8px;
  min-height: calc(44px + env(safe-area-inset-top, 0px));
  background: var(--bg);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .topbar {
    background: color-mix(in srgb, var(--bg) 72%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
  }
}

.back-btn {
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -.02em;
  color: var(--accent);
  padding: 6px 6px 6px 0;
  margin-left: -2px;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  transition: opacity .18s var(--ease-out);
}
.back-btn:active { opacity: .45; }

/* ---------------------------------------------------------------- cards -- */

.card {
  background: var(--surface);
  border-radius: var(--r-card);
  border: var(--hair) solid var(--separator);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}

.card.tappable {
  transition: transform .32s var(--ease-out), background-color .18s ease;
}
.card.tappable:active {
  transform: scale(.982);
  background: var(--surface2);
  transition-duration: .06s;
}

/* --- hero card ------------------------------------------------------------
   Was: three saturated gradient billboards. Now: one elevated material cell
   with a tinted 44pt glyph tile, a tint-coloured kicker and a chevron — the
   same anatomy iOS uses for a featured row. Colour lives in the tile only. */

.hero-card {
  position: relative;
  display: block;
  width: 100%;
  text-align: left;
  overflow: hidden;
  border-radius: 20px;
  padding: 18px 34px 18px 74px;
  margin-bottom: 12px;
  color: var(--text);
  background:
    radial-gradient(120% 140% at 0% 0%, var(--accent-soft) 0%, transparent 62%),
    var(--surface);
  border: var(--hair) solid var(--separator);
  box-shadow: var(--shadow-md);
  transition: transform .34s var(--ease-out), box-shadow .3s var(--ease-out);
}

.hero-card::after {                       /* affordance chevron */
  content: "\203A";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-52%);
  font-size: 22px;
  line-height: 1;
  font-weight: 500;
  color: var(--text3);
}

.hero-card:active {
  transform: scale(.978);
  box-shadow: var(--shadow);
  transition-duration: .07s;
}

.hero-emoji {                              /* becomes the glyph tile */
  position: absolute;
  left: 16px;
  top: 17px;
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  line-height: 1;
  background: var(--accent-soft-2);
  color: var(--accent);
  opacity: 1;
}

.hero-kicker {
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 1;
}

.hero-title {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.2;
  margin: 3px 0 4px;
  text-wrap: balance;
}

.hero-desc {
  font-size: 14px;
  line-height: 1.42;
  letter-spacing: -.005em;
  color: var(--text2);
  opacity: 1;
  max-width: 42ch;
  text-wrap: pretty;
}

/* muted companion tints — restraint, not rainbow */
.hero-card.alt  { background: radial-gradient(120% 140% at 0% 0%, var(--tile-ink) 0%, transparent 60%), var(--surface); }
.hero-card.alt  .hero-emoji  { background: var(--tile-ink); color: var(--tile-ink-fg); }
.hero-card.alt  .hero-kicker { color: var(--tile-ink-fg); }
.hero-card.alt2 { background: radial-gradient(120% 140% at 0% 0%, var(--tile-sand) 0%, transparent 60%), var(--surface); }
.hero-card.alt2 .hero-emoji  { background: var(--tile-sand); color: var(--tile-sand-fg); }
.hero-card.alt2 .hero-kicker { color: var(--tile-sand-fg); }

/* ---------------------------------------------------------------- lists -- */
/* Inset-grouped table view: one container, hairline separators, no gaps. */

.row-list {
  background: var(--surface);
  border: var(--hair) solid var(--separator);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 12px;
}

.row-list .row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
  padding: 12px 14px;
  min-height: 56px;
  position: relative;
  transition: background-color .18s ease;
}

.row-list .row::after {                    /* inset hairline, iOS-style */
  content: "";
  position: absolute;
  left: 52px;
  right: 0;
  bottom: 0;
  height: var(--hair);
  background: var(--separator);
}
.row-list .row:last-child::after { display: none; }

.row:active { background: var(--fill); transition-duration: 0s; }

.row .row-main { flex: 1; min-width: 0; }

.row .row-title {
  font-size: 16.5px;
  font-weight: 550;
  letter-spacing: -.014em;
  line-height: 1.25;
}

.row .row-sub {
  color: var(--text2);
  font-size: 13.5px;
  line-height: 1.3;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row .chev {
  color: var(--text3);
  font-size: 19px;
  font-weight: 500;
  line-height: 1;
  flex: none;
}

.row .row-emoji {
  flex: none;
  width: 26px;
  text-align: center;
  font-size: 22px;
  line-height: 1;
}

/* ---------------------------------------------------------------- chips -- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  background: var(--fill);
  border: var(--hair) solid transparent;
  box-shadow: none;
  border-radius: 100px;
  padding: 8px 14px;
  min-height: 34px;
  font-size: 14.5px;
  font-weight: 550;
  letter-spacing: -.008em;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: transform .3s var(--ease-out), background-color .18s ease, color .18s ease;
}
.chip:active {
  background: var(--fill-strong);
  transform: scale(.955);
  transition-duration: .06s;
}
.chip.on {
  background: var(--accent-fill);
  color: var(--on-accent);
  border-color: transparent;
}
.chip.on:active { background: var(--accent-press); }
.chip.subtle {
  background: transparent;
  border-color: var(--separator);
  font-weight: 500;
  color: var(--text2);
}
.chip.subtle:active { background: var(--fill); }

/* --------------------------------------------------------------- search -- */

.search-wrap { position: relative; margin: 2px 0 18px; }

.search-input {
  width: 100%;
  padding: 11px 16px 11px 40px;
  border-radius: var(--r-control);
  border: var(--hair) solid transparent;
  background: var(--fill);
  box-shadow: none;
  font-size: 17px;
  letter-spacing: -.014em;
  outline: none;
  transition: box-shadow .2s var(--ease-out), background-color .2s ease;
}
.search-input::placeholder { color: var(--text3); }
.search-input:focus {
  background: var(--surface);
  border-color: var(--separator);
  box-shadow: 0 0 0 3.5px var(--accent-ring);
}
.search-ico {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  font-size: 17px;
  line-height: 1;
  pointer-events: none;
}

.search-results {
  position: absolute;
  z-index: 32;
  left: 0; right: 0;
  top: calc(100% + 8px);
  background: var(--surface);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-lg);
  border: var(--hair) solid var(--separator);
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  animation: pop .18s var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.985); } }

.search-results button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 16px;
  min-height: 46px;
  font-size: 16px;
  letter-spacing: -.012em;
  box-shadow: inset 0 -1px 0 var(--separator-2);
}
.search-results button:last-child { box-shadow: none; }
.search-results button:active { background: var(--fill); }
.search-results button[disabled] { color: var(--text2); background: none; }

/* -------------------------------------------------------------- tab bar -- */

.tabbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  justify-content: space-around;
  background: var(--bg);
  border-top: var(--hair) solid var(--separator);
  padding: 6px 6px calc(6px + var(--safe-b));
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .tabbar {
    background: color-mix(in srgb, var(--bg) 76%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
  }
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 550;
  letter-spacing: 0;
  color: var(--text2);
  padding: 3px 4px;
  min-height: 46px;
  border-radius: 12px;
  transition: color .22s var(--ease-out), transform .3s var(--ease-out);
}
.tab:active { transform: scale(.93); transition-duration: .06s; }
.tab.on { color: var(--accent); }

.tab-ico {
  font-size: 21px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 26px;
}
.tab-ico svg {
  width: 26px;
  height: 26px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke-width .22s var(--ease-out);
}
.tab.on .tab-ico svg { stroke-width: 2.15; }
.tab-ico .ico-fill { fill: currentColor; stroke: none; }

/* -------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent-fill);
  color: var(--on-accent);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -.012em;
  border-radius: 100px;
  padding: 0 22px;
  min-height: 50px;
  width: 100%;
  box-shadow: none;
  transition: transform .32s var(--ease-out), background-color .18s ease, opacity .18s ease;
}
.btn:active {
  transform: scale(.975);
  background: var(--accent-press);
  transition-duration: .06s;
}
.btn.secondary {
  background: var(--fill);
  color: var(--text);
  border: none;
}
.btn.secondary:active { background: var(--fill-strong); }
.btn.small {
  width: auto;
  min-height: 38px;
  padding: 0 16px;
  font-size: 15px;
}
.btn.ghost {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: none;
}
.btn.ghost:active { background: var(--accent-soft-2); }
.btn:disabled { opacity: .4; transform: none; }

/* ---------------------------------------------------------------- login -- */

.login-wrap {
  min-height: 100dvh;
  /* cancel #app's tab-bar reservation so the form is optically centred */
  margin-bottom: calc((var(--tabbar-h) + 40px + var(--safe-b)) * -1);
  padding: env(safe-area-inset-top, 0px) 0 calc(6dvh + var(--safe-b));
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-logo {                              /* app-icon tile, not a loose emoji */
  width: 84px;
  height: 84px;
  margin: 0 auto;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  line-height: 1;
  text-align: center;
  background: var(--surface);
  border: var(--hair) solid var(--separator);
  box-shadow: var(--shadow-md);
}

.login-title {
  font-size: 34px;
  font-weight: 700;
  text-align: center;
  letter-spacing: -.028em;
  margin: 18px 0 4px;
}

.login-sub {
  text-align: center;
  color: var(--text2);
  font-size: 15px;
  letter-spacing: -.004em;
  margin-bottom: 32px;
}

.field { margin-bottom: 12px; }

.field input,
.field textarea,
.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-control);
  border: var(--hair) solid var(--separator);
  background: var(--surface);
  font-size: 17px;
  letter-spacing: -.012em;
  line-height: 1.35;
  outline: none;
  box-shadow: none;
  transition: box-shadow .2s var(--ease-out), border-color .2s ease;
}
.field textarea { resize: vertical; min-height: 44px; }
.field select { min-height: 46px; }
.field input::placeholder,
.field textarea::placeholder { color: var(--text3); }
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: transparent;
  box-shadow: 0 0 0 3.5px var(--accent-ring), 0 0 0 var(--hair) var(--accent) inset;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  letter-spacing: -.004em;
  margin: 0 0 5px 3px;
}

.err {
  color: var(--danger);
  text-align: center;
  font-size: 14px;
  margin-top: 14px;
  min-height: 20px;
}

/* ----------------------------------------------------------------- chat -- */

.chat-page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
}

.chat-scroll {
  flex: 1 1 auto;
  min-height: 0;                 /* let the scroller shrink inside the column */
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 0 14px;
  -webkit-overflow-scrolling: touch;
}

.msg {
  max-width: 82%;
  width: fit-content;
  margin-bottom: 8px;
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 16.5px;
  line-height: 1.45;
  letter-spacing: -.012em;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: msg-in .28s var(--ease-out);
}
@keyframes msg-in { from { opacity: 0; transform: translateY(6px) scale(.985); } }

.msg.user {
  background: var(--accent-fill);
  color: var(--on-accent);
  margin-left: auto;
  border-bottom-right-radius: 7px;
}
.msg.user a { color: var(--on-accent); text-decoration: underline; }
.msg.user b { font-weight: 650; }

.msg.assistant {
  background: var(--surface);
  border: var(--hair) solid var(--separator);
  box-shadow: var(--shadow);
  border-bottom-left-radius: 7px;
}

.msg img {
  max-width: 100%;
  border-radius: 12px;
  margin: 4px 0;
  display: block;
}
.msg p { margin: 0 0 9px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul, .msg ol { margin: 4px 0 9px 20px; }
.msg li { margin-bottom: 3px; }
.msg li:last-child { margin-bottom: 0; }
.msg b { font-weight: 650; }
.msg h1, .msg h2, .msg h3 {
  font-size: 1em;
  font-weight: 650;
  letter-spacing: -.014em;
  margin: 10px 0 4px;
}
.msg > :first-child { margin-top: 0; }

.typing { display: inline-flex; align-items: center; gap: 5px; padding: 3px 0; }
.typing i {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text3);
  margin-right: 0;
  animation: blink 1.3s infinite ease-in-out;
  font-style: normal;
}
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink {
  0%, 70%, 100% { opacity: .25; transform: translateY(0); }
  35%           { opacity: 1;   transform: translateY(-2px); }
}

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 calc(var(--gutter) * -1);
  padding: 8px var(--gutter) calc(10px + var(--safe-b));
  background: var(--bg);
  border-top: var(--hair) solid var(--separator);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .chat-input-bar {
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(22px);
    backdrop-filter: saturate(180%) blur(22px);
  }
}

.chat-input {
  flex: 1;
  min-width: 0;
  border: var(--hair) solid var(--separator);
  background: var(--surface);
  box-shadow: none;
  border-radius: 22px;
  padding: 11px 15px;
  font-size: 17px;
  letter-spacing: -.012em;
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.35;
  transition: box-shadow .2s var(--ease-out);
}
.chat-input::placeholder { color: var(--text3); }
.chat-input:focus { box-shadow: 0 0 0 3.5px var(--accent-ring); }

.icon-btn {
  width: 44px; height: 44px; min-width: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fill);
  border: none;
  box-shadow: none;
  font-size: 19px;
  line-height: 1;
  transition: transform .3s var(--ease-out), background-color .18s ease, opacity .18s ease;
}
.icon-btn:active { transform: scale(.9); background: var(--fill-strong); transition-duration: .06s; }
.icon-btn.primary {
  background: var(--accent-fill);
  color: var(--on-accent);
  border: none;
  font-size: 20px;
  font-weight: 600;
}
.icon-btn.primary:active { background: var(--accent-press); }
.icon-btn:disabled { opacity: .38; transform: none; }

.attach-preview {
  display: flex;
  gap: 8px;
  padding: 6px 0 2px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.attach-preview:empty { display: none; }
.attach-preview .thumb { position: relative; flex: none; }
.attach-preview img {
  height: 62px;
  border-radius: 10px;
  border: var(--hair) solid var(--separator);
}
.attach-preview .x {
  position: absolute;
  top: -6px; right: -6px;
  background: var(--text);
  color: var(--bg);
  border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

/* --------------------------------------------------------------- hearts -- */

.hearts {
  display: flex;
  gap: 3px;
  font-size: 21px;
  line-height: 1;
  justify-content: center;
  margin: 14px 0 6px;
  flex-wrap: wrap;
}
.hearts button {
  padding: 3px 1px;
  line-height: 1;
  filter: grayscale(1) opacity(.26);
  transform: scale(.9);
  transition: transform .3s var(--ease-spring), filter .22s var(--ease-out);
}
.hearts button.on { filter: none; transform: scale(1); }
.hearts button:active { transform: scale(1.3); transition-duration: .08s; }

.hearts-label {
  text-align: center;
  color: var(--text2);
  font-size: 13px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
}

/* ---------------------------------------------------------------- modal -- */

.modal-back {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-top: calc(var(--safe-t) + 10px);
  background: rgba(0, 0, 0, .35);
  animation: fade .28s var(--ease-out);
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
  .modal-back {
    background: rgba(0, 0, 0, .28);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
  }
}
@keyframes fade { from { opacity: 0; } }

.modal {
  background: var(--bg-elevated);
  width: 100%;
  max-width: 640px;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  padding: 8px 18px calc(26px + var(--safe-b));
  box-shadow: 0 -1px 0 var(--separator), var(--shadow-lg);
  animation: rise .42s var(--ease-sheet);
}
@keyframes rise { from { transform: translateY(100%); } }

.modal-grab {
  width: 36px; height: 5px;
  background: var(--text3);
  opacity: .4;
  border-radius: 3px;
  margin: 5px auto 14px;
}

.modal h2 {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -.022em;
  line-height: 1.2;
  margin-bottom: 16px;
  text-wrap: balance;
}

.modal .btn { margin-top: 4px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 10px;
  margin-bottom: 12px;
}
.form-grid .field { margin-bottom: 0; }
.form-grid .full { grid-column: 1 / -1; }

/* ----------------------------------------------------------- wine cards -- */

.wine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}

.wine-card {
  background: var(--surface);
  border-radius: var(--r-card);
  overflow: hidden;
  border: var(--hair) solid var(--separator);
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform .32s var(--ease-out), box-shadow .3s var(--ease-out);
}
.wine-card:active {
  transform: scale(.968);
  box-shadow: none;
  transition-duration: .07s;
}

.wine-card .ph {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--surface2);
  background:
    linear-gradient(160deg, var(--surface2), color-mix(in srgb, var(--surface2) 55%, var(--bg)));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  line-height: 1;
  filter: none;
}

.wine-card .meta { padding: 10px 11px 12px; }

.wine-card .nm {
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.28;
  letter-spacing: -.01em;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.wine-card .sb {
  color: var(--text2);
  font-size: 12px;
  line-height: 1.3;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wine-card .rt {
  font-size: 12px;
  margin-top: 5px;
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ----------------------------------------------------------------- stats -- */

.stat-row {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.stat {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border-radius: var(--r-card);
  padding: 13px 8px 11px;
  text-align: center;
  border: var(--hair) solid var(--separator);
  box-shadow: var(--shadow);
}
.stat b {
  display: block;
  font-size: 23px;
  font-weight: 650;
  letter-spacing: -.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--text2);
  font-weight: 500;
  letter-spacing: -.002em;
}

/* ------------------------------------------------------ knowledge pages -- */

.kn-body {
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: -.011em;
  text-wrap: pretty;
}
.kn-body h1, .kn-body h2, .kn-body h3 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -.02em;
  line-height: 1.25;
  margin: 26px 0 8px;
}
.kn-body h1 { font-size: 21px; }
.kn-body p { margin: 0 0 12px; }
.kn-body ul, .kn-body ol { margin: 0 0 12px 20px; }
.kn-body li { margin-bottom: 5px; }
.kn-body b { font-weight: 650; }

.kn-intro {
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -.013em;
  font-weight: 450;
  padding: 15px 17px;
  background: var(--accent-soft);
  color: var(--text);
  border: var(--hair) solid var(--accent-soft-2);
  border-radius: var(--r-card);
  margin-bottom: 18px;
  text-wrap: pretty;
}

.kn-facts {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 16px 0;
  background: var(--surface);
  border: var(--hair) solid var(--separator);
  border-radius: var(--r-card);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.kn-fact {
  display: flex;
  gap: 11px;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: inset 0 -1px 0 var(--separator-2);
  padding: 12px 15px;
  font-size: 15px;
  line-height: 1.42;
  letter-spacing: -.008em;
}
.kn-fact:last-child { box-shadow: none; }
.kn-fact::before {
  content: "";
  flex: none;
  width: 6px; height: 6px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--accent);
  color: transparent;
  font-weight: 400;
}

/* --------------------------------------------------------------- states -- */

.spinner-wrap {
  text-align: center;
  padding: 56px 20px 30px;
  color: var(--text2);
  font-size: 15px;
  animation: fade .4s var(--ease-out);
}
.spinner {
  width: 26px; height: 26px;
  border: 2.5px solid var(--separator);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 14px;
  animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center;
  color: var(--text2);
  padding: 56px 24px;
  font-size: 15.5px;
  line-height: 1.5;
  text-wrap: pretty;
}
.empty .big {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 14px;
  filter: grayscale(.55);
  opacity: .8;
}

/* --------------------------------------------------------- photo strips -- */

.photo-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  margin: 4px 0 16px;
  padding-bottom: 2px;
}
.photo-strip img {
  height: 130px;
  flex: none;
  border-radius: 12px;
  border: var(--hair) solid var(--separator);
  scroll-snap-align: start;
  transition: transform .3s var(--ease-out);
}
.photo-strip img:active { transform: scale(.97); }

/* ------------------------------------------------------------------ fab -- */

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(var(--tabbar-h) + 18px + var(--safe-b));
  z-index: 35;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: var(--on-accent);
  font-size: 23px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-accent);
  transition: transform .34s var(--ease-out), box-shadow .3s var(--ease-out);
}
.fab:active {
  transform: scale(.9);
  box-shadow: var(--shadow);
  transition-duration: .07s;
}

@media (min-width: 672px) {
  .fab { right: calc(50vw - 320px + 18px); }
}

/* ------------------------------------------------------- small screens --- */

@media (max-width: 380px) {
  :root { --gutter: 14px; }
  .page-title { font-size: 31px; }
  .hero-card { padding-left: 68px; }
  .hero-emoji { width: 40px; height: 40px; left: 14px; }
  .hearts { font-size: 19px; gap: 2px; }
  .stat b { font-size: 21px; }
}

/* ------------------------------------------------------------ a11y ------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .spinner { animation: spin 1s linear infinite !important; }
  .hero-card:active, .btn:active, .chip:active,
  .wine-card:active, .fab:active, .tab:active,
  .icon-btn:active, .card.tappable:active { transform: none; }
}

@media (prefers-contrast: more) {
  :root {
    --separator: rgba(27, 20, 24, .28);
    --text2: #52484d;
    --text3: #6b6167;
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --separator: rgba(245, 239, 241, .32);
      --text2: #c4bac0;
      --text3: #a49aa0;
    }
  }
}

/* ---- shared vector-icon layer (appended; keep when regenerating skins) ---- */
.svgi{flex:none;vertical-align:-.18em}
.chip-ico{vertical-align:-2.5px;margin-right:1px}
.hero-emoji .svgi,.row-emoji .svgi,.tab-ico .svgi,.icon-btn .svgi,.fab .svgi,.empty .big .svgi,.wine-card .ph .svgi,.search-ico .svgi{display:block;vertical-align:baseline}
.row-emoji{display:flex;align-items:center;justify-content:center;color:var(--accent,#7a1e2e)}
.wine-card .ph .svgi{color:var(--text2,#8a7c82);opacity:.8}
.cc{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;min-width:34px;border-radius:50%;background:var(--accent-soft,rgba(122,30,46,.12));color:var(--accent,#7a1e2e);font-size:12px;font-weight:700;letter-spacing:.04em}
.hearts button{filter:none!important}
.hearts button .svgi{fill:none;stroke:var(--text2,#8a7c82);opacity:.55;transition:opacity .15s}
.hearts button.on .svgi{fill:var(--accent,#7a1e2e);stroke:var(--accent,#7a1e2e);opacity:1}
.login-logo .svgi{display:block;margin:0 auto}
