/* ---------- Tokens ---------- */
:root {
  --scale: 1;
  --bg: #F6F3EE;
  --bg-elev: #FFFFFF;
  --bg-sunken: #EDE8E1;
  --fill: rgba(120, 100, 80, .10);
  --fill-strong: rgba(120, 100, 80, .16);
  --text: #1B1714;
  --text-2: #6E655C;
  --text-3: #A39A90;
  --line: rgba(60, 40, 20, .10);
  --accent: #E8552F;
  --accent-2: #F28A3C;
  --accent-soft: rgba(232, 85, 47, .12);
  --ok: #2FA36B;
  --danger: #E0393E;
  --shadow: 0 1px 2px rgba(40, 25, 10, .06), 0 8px 24px rgba(40, 25, 10, .08);
  --shadow-lg: 0 20px 50px rgba(40, 25, 10, .18);
  --blur-bg: rgba(246, 243, 238, .78);
  --radius: 22px;
  --radius-sm: 14px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D0D0F; --bg-elev: #1A1A1D; --bg-sunken: #141416;
    --fill: rgba(255, 255, 255, .08); --fill-strong: rgba(255, 255, 255, .13);
    --text: #F4F1EC; --text-2: #A8A29B; --text-3: #6C6761;
    --line: rgba(255, 255, 255, .09);
    --accent: #FF6A3D; --accent-2: #FF9A4D; --accent-soft: rgba(255, 106, 61, .16);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --shadow-lg: 0 20px 50px rgba(0,0,0,.6);
    --blur-bg: rgba(13, 13, 15, .76);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D0D0F; --bg-elev: #1A1A1D; --bg-sunken: #141416;
  --fill: rgba(255, 255, 255, .08); --fill-strong: rgba(255, 255, 255, .13);
  --text: #F4F1EC; --text-2: #A8A29B; --text-3: #6C6761;
  --line: rgba(255, 255, 255, .09);
  --accent: #FF6A3D; --accent-2: #FF9A4D; --accent-soft: rgba(255, 106, 61, .16);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 20px 50px rgba(0,0,0,.6);
  --blur-bg: rgba(13, 13, 15, .76);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { font-size: calc(16px * var(--scale)); -webkit-text-size-adjust: 100%; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  line-height: 1.45; overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: var(--accent); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }

#app { position: relative; min-height: 100%; }
.view {
  padding: calc(var(--safe-top) + 12px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 32px);
  max-width: 820px; margin: 0 auto;
  animation: fade .25s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Header ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.greeting { font-size: .82rem; color: var(--text-2); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.large-title { font-size: 2.1rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; margin: 2px 0 14px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none; overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 16px; box-shadow: var(--shadow);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--fill); color: var(--text); flex: none; transition: transform .15s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn svg { width: 21px; height: 21px; }

/* ---------- Search ---------- */
.search {
  position: sticky; top: 0; z-index: 5;
  margin: 0 -16px; padding: calc(var(--safe-top) + 8px) 16px 10px;
  background: var(--blur-bg); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.search-inner { display: flex; gap: 10px; align-items: center; }
.search-field {
  flex: 1; display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px;
  background: var(--fill); border-radius: 14px; color: var(--text-2);
}
.search-field svg { width: 19px; height: 19px; flex: none; }
.search-field input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 1.02rem; color: var(--text); }
.search-field input::placeholder { color: var(--text-3); }
.search-field input::-webkit-search-cancel-button, .search-field input::-webkit-search-decoration { -webkit-appearance: none; display: none; }
.search-clear { width: 22px; height: 22px; border-radius: 50%; background: var(--text-3); color: var(--bg); display: grid; place-items: center; }
.search-clear svg { width: 13px; height: 13px; stroke-width: 3; }

/* ---------- Chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; margin: 0 -16px; padding: 4px 16px 6px; scrollbar-width: none; scroll-snap-type: x proximity; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border-radius: 999px; background: var(--bg-elev); color: var(--text); font-size: .9rem; font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--line); white-space: nowrap; scroll-snap-align: start; transition: all .15s;
}
.chip .count { color: var(--text-3); font-weight: 600; font-size: .8rem; }
.chip.active { background: var(--text); color: var(--bg); box-shadow: none; }
.chip.active .count { color: var(--bg); opacity: .6; }
.chip.small { height: 30px; font-size: .82rem; padding: 0 11px; }
.chips.seg .chip.active { background: var(--accent); color: #fff; }

/* ---------- Sections ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 22px 0 12px; }
.section-head h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.section-head .link { color: var(--accent); font-weight: 600; font-size: .92rem; }
.muted { color: var(--text-2); }

/* ---------- Hero / surprise ---------- */
.surprise {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; margin-top: 14px;
  padding: 16px; border-radius: var(--radius); color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, #FF9A4D 0%, #E8552F 45%, #B8322A 100%);
  box-shadow: 0 12px 30px rgba(232, 85, 47, .32);
}
.surprise b { display: block; font-size: 1.08rem; }
.surprise span { opacity: .88; font-size: .88rem; }

/* ---------- Cards ---------- */
.rail { scroll-padding: 0 16px; display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 10px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.rail::-webkit-scrollbar { display: none; }
.rail .card { width: 66%; max-width: 280px; flex: none; scroll-snap-align: start; }
.rail .card .thumb { aspect-ratio: 4 / 3; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
  position: relative; display: block; text-align: left; width: 100%;
  background: var(--bg-elev); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: transform .18s cubic-bezier(.2,.8,.2,1);
}
.card:active { transform: scale(.97); }
.thumb { position: relative; aspect-ratio: 1 / 1; background: var(--bg-sunken); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.ph {
  width: 100%; height: 100%; display: grid; place-items: center; font-size: 3rem;
  background: radial-gradient(120% 120% at 20% 10%, hsl(var(--h) 75% 86%), hsl(var(--h) 55% 66%));
}
:root[data-theme="dark"] .ph { background: radial-gradient(120% 120% at 20% 10%, hsl(var(--h) 45% 34%), hsl(var(--h) 45% 20%)); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .ph { background: radial-gradient(120% 120% at 20% 10%, hsl(var(--h) 45% 34%), hsl(var(--h) 45% 20%)); } }
.ph span { filter: drop-shadow(0 6px 12px rgba(0,0,0,.18)); }
.card-body { padding: 10px 12px 12px; }
.card-title {
  font-weight: 700; font-size: .95rem; line-height: 1.25; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em;
}
.card-meta { margin-top: 6px; font-size: .74rem; color: var(--text-2); display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; }
.badge-tl {
  position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700;
  background: rgba(0,0,0,.45); color: #fff; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.fav-dot {
  position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0,0,0,.35); color: #fff;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.fav-dot svg { width: 16px; height: 16px; }
.fav-dot.on { color: #FF4D5E; background: rgba(255,255,255,.92); }
.fav-dot.on svg { fill: currentColor; }

/* ---------- List rows (search results) ---------- */
.result-count { font-size: .88rem; color: var(--text-2); margin: 14px 2px 10px; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 60px 24px; color: var(--text-2); }
.empty .big { font-size: 56px; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin: 6px 0; font-size: 1.15rem; }

/* ---------- Category tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 640px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
.tile {
  position: relative; padding: 16px; border-radius: var(--radius); text-align: left; min-height: 112px;
  background: linear-gradient(150deg, hsl(var(--h) 90% 94%), hsl(var(--h) 80% 86%)); color: hsl(var(--h) 60% 22%);
  overflow: hidden; transition: transform .15s;
}
:root[data-theme="dark"] .tile { background: linear-gradient(150deg, hsl(var(--h) 35% 22%), hsl(var(--h) 35% 14%)); color: hsl(var(--h) 70% 88%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tile { background: linear-gradient(150deg, hsl(var(--h) 35% 22%), hsl(var(--h) 35% 14%)); color: hsl(var(--h) 70% 88%); } }
.tile:active { transform: scale(.97); }
.tile .emo { font-size: 2.3rem; position: absolute; right: 10px; bottom: 6px; opacity: .95; }
.tile b { display: block; font-size: 1.05rem; }
.tile span { font-size: .82rem; opacity: .75; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: flex-start;
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding: 6px 8px var(--safe-bottom);
  background: var(--blur-bg); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border-top: .5px solid var(--line);
  transition: transform .3s ease;
}
.tabbar.hide { transform: translateY(110%); }
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding-top: 4px; color: var(--text-3); font-size: 10.5px; font-weight: 600; }
.tab svg { width: 25px; height: 25px; }
.tab.active { color: var(--accent); }
.tab.active svg { fill: var(--accent-soft); }
.tab-add .plus {
  width: 50px; height: 50px; margin-top: -6px; border-radius: 17px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 8px 20px rgba(232, 85, 47, .4);
  transition: transform .15s;
}
.tab-add:active .plus { transform: scale(.9); }
.tab-add .plus svg { width: 26px; height: 26px; stroke-width: 2.4; }

/* ---------- Pages (pushed views) ---------- */
.page {
  position: fixed; inset: 0; z-index: 30; background: var(--bg); overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch; animation: slideIn .32s cubic-bezier(.2,.8,.2,1);
  box-shadow: -10px 0 30px rgba(0,0,0,.12);
}
.page.closing { animation: slideOut .26s ease forwards; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }
@keyframes slideOut { to { transform: translateX(100%); } }
.page.modal { animation: slideUp .34s cubic-bezier(.2,.8,.2,1); }
.page.modal.closing { animation: slideDown .26s ease forwards; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes slideDown { to { transform: translateY(100%); } }

.navbar {
  position: sticky; top: 0; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(var(--safe-top) + 6px) 12px 8px; background: var(--blur-bg);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--line);
}
.navbar h1 { font-size: 1.02rem; margin: 0; font-weight: 700; flex: 1; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-btn { height: 40px; padding: 0 8px; color: var(--accent); font-weight: 600; font-size: 1.02rem; }
.nav-btn.strong { font-weight: 800; }
.nav-btn:disabled { opacity: .4; }

/* ---------- Detail ---------- */
.detail-hero { position: relative; height: 52vh; max-height: 460px; min-height: 280px; background: var(--bg-sunken); }
.gallery { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery > * { flex: none; width: 100%; height: 100%; scroll-snap-align: center; }
.gallery img { width: 100%; height: 100%; object-fit: cover; }
.gallery .ph { font-size: 6rem; }
.hero-fade { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(0,0,0,.35) 0%, transparent 26%, transparent 70%, rgba(0,0,0,.25) 100%); }
.hero-bar { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; padding: calc(var(--safe-top) + 8px) 14px 0; }
.glass {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  background: rgba(20, 20, 20, .38); -webkit-backdrop-filter: blur(16px) saturate(160%); backdrop-filter: blur(16px) saturate(160%);
}
.glass svg { width: 21px; height: 21px; stroke-width: 2.1; }
.glass.on { color: #FF4D5E; background: rgba(255,255,255,.94); }
.glass.on svg { fill: currentColor; }
.hero-actions { display: flex; gap: 10px; }
.dots { position: absolute; bottom: 40px; left: 0; right: 0; display: flex; justify-content: center; gap: 6px; }
.dots i { width: 6px; height: 6px; border-radius: 3px; background: rgba(255,255,255,.55); transition: all .2s; }
.dots i.on { width: 18px; background: #fff; }

.sheet-body {
  position: relative; margin-top: -26px; background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 22px 18px calc(var(--safe-bottom) + 40px); max-width: 820px; margin-left: auto; margin-right: auto;
}
.detail-title { font-size: 1.75rem; line-height: 1.15; letter-spacing: -.025em; font-weight: 800; margin: 0 0 10px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--fill); color: var(--text-2); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: rgba(47, 163, 107, .14); color: var(--ok); }
.quick-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; margin: 6px 0 18px; }
.qa { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border-radius: 16px; background: var(--bg-elev); box-shadow: var(--shadow); font-size: .78rem; font-weight: 600; color: var(--text-2); }
.qa svg { width: 22px; height: 22px; color: var(--accent); }
.qa.on { background: var(--accent); color: #fff; }
.qa.on svg { color: #fff; }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--fill); border-radius: 12px; padding: 3px; margin-bottom: 16px; }
.segmented button { height: 34px; border-radius: 9px; font-weight: 600; font-size: .9rem; color: var(--text-2); transition: all .2s; }
.segmented button.active { background: var(--bg-elev); color: var(--text); box-shadow: 0 2px 8px rgba(0,0,0,.1); }

.ing-list { list-style: none; padding: 0; margin: 0; }
.ing-list li { display: flex; gap: 12px; align-items: flex-start; padding: 11px 2px; border-bottom: .5px solid var(--line); font-size: 1rem; cursor: pointer; }
.ing-list li .tick { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--text-3); margin-top: 1px; display: grid; place-items: center; transition: all .15s; }
.ing-list li .tick svg { width: 13px; height: 13px; stroke-width: 3.2; color: #fff; opacity: 0; }
.ing-list li.done { color: var(--text-3); text-decoration: line-through; }
.ing-list li.done .tick { background: var(--ok); border-color: var(--ok); }
.ing-list li.done .tick svg { opacity: 1; }
.ing-list li.sub { cursor: default; border: 0; padding: 16px 2px 4px; font-weight: 800; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }

.steps { counter-reset: step; }
.step { position: relative; padding: 0 0 18px 44px; font-size: 1.02rem; line-height: 1.6; }
.step::before {
  counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: .9rem;
}
.prose { font-size: 1.02rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.notes-box { margin-top: 18px; padding: 14px 16px; border-radius: 16px; background: var(--bg-elev); box-shadow: var(--shadow); }
.notes-box h4 { margin: 0 0 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }

.links { display: grid; gap: 8px; margin-top: 8px; }
.link-card { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--bg-elev); box-shadow: var(--shadow); text-decoration: none; color: var(--text); }
.link-card .ico { width: 38px; height: 38px; flex: none; border-radius: 11px; display: grid; place-items: center; font-size: 18px; background: var(--fill); }
.link-card .t { flex: 1; min-width: 0; }
.link-card b { display: block; font-size: .95rem; }
.link-card small { display: block; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-card > svg { width: 18px; height: 18px; color: var(--text-3); }
h3.block-title { font-size: 1.1rem; margin: 26px 0 8px; letter-spacing: -.01em; }

.cook-mode .prose, .cook-mode .step, .cook-mode .ing-list li { font-size: 1.25rem; }

/* ---------- Forms ---------- */
.form { padding: 12px 16px calc(var(--safe-bottom) + 60px); max-width: 820px; margin: 0 auto; }
.group-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 600; margin: 22px 4px 8px; }
.group { background: var(--bg-elev); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow); }
.group > * + * { border-top: .5px solid var(--line); }
.field { display: block; width: 100%; padding: 13px 14px; border: 0; outline: 0; background: transparent; font-size: 1rem; resize: none; }
textarea.field { min-height: 140px; line-height: 1.5; }
.field::placeholder { color: var(--text-3); }
.title-field { font-size: 1.3rem; font-weight: 700; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; min-height: 50px; }
.row .lbl { display: flex; align-items: center; gap: 12px; font-size: 1rem; }
.row .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-size: 15px; flex: none; }
.row .val { color: var(--text-2); font-size: .95rem; }
button.row-btn { width: 100%; text-align: left; }
.hint { font-size: .8rem; color: var(--text-3); margin: 6px 6px 0; }

.switch { position: relative; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; position: absolute; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--fill-strong); transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: .2s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { transform: translateX(20px); }

.photo-strip { display: flex; gap: 10px; overflow-x: auto; padding: 12px 14px; scrollbar-width: none; }
.photo-strip::-webkit-scrollbar { display: none; }
.photo-tile { position: relative; flex: none; width: 92px; height: 92px; border-radius: 14px; overflow: hidden; background: var(--bg-sunken); }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; }
.photo-tile .x { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.photo-tile .x svg { width: 13px; height: 13px; stroke-width: 3; }
.photo-tile .cover { position: absolute; left: 4px; bottom: 4px; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; background: var(--accent); color: #fff; }
.photo-add { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 14px 14px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border-radius: 14px;
  font-weight: 700; font-size: .95rem; background: var(--fill); color: var(--text); width: 100%;
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; }
.btn.danger { color: var(--danger); background: rgba(224, 57, 62, .1); }
.btn:active { opacity: .8; }
.chip-pick { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
.chip-pick .chip { box-shadow: inset 0 0 0 1px var(--line); background: transparent; }
.chip-pick .chip.active { background: var(--accent); color: #fff; box-shadow: none; }
.link-row { display: flex; gap: 8px; padding: 10px 14px; align-items: center; }
.link-row input { flex: 1; min-width: 0; border: 0; outline: 0; background: var(--fill); border-radius: 10px; padding: 10px; font-size: .95rem; }
.link-row .rm { color: var(--danger); width: 32px; height: 32px; display: grid; place-items: center; }
.inline-fields { display: grid; grid-template-columns: 1fr 1fr; }
.inline-fields > * + * { border-left: .5px solid var(--line); }

/* ---------- Settings ---------- */
.profile-card { display: flex; align-items: center; gap: 14px; padding: 16px; background: var(--bg-elev); border-radius: var(--radius); box-shadow: var(--shadow); }
.profile-card .avatar { width: 64px; height: 64px; font-size: 26px; }
.profile-card input { border: 0; outline: 0; background: transparent; font-size: 1.25rem; font-weight: 700; width: 100%; }
.profile-card small { color: var(--text-2); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.stat { background: var(--bg-elev); border-radius: 16px; padding: 12px; box-shadow: var(--shadow); text-align: center; }
.stat b { display: block; font-size: 1.4rem; letter-spacing: -.02em; }
.stat span { font-size: .75rem; color: var(--text-2); }
.size-preview { padding: 10px 14px 4px; color: var(--text-2); font-size: .95rem; }
.slider-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px 16px; }
.slider-row .a-small { font-size: 13px; font-weight: 700; }
.slider-row .a-big { font-size: 22px; font-weight: 700; }
input[type=range] { flex: 1; accent-color: var(--accent); }
.seg-row { padding: 10px 14px; }
.seg-row .segmented { margin: 0; }
.footer-note { text-align: center; color: var(--text-3); font-size: .8rem; margin: 26px 0 0; }

/* ---------- Action sheet ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.4); animation: fadeIn .2s ease; }
.backdrop.closing { animation: fadeOut .2s ease forwards; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.action-sheet { position: fixed; left: 8px; right: 8px; bottom: calc(var(--safe-bottom) + 8px); z-index: 51; animation: slideUp .3s cubic-bezier(.2,.8,.2,1); max-width: 560px; margin: 0 auto; }
.action-sheet.closing { animation: slideDown .22s ease forwards; }
.as-group { background: var(--blur-bg); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%); border-radius: 16px; overflow: hidden; }
:root .as-group { background: var(--bg-elev); }
.as-title { padding: 14px 16px; text-align: center; font-size: .82rem; color: var(--text-2); }
.as-btn { display: block; width: 100%; height: 56px; font-size: 1.08rem; color: var(--accent); border-top: .5px solid var(--line); }
.as-btn.danger { color: var(--danger); }
.as-btn.cancel { margin-top: 8px; border-radius: 16px; background: var(--bg-elev); font-weight: 700; border: 0; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.18rem; font-weight: 700; letter-spacing: -.02em; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; box-shadow: 0 4px 12px rgba(232, 85, 47, .35); }
.brand b { color: var(--accent); font-weight: 800; }
.avatar-empty { background: var(--fill-strong); color: var(--text-2); box-shadow: none; }
.avatar-empty svg { width: 55%; height: 55%; }
.center { text-align: center; }

/* ---------- Roulette ---------- */
.surprise .wheel-mini { width: 44px; height: 44px; flex: none; animation: idleSpin 9s linear infinite; }
.surprise .wheel-mini svg { width: 100%; height: 100%; }
.surprise > span:nth-child(2) { flex: 1; }
.surprise .go svg { width: 20px; height: 20px; opacity: .85; }
@keyframes idleSpin { to { transform: rotate(360deg); } }

.roulette { padding: 8px 16px calc(var(--safe-bottom) + 40px); max-width: 560px; margin: 0 auto; }
.roulette .chips { margin-bottom: 8px; }
.wheel-wrap { position: relative; width: min(84vw, 360px); aspect-ratio: 1; margin: 18px auto 6px; }
.wheel { width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 18px 50px rgba(150, 40, 20, .35); will-change: transform; }
.wheel-svg { width: 100%; height: 100%; }
.wheel-pointer {
  position: absolute; top: -10px; left: 50%; z-index: 2; transform: translateX(-50%);
  width: 0; height: 0; border-left: 15px solid transparent; border-right: 15px solid transparent;
  border-top: 30px solid var(--text); filter: drop-shadow(0 3px 4px rgba(0,0,0,.3));
}
.wheel-hub {
  position: absolute; inset: 0; margin: auto; width: 25%; height: 25%; border-radius: 50%; z-index: 2;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); color: #fff; font-weight: 800; font-size: .9rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.3), inset 0 0 0 4px rgba(255,255,255,.85); transition: transform .15s;
}
.wheel-hub:active { transform: scale(.92); }
.wheel-hub:disabled { opacity: .85; }
.ticker { min-height: 2.6em; margin-top: 10px; text-align: center; font-weight: 700; font-size: 1.05rem; color: var(--text-2);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.win-card { position: relative; background: var(--bg-elev); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 16px; text-align: center; animation: pop .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.win-label { font-weight: 700; color: var(--accent); margin-bottom: 10px; }
.win-thumb { aspect-ratio: 16 / 10; border-radius: 16px; overflow: hidden; background: var(--bg-sunken); }
.win-thumb img { width: 100%; height: 100%; object-fit: cover; }
.win-card h2 { font-size: 1.3rem; letter-spacing: -.02em; margin: 12px 0 14px; }
.win-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti i { position: absolute; top: -40px; left: var(--x); font-style: normal; font-size: 24px; animation: fall var(--d) ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(var(--r)); opacity: .2; } }

/* ---------- YouTube ---------- */
.yt {
  position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 18px; overflow: hidden; margin-bottom: 10px;
  background: #000 center / cover no-repeat; box-shadow: var(--shadow);
}
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.yt-play {
  position: absolute; inset: 0; margin: auto; width: 68px; height: 48px; border-radius: 14px; display: grid; place-items: center;
  background: rgba(255, 0, 0, .92); color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.yt-play svg { width: 26px; height: 26px; }

/* ---------- AI ---------- */
.ai-go { height: 54px; font-size: 1.02rem; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; animation: idleSpin .8s linear infinite; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  padding: 11px 18px; border-radius: 999px; background: var(--text); color: var(--bg); font-weight: 600; font-size: .9rem;
  box-shadow: var(--shadow-lg); transition: all .25s ease; max-width: 86vw; text-align: center;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }

/* ---------- Accounts ---------- */
.btn-login {
  height: 38px; padding: 0 18px; border-radius: 999px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 6px 16px rgba(232, 85, 47, .3);
}
.badge-bl {
  position: absolute; bottom: 8px; left: 8px; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: .8rem; background: rgba(0,0,0,.45); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.pill.warn { background: rgba(242, 138, 60, .16); color: var(--accent-2); }
.guest-card small { color: var(--text-2); }

#auth-root:empty { display: none; }
.auth {
  position: fixed; inset: 0; z-index: 70; overflow-y: auto; display: grid; place-items: center;
  padding: calc(var(--safe-top) + 20px) 16px calc(var(--safe-bottom) + 20px);
  background: radial-gradient(120% 80% at 50% 0%, var(--accent-soft), transparent 60%), var(--bg);
  animation: fade .25s ease;
}
.auth-card {
  position: relative; width: 100%; max-width: 400px; padding: 28px 22px 22px; text-align: center;
  background: var(--bg-elev); border-radius: 28px; box-shadow: var(--shadow-lg);
}
.auth-logo { width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 18px; box-shadow: 0 8px 20px rgba(232, 85, 47, .35); }
.auth-card h1 { margin: 0; font-size: 1.7rem; letter-spacing: -.03em; }
.auth-card h1 b { color: var(--accent); }
.auth-sub { margin: 4px 0 18px; color: var(--text-2); font-size: .92rem; }
.auth-title { margin: 0 0 12px; font-size: 1.05rem; }
.oauth {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: 48px; margin-bottom: 10px;
  border-radius: 14px; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); font-weight: 700; transition: transform .15s;
}
.oauth:active { transform: scale(.98); }
.oauth:disabled { opacity: .6; }
.oauth svg { width: 20px; height: 20px; stroke: none; }
.or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--text-3); font-size: .8rem; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#auth-form { display: grid; gap: 10px; }
#auth-form .field { background: var(--bg); border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); }
#auth-form .btn { height: 48px; }
.auth-msg { min-height: 1.3em; margin-top: 10px; font-size: .88rem; color: var(--text-2); }
.auth-msg.err { color: var(--danger); }
.auth-msg.ok { color: var(--ok); }
.auth-links { display: grid; gap: 2px; margin: 6px 0 14px; }
.auth-link { padding: 6px; color: var(--accent); font-weight: 600; font-size: .9rem; }
.auth-close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); }
.auth-close svg { width: 18px; height: 18px; }

/* ---------- Desktop ---------- */
@media (min-width: 900px) {
  :root { --tabbar-h: 0px; }
  #app { padding-left: 96px; }
  .tabbar {
    top: 0; right: auto; bottom: 0; width: 96px; height: 100vh; padding: 22px 8px; gap: 6px;
    flex-direction: column; justify-content: flex-start; align-items: center;
    border-top: 0; border-right: .5px solid var(--line);
  }
  .tabbar.hide { transform: none; }
  .tab { flex: none; width: 78px; padding: 10px 0 8px; border-radius: 16px; transition: background .15s; }
  .tab:hover { background: var(--fill); }
  .tab-add { order: -1; margin-bottom: 14px; }
  .tab-add:hover { background: none; }

  .view { max-width: 1240px; padding: 28px 44px 56px; }
  .view.narrow { max-width: 720px; }
  .large-title { font-size: 2.7rem; }
  .search { margin: 0 -44px; padding: 12px 44px 12px; }
  .search-field { height: 48px; }
  .chips, .rail { margin: 0 -44px; padding-left: 44px; padding-right: 44px; scroll-padding: 0 44px; }
  .chips { flex-wrap: wrap; overflow: visible; }
  .rail .card { width: 270px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
  .card, .tile { cursor: pointer; }
  .card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
  .tile:hover { transform: translateY(-2px); }
  .surprise { max-width: 560px; }
  .section-head h2 { font-size: 1.5rem; }

  /* Recipes open as a panel from the right, over a dimmed backdrop. */
  #pages-root:not(:empty)::before { content: ""; position: fixed; inset: 0; z-index: 29; background: rgba(0, 0, 0, .38); animation: fadeIn .2s ease; }
  .page, .page.modal {
    left: auto; width: min(800px, calc(100vw - 96px)); box-shadow: -24px 0 70px rgba(0, 0, 0, .28);
    animation: slideIn .32s cubic-bezier(.2, .8, .2, 1);
  }
  .page.closing, .page.modal.closing { animation: slideOut .26s ease forwards; }
  .detail-hero { height: 360px; max-height: none; }
  .sheet-body { padding-left: 28px; padding-right: 28px; }

  .action-sheet { left: 50%; right: auto; bottom: 50%; width: 420px; margin: 0; translate: -50% 50%; }
  .confetti { left: 96px; }
  #toast { bottom: 28px; left: calc(50% + 48px); }
  .auth-card { padding: 34px 32px 26px; }
}

/* ---------- Authors & sharing ---------- */
.card-author { margin-top: 3px; font-size: .72rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-mine { outline: 2px solid var(--accent-soft); }
.people { display: grid; gap: 8px; margin-top: 12px; }
.person { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--bg-elev); border-radius: 16px; box-shadow: var(--shadow); }
.person .avatar { width: 38px; height: 38px; font-size: 15px; box-shadow: none; }
.person b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-name-text { font-size: 1.25rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-edit { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 0; }
.name-edit .field { flex: 1; min-width: 0; }
.name-edit .btn { width: auto; height: 40px; padding: 0 18px; }

/* ---------- v1.5: steps, servings, cook mode, timer, delete ---------- */
.step { cursor: pointer; transition: opacity .15s; }
.step.done { opacity: .45; text-decoration: line-through; }
.step.done::before { content: "✓"; background: var(--ok); color: #fff; }

.serv-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 12px; padding: 10px 14px; border-radius: 16px; background: var(--bg-elev); box-shadow: var(--shadow); font-weight: 600; }
.serv-bar small { color: var(--text-3); font-weight: 500; }
.serv-bar .link { color: var(--accent); font-weight: 700; }
.stepper { display: inline-flex; align-items: center; gap: 4px; background: var(--fill); border-radius: 999px; padding: 3px; }
.stepper button { width: 32px; height: 32px; border-radius: 50%; background: var(--bg-elev); font-size: 1.2rem; font-weight: 700; line-height: 1; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.stepper b { min-width: 2ch; text-align: center; font-size: 1.05rem; }
.serv-bar .chip.small { height: 30px; }

.danger-zone { margin-top: 36px; text-align: center; }
.danger-link { color: var(--text-3); font-size: .78rem; padding: 8px 14px; text-decoration: underline; text-underline-offset: 3px; }

.dialog { position: fixed; left: 50%; top: 50%; translate: -50% -50%; z-index: 51; width: min(92vw, 380px); padding: 22px 20px 18px; border-radius: 22px; background: var(--bg-elev); box-shadow: var(--shadow-lg); animation: pop .3s cubic-bezier(.2,1.3,.4,1); }
.dialog h3 { margin: 0 0 6px; font-size: 1.15rem; }
.dialog p { margin: 0 0 14px; color: var(--text-2); font-size: .92rem; }
.captcha { display: flex; justify-content: center; gap: 10px; padding: 14px; margin-bottom: 4px; border-radius: 14px; user-select: none; -webkit-user-select: none;
  background: repeating-linear-gradient(135deg, var(--fill) 0 6px, transparent 6px 12px), var(--bg-sunken); }
.captcha i { font-style: normal; font-size: 1.7rem; font-weight: 800; letter-spacing: 0; color: var(--text); display: inline-block; text-shadow: 1px 1px 0 var(--accent-soft); }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.dialog-actions .btn:disabled { opacity: .4; }

.cook-bar { display: none; position: sticky; bottom: 0; z-index: 8; flex-direction: column; gap: 8px; padding: 10px 14px calc(var(--safe-bottom) + 12px);
  background: var(--blur-bg); -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px); border-top: .5px solid var(--line); }
.cook-mode .cook-bar { display: flex; }
.cook-timer { display: flex; align-items: center; justify-content: center; gap: 10px; }
.cook-time { font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; min-width: 4.4ch; text-align: center; }
.cook-time.run { color: var(--accent); }
.round { width: 44px; height: 44px; border-radius: 50%; background: var(--fill-strong); font-size: 1.1rem; font-weight: 800; }
.round.wide { width: auto; padding: 0 14px; border-radius: 999px; }
.round:disabled { opacity: .35; }
.cook-presets { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; justify-content: center; flex-wrap: wrap; }
.cook-done { height: 46px; }

.timer-pill { position: fixed; right: 14px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px); z-index: 45; padding: 10px 16px; border-radius: 999px; font-weight: 800; color: #fff;
  font-variant-numeric: tabular-nums; background: linear-gradient(135deg, var(--accent-2), var(--accent)); box-shadow: 0 8px 22px rgba(232,85,47,.45); }
#alarm-root:empty { display: none; }
.alarm { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(0,0,0,.6); animation: fadeIn .2s ease; }
.alarm-card { width: min(86vw, 340px); padding: 28px 22px 22px; border-radius: 26px; text-align: center; background: var(--bg-elev); box-shadow: var(--shadow-lg); }
.alarm-card h2 { margin: 6px 0 18px; font-size: 1.5rem; }
.alarm-bell { font-size: 3.4rem; animation: ring .5s ease-in-out infinite alternate; }
@keyframes ring { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }

.star { width: 36px; height: 36px; border-radius: 50%; font-size: 1.35rem; color: var(--text-3); background: var(--fill); }
.star.on { color: #F2A33C; background: rgba(242, 163, 60, .16); }
.person .btn { flex: none; }
@media (min-width: 900px) {
  .timer-pill { bottom: 24px; right: 24px; }
  .cook-bar { flex-direction: row; align-items: center; flex-wrap: wrap; justify-content: center; }
}

/* ---------- v1.6: ratings ---------- */
.rating-box { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 4px 0 16px; padding: 12px 14px; border-radius: 16px; background: var(--bg-elev); box-shadow: var(--shadow); }
.score { display: flex; align-items: center; gap: 10px; }
.score-badge { min-width: 46px; padding: 8px 6px; border-radius: 10px 10px 10px 2px; text-align: center; font-weight: 800; font-size: 1.15rem; color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.score-text { display: flex; flex-direction: column; line-height: 1.2; }
.score-text b { font-size: .98rem; }
.score-text small { color: var(--text-2); font-size: .8rem; }
.score.none small { color: var(--text-3); }
.rate-row { display: flex; align-items: center; gap: 10px; font-size: .82rem; color: var(--text-2); font-weight: 600; }
.stars-input { display: inline-flex; gap: 2px; }
.stars-input button { font-size: 1.7rem; line-height: 1; color: var(--text-3); padding: 2px 3px; transition: transform .12s, color .12s; }
.stars-input button.on { color: #F2A33C; }
.stars-input button:hover { transform: scale(1.18); }
.mini-score { display: inline-block; margin-right: 6px; padding: 1px 6px; border-radius: 6px 6px 6px 1px; font-weight: 800; font-size: .72rem; color: #fff; background: var(--accent); }
.pill-btn { cursor: pointer; }
.pill-btn:hover { background: var(--fill-strong); }
.person-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left; }
.person-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-head { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 0 14px; }
.user-head h2 { margin: 0; font-size: 1.4rem; letter-spacing: -.02em; }
.avatar.big { width: 84px; height: 84px; font-size: 34px; }

/* ---------- Home KPI ---------- */
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-top: 14px; }
.hero-text { min-width: 0; }
.hero-text .large-title { margin-bottom: 14px; }
.kpi {
  flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 84px; padding: 10px 16px 11px; margin-bottom: 14px;
  border-radius: 20px; text-align: center; color: #fff; cursor: pointer;
  background: radial-gradient(130% 150% at 0% 0%, var(--accent-2) 0%, var(--accent) 55%, #B8322A 100%);
  box-shadow: 0 10px 24px rgba(232, 85, 47, .32); transition: transform .15s;
}
.kpi:active { transform: scale(.96); }
.kpi b { font-size: 1.9rem; line-height: 1; font-weight: 800; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi span { margin-top: 3px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; opacity: .92; }
.kpi small { margin-top: 5px; padding: 2px 8px; border-radius: 999px; font-size: .7rem; font-weight: 700; background: rgba(255,255,255,.22); }
@media (min-width: 900px) { .kpi { min-width: 110px; padding: 14px 22px 15px; } .kpi b { font-size: 2.6rem; } .kpi span { font-size: .78rem; } .kpi small { font-size: .78rem; } }

/* ---------- v1.9: chat ---------- */
.tab-ico { position: relative; display: inline-flex; }
.tab-badge { position: absolute; top: -5px; right: -9px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; font-style: normal; font-size: 11px; font-weight: 800; line-height: 18px; text-align: center; color: #fff; background: #E0393E; box-shadow: 0 0 0 2px var(--bg); }
.chat-toast {
  position: fixed; top: calc(var(--safe-top) + 10px); left: 50%; z-index: 85; width: min(92vw, 420px); translate: -50% -140%; opacity: 0; pointer-events: none;
  display: flex; flex-direction: column; gap: 2px; padding: 11px 16px; border-radius: 16px; text-align: left; color: var(--text);
  background: var(--bg-elev); box-shadow: var(--shadow-lg); border: .5px solid var(--line); transition: translate .3s cubic-bezier(.2,.9,.3,1), opacity .25s;
}
.chat-toast.show { translate: -50% 0; opacity: 1; pointer-events: auto; }
.chat-toast span { color: var(--text-2); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-banner { display: flex; align-items: center; gap: 12px; width: 100%; margin: 4px 0 14px; padding: 12px 14px; text-align: left; border-radius: 16px; background: var(--accent-soft); color: var(--text); }
.notif-banner > span:first-child { font-size: 1.5rem; }
.notif-banner b { display: block; }
.notif-banner small { color: var(--text-2); }
.threads { display: grid; gap: 8px; }
.thread { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; border-radius: 18px; background: var(--bg-elev); box-shadow: var(--shadow); }
.thread.unread { box-shadow: inset 3px 0 0 var(--accent), var(--shadow); }
.thread .avatar { width: 46px; height: 46px; font-size: 18px; box-shadow: none; }
.thread-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.thread-last { color: var(--text-2); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread.unread .thread-last { color: var(--text); font-weight: 600; }
.thread-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
.thread-meta small { color: var(--text-3); }
.dot { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; font-style: normal; font-size: .75rem; font-weight: 800; line-height: 22px; text-align: center; color: #fff; background: var(--accent); }
.avatar.sm { width: 32px; height: 32px; font-size: 14px; box-shadow: none; }

.page.chat-page { display: flex; flex-direction: column; overflow: hidden; }
.chat-title { display: flex !important; align-items: center; justify-content: center; gap: 8px; }
.chat-title span:last-child { overflow: hidden; text-overflow: ellipsis; }
.chat-body { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 14px 16px; display: flex; flex-direction: column; gap: 4px; -webkit-overflow-scrolling: touch; }
.day { align-self: center; margin: 12px 0 6px; padding: 3px 12px; border-radius: 999px; font-size: .75rem; font-weight: 600; color: var(--text-2); background: var(--fill); text-transform: capitalize; }
.msg { display: flex; flex-direction: column; max-width: 82%; gap: 3px; margin-top: 4px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 9px 13px; border-radius: 18px; line-height: 1.4; overflow-wrap: anywhere; font-size: .98rem; }
.msg.mine .bubble { color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent)); border-bottom-right-radius: 5px; }
.msg.theirs .bubble { background: var(--bg-elev); box-shadow: var(--shadow); border-bottom-left-radius: 5px; }
.msg.mine .bubble a { color: #fff; }
.msg small { color: var(--text-3); font-size: .7rem; padding: 0 4px; }
.tagged { display: flex; align-items: center; gap: 10px; width: 260px; max-width: 100%; padding: 8px; border-radius: 16px; text-align: left; background: var(--bg-elev); box-shadow: var(--shadow); border: 1px solid var(--line); }
.tagged.missing { padding: 10px 12px; color: var(--text-3); font-size: .85rem; }
.tagged-thumb { flex: none; width: 52px; height: 52px; border-radius: 12px; overflow: hidden; background: var(--bg-sunken); }
.tagged-thumb img, .tagged-thumb .ph { width: 100%; height: 100%; object-fit: cover; font-size: 1.4rem; }
.tagged-text { min-width: 0; display: flex; flex-direction: column; }
.tagged-text b { font-size: .92rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tagged-text small { color: var(--text-2); }
.chat-compose { flex: none; padding: 8px 12px calc(var(--safe-bottom) + 10px); background: var(--blur-bg); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: .5px solid var(--line); }
.chat-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-row textarea { flex: 1; min-width: 0; max-height: 130px; padding: 11px 14px; border: 0; outline: 0; resize: none; border-radius: 20px; background: var(--fill); font-size: 1rem; line-height: 1.35; }
.chat-row .round { flex: none; }
.round.send { color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.draft-tag { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 4px 8px; padding: 8px 12px; border-radius: 14px; background: var(--accent-soft); font-size: .88rem; }
.draft-tag span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-tag button { width: 26px; height: 26px; border-radius: 50%; background: var(--fill-strong); }
.pick-list { display: grid; gap: 8px; margin-top: 12px; }
.pick-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px 12px 8px 8px; text-align: left; border-radius: 16px; background: var(--bg-elev); box-shadow: var(--shadow); }
.pick-row > span:last-child { min-width: 0; display: flex; flex-direction: column; }
.pick-row b { line-height: 1.25; }
.pick-row small { color: var(--text-2); }
.person-pick { width: 100%; text-align: left; }
.person-pick .chev { margin-left: auto; color: var(--text-3); font-size: 1.4rem; }
@media (min-width: 900px) { .chat-toast { left: calc(50% + 48px); } .msg { max-width: 68%; } .page.chat-page { height: 100vh; } }

/* ---------- v1.10: admin panel ---------- */
.adm-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; }
.adm-kpi { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 12px 6px; border-radius: 16px; text-align: center; background: var(--bg-elev); box-shadow: var(--shadow); }
.adm-kpi b { font-size: 1.7rem; line-height: 1.05; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.adm-kpis:not(.small) .adm-kpi:first-child { color: #fff; background: radial-gradient(130% 150% at 0% 0%, var(--accent-2) 0%, var(--accent) 60%, #B8322A 100%); }
.adm-kpi span { margin-top: 3px; font-size: .72rem; font-weight: 600; color: var(--text-2); line-height: 1.2; }
.adm-kpis:not(.small) .adm-kpi:first-child span { color: rgba(255,255,255,.9); }
.adm-kpis.small .adm-kpi b { font-size: 1.3rem; }
.adm-chart { display: flex; align-items: flex-end; gap: 3px; height: 84px; }
.adm-bar { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.adm-bar i { display: block; width: 100%; border-radius: 4px 4px 1px 1px; background: var(--fill-strong); }
.adm-bar i.on { background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
.adm-axis { display: flex; justify-content: space-between; margin-top: 6px; font-size: .72rem; color: var(--text-3); }
.adm-totals { margin: 12px 4px 0; font-size: .85rem; color: var(--text-2); }
.adm-providers { display: flex; flex-wrap: wrap; gap: 8px; }
.adm-users { display: grid; gap: 8px; margin-top: 12px; }
.adm-user { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 16px; background: var(--bg-elev); box-shadow: var(--shadow); }
.adm-user .avatar { width: 42px; height: 42px; font-size: 17px; box-shadow: none; flex: none; }
.adm-user-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.adm-user-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-user-main small { color: var(--text-2); font-size: .76rem; }
.adm-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text) !important; opacity: .75; }
.adm-nums { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: .8rem; font-weight: 700; color: var(--text-2); }
@media (max-width: 380px) { .adm-kpis { grid-template-columns: repeat(2, 1fr); } }
.adm-chart-title { margin: 0 0 8px; font-size: .8rem; font-weight: 700; color: var(--text-2); }
.adm-bar.stack { flex-direction: column-reverse; justify-content: flex-start; gap: 1px; }
.adm-bar.stack i { border-radius: 2px; }
.adm-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: .76rem; color: var(--text-2); }
.adm-legend span { display: inline-flex; align-items: center; gap: 5px; }
.adm-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.adm-badge { display: inline-block; margin-left: 4px; padding: 1px 7px; border-radius: 999px; font-size: .68rem; font-weight: 700; vertical-align: 1px; }
.adm-badge.admin { color: #6C5CE7; background: rgba(108, 92, 231, .14); }
.adm-badge.blocked { color: var(--danger); background: rgba(224, 57, 62, .12); }
.adm-user.is-blocked { opacity: .65; }
.adm-act { margin-top: 4px; padding: 4px 10px; border-radius: 999px; font-size: .72rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); }
.adm-act.danger { color: var(--danger); background: rgba(224, 57, 62, .1); }

/* ---------- v1.12: invites, chat friend banner ---------- */
.topbar-btns { display: flex; gap: 8px; }
.btn-login.ghost { color: var(--accent); background: var(--accent-soft); box-shadow: none; }
.chat-banner { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 14px; background: var(--accent-soft); font-size: .86rem; }
.chat-banner span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-banner button { flex: none; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: .8rem; color: #fff; background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.auth-invite { margin: 0 0 14px; padding: 10px 12px; border-radius: 14px; font-weight: 600; font-size: .92rem; color: var(--accent); background: var(--accent-soft); }
.invite-preview { margin-top: 12px; padding: 12px 14px; border-radius: 16px; background: var(--bg-elev); box-shadow: var(--shadow); font-size: .9rem; line-height: 1.5; overflow-wrap: anywhere; }
.invite-preview small { display: block; margin-bottom: 4px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-size: .7rem; font-weight: 700; }
.invite-actions { display: grid; gap: 10px; margin-top: 14px; }
.person .person-main + .star { margin-left: auto; }
.soc-seg { margin: 6px 0 14px; }
.soc-seg button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap; }
.soc-seg .dot { min-width: 18px; height: 18px; line-height: 18px; font-size: .7rem; padding: 0 5px; }
.soc-seg .count { color: var(--text-3); font-size: .78rem; }
