/* خُلکده — اتاق ۴۲۵ */

@font-face { font-family: 'Gramophone'; src: url('/fonts/gramophone-fanum.woff2') format('woff2-variations'), url('/fonts/gramophone-fanum.woff2') format('woff2'); font-weight: 100 1000; font-display: swap; }

/* ---------- themes: each has a day and a night palette ---------- */
[data-theme="firoozeh"], :root { --paper: #e6efea; --sheet: #fbfdfb; --ink: #13243a; --muted: #5d6b74; --line: #c9d6cf; --primary: #0f9b8e; --on-primary: #ffffff; --accent: #f2b233; --hot: #d2344b; --good: #138a4f; --misreg: #f2b233; --shadow: #13243a; --grain-blend: multiply; --grain-op: .07; color-scheme: light; }
[data-theme="riso"] { --paper: #f3f1ee; --sheet: #ffffff; --ink: #1b1b3a; --muted: #6a6878; --line: #dcd8e2; --primary: #ff48b0; --on-primary: #ffffff; --accent: #0078bf; --hot: #e8473f; --good: #00a95c; --misreg: #0078bf; --shadow: #1b1b3a; --grain-blend: multiply; --grain-op: .07; color-scheme: light; }
[data-theme="anar"] { --paper: #f7e6e4; --sheet: #fffafa; --ink: #3b0d1a; --muted: #7d5a62; --line: #ecc9cd; --primary: #b51f3a; --on-primary: #fff3f0; --accent: #e98a2e; --hot: #b51f3a; --good: #3d7d3a; --misreg: #e98a2e; --shadow: #3b0d1a; --grain-blend: multiply; --grain-op: .07; color-scheme: light; }
[data-theme="zaferan"] { --paper: #fbefc9; --sheet: #fffbee; --ink: #2a1a06; --muted: #7a6235; --line: #ecd9a0; --primary: #e8740c; --on-primary: #fffbee; --accent: #6b3fa0; --hot: #c22d2d; --good: #3f7d1f; --misreg: #6b3fa0; --shadow: #2a1a06; --grain-blend: multiply; --grain-op: .07; color-scheme: light; }
@media (prefers-color-scheme: dark) {
  [data-theme="firoozeh"]:not([data-mode="light"]), :root:not([data-theme]):not([data-mode="light"]) { --paper: #0d1a1e; --sheet: #142429; --ink: #e4f1ec; --muted: #8ea8a3; --line: #23393f; --primary: #2cc3b2; --on-primary: #06201c; --accent: #f2b233; --hot: #ff6b7a; --good: #4fd18b; --misreg: #0f9b8e; --shadow: #000000; --grain-blend: screen; --grain-op: .05; color-scheme: dark; }
  [data-theme="riso"]:not([data-mode="light"]) { --paper: #14132a; --sheet: #1e1c3c; --ink: #f3f1ee; --muted: #a3a0c0; --line: #312e5c; --primary: #ff5cbb; --on-primary: #1b0a16; --accent: #3fa9f5; --hot: #ff6b5e; --good: #2fd47d; --misreg: #3fa9f5; --shadow: #05040f; --grain-blend: screen; --grain-op: .05; color-scheme: dark; }
  [data-theme="anar"]:not([data-mode="light"]) { --paper: #1b0a10; --sheet: #2a1119; --ink: #f7e6e4; --muted: #b98d96; --line: #45202c; --primary: #ff4d6a; --on-primary: #22060d; --accent: #f2a65a; --hot: #ff6b6b; --good: #7cc576; --misreg: #f2a65a; --shadow: #080204; --grain-blend: screen; --grain-op: .05; color-scheme: dark; }
  [data-theme="zaferan"]:not([data-mode="light"]) { --paper: #191206; --sheet: #261c0c; --ink: #fbefc9; --muted: #b49c6c; --line: #3e3017; --primary: #ff9a2e; --on-primary: #1a1006; --accent: #b48cf0; --hot: #ff6b5e; --good: #8fd16a; --misreg: #b48cf0; --shadow: #060400; --grain-blend: screen; --grain-op: .05; color-scheme: dark; }
}
[data-theme="firoozeh"][data-mode="dark"] { --paper: #0d1a1e; --sheet: #142429; --ink: #e4f1ec; --muted: #8ea8a3; --line: #23393f; --primary: #2cc3b2; --on-primary: #06201c; --accent: #f2b233; --hot: #ff6b7a; --good: #4fd18b; --misreg: #0f9b8e; --shadow: #000000; --grain-blend: screen; --grain-op: .05; color-scheme: dark; }
[data-theme="riso"][data-mode="dark"] { --paper: #14132a; --sheet: #1e1c3c; --ink: #f3f1ee; --muted: #a3a0c0; --line: #312e5c; --primary: #ff5cbb; --on-primary: #1b0a16; --accent: #3fa9f5; --hot: #ff6b5e; --good: #2fd47d; --misreg: #3fa9f5; --shadow: #05040f; --grain-blend: screen; --grain-op: .05; color-scheme: dark; }
[data-theme="anar"][data-mode="dark"] { --paper: #1b0a10; --sheet: #2a1119; --ink: #f7e6e4; --muted: #b98d96; --line: #45202c; --primary: #ff4d6a; --on-primary: #22060d; --accent: #f2a65a; --hot: #ff6b6b; --good: #7cc576; --misreg: #f2a65a; --shadow: #080204; --grain-blend: screen; --grain-op: .05; color-scheme: dark; }
[data-theme="zaferan"][data-mode="dark"] { --paper: #191206; --sheet: #261c0c; --ink: #fbefc9; --muted: #b49c6c; --line: #3e3017; --primary: #ff9a2e; --on-primary: #1a1006; --accent: #b48cf0; --hot: #ff6b5e; --good: #8fd16a; --misreg: #b48cf0; --shadow: #060400; --grain-blend: screen; --grain-op: .05; color-scheme: dark; }

/* ---------- base ---------- */
:root { --display: 'Gramophone', system-ui, sans-serif; --display-w: 1000; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--paper); }
body {
  margin: 0; min-height: 100dvh; color: var(--ink); background: var(--paper);
  font-family: 'Gramophone', system-ui, sans-serif; font-size: 16px; line-height: 1.65;
  direction: rtl; -webkit-font-smoothing: antialiased;
}
body::before { /* grain */
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: var(--grain-op); mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
a { color: inherit; }
.num { }
.display { font-family: var(--display); font-weight: var(--display-w); letter-spacing: 0; }

#app { position: relative; max-width: 520px; margin: 0 auto; padding: 0 16px calc(120px + env(safe-area-inset-bottom)); }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 10px; }
.wordmark { font-family: var(--display); font-weight: var(--display-w); font-size: 34px; line-height: 1; color: var(--ink); text-shadow: 2px 2px 0 var(--misreg); text-decoration: none; }
.wordmark small { font-family: 'Gramophone', sans-serif; font-size: 12px; font-weight: 700; text-shadow: none; border: 1.5px dashed currentColor; border-radius: 6px; padding: 2px 6px; margin-inline-start: 8px; vertical-align: 6px; color: var(--primary); display: inline-block; transform: rotate(-4deg); }
.page-title { font-family: var(--display); font-weight: var(--display-w); font-size: 30px; line-height: 1.1; margin: 0; }

/* ---------- avatars ---------- */
.av { --c: var(--primary); width: 38px; height: 38px; border-radius: 50%; background: var(--c); display: inline-grid; place-items: center; font-size: 19px; flex: none; border: 2px solid var(--ink); position: relative; }
.av.sm { width: 28px; height: 28px; font-size: 14px; border-width: 1.5px; }
.av.lg { width: 64px; height: 64px; font-size: 32px; border-width: 2.5px; }
.av.guest { border-style: dashed; }
.av-btn { background: none; border: 0; padding: 0; }

/* ---------- sections ---------- */
.sec { margin-top: 26px; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.sec-h h2 { font-family: var(--display); font-weight: var(--display-w); font-size: 22px; margin: 0; }
.sec-h a, .link { font-size: 14px; font-weight: 700; color: var(--primary); text-decoration: none; background: none; border: 0; padding: 0; }
.sheet-box { background: var(--sheet); border: 1.5px solid var(--line); border-radius: 22px; overflow: hidden; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.empty { padding: 26px 18px; text-align: center; color: var(--muted); font-size: 14px; }
.empty b { display: block; color: var(--ink); font-size: 16px; margin-bottom: 4px; }

/* ---------- hero (balance) ---------- */
.hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 22px 20px 20px; margin-top: 6px;
  background: var(--primary); color: var(--on-primary); border: 2.5px solid var(--ink); box-shadow: 6px 6px 0 var(--shadow);
}
.hero .girih { position: absolute; inset: 0; opacity: .16; pointer-events: none; }
.hero .label { font-size: 14px; font-weight: 700; opacity: .9; position: relative; }
.hero .big { position: relative; font-family: var(--display); font-weight: var(--display-w); font-size: 48px; line-height: 1.15; margin: 4px 0 2px; }
.hero .big small { font-family: 'Gramophone', sans-serif; font-size: 15px; font-weight: 700; margin-inline-start: 6px; }
.hero .sub { position: relative; font-size: 14px; opacity: .92; }
.hero .stamp { position: absolute; left: -26px; bottom: -30px; width: 130px; height: 130px; opacity: .9; }
.hero-actions { position: relative; display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- quote ---------- */
.quote { position: relative; padding: 20px 20px 16px; background: var(--sheet); border-radius: 22px; border: 1.5px solid var(--line); }
.quote .q-star { position: absolute; top: -14px; right: 16px; width: 30px; height: 30px; }
.quote .q-star svg { width: 100%; height: 100%; display: block; }
.quote p { margin: 0; font-size: 18px; line-height: 1.9; font-weight: 500; text-wrap: balance; }
.quote footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 13px; color: var(--muted); }

/* ---------- rows (receipt-ish lists) ---------- */
.row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; width: 100%; background: none; border: 0; text-align: right; border-top: 1.5px dashed var(--line); }
.row:first-child { border-top: 0; }
button.row:active { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.row .tile { width: 42px; height: 42px; flex: none; border-radius: 12px; display: grid; place-items: center; font-size: 22px; background: color-mix(in srgb, var(--primary) 14%, var(--sheet)); border: 1.5px solid color-mix(in srgb, var(--primary) 35%, transparent); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: left; flex: none; }
.row .amt { font-weight: 700; }
.row .mine { font-size: 12px; font-weight: 700; color: var(--hot); }
.row .mine.plus { color: var(--good); }
.date-h { padding: 8px 16px 4px; font-size: 13px; font-weight: 700; color: var(--muted); background: color-mix(in srgb, var(--paper) 55%, var(--sheet)); border-top: 1.5px solid var(--line); }
.date-h:first-child { border-top: 0; }

/* ---------- debts ---------- */
.debt { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1.5px dashed var(--line); }
.debt:first-child { border-top: 0; }
.debt .flow { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 14px; }
.debt .flow .arrow { color: var(--muted); font-size: 12.5px; }
.debt .flow b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.debt.me { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.debt .amt { font-weight: 800; white-space: nowrap; }
.debt-actions { display: flex; gap: 6px; padding: 0 16px 14px; background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* bars */
.bars { padding: 10px 16px 14px; }
.bar { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: center; padding: 6px 0; }
.bar .who { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; }
.bar .track { position: relative; height: 26px; }
.bar .fill { position: absolute; right: 0; top: 4px; height: 18px; min-width: 6px; border-radius: 5px; border: 1.5px solid var(--ink); }
.bar .fill.pos { background: var(--good); }
.bar .fill.neg { background: var(--hot); }
.bar .v { position: absolute; top: 2px; font-size: 12px; font-weight: 700; white-space: nowrap; }

/* ---------- buttons & chips ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 8px 18px;
  border-radius: 14px; border: 2px solid var(--ink); background: var(--sheet); color: var(--ink); font-weight: 700; font-size: 15px;
  box-shadow: 3px 3px 0 var(--shadow); transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow); }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.accent { background: var(--accent); color: var(--ink); }
.btn.ghost { box-shadow: none; border-color: var(--line); background: transparent; }
.btn.danger { color: var(--hot); border-color: var(--hot); box-shadow: none; background: transparent; }
.btn.block { width: 100%; min-height: 52px; font-size: 16px; }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 13px; border-radius: 11px; box-shadow: 2px 2px 0 var(--shadow); }
.btn.on-hero { background: var(--sheet); color: var(--ink); }
.btn:disabled { opacity: .5; pointer-events: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 12px 4px 14px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--sheet); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.chip .av { width: 26px; height: 26px; font-size: 13px; border-width: 1.5px; margin-inline-start: -8px; }
.chip[aria-pressed="true"] { border: 2px solid var(--ink); background: color-mix(in srgb, var(--primary) 18%, var(--sheet)); }
.chip[aria-pressed="true"]::after { content: '✓'; font-weight: 900; color: var(--primary); }
.chip.dashed { border-style: dashed; color: var(--muted); }
.seg { display: flex; background: var(--sheet); border: 1.5px solid var(--line); border-radius: 14px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 6px; border-radius: 11px; font-size: 14px; font-weight: 700; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ---------- forms ---------- */
.field { display: block; margin-top: 16px; }
.field > span { display: block; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.input { width: 100%; min-height: 50px; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--sheet); font-size: 16px; outline: none; }
.input:focus { border-color: var(--ink); }
.input.ltr { direction: ltr; text-align: center; letter-spacing: 1px; }
.amount-wrap { position: relative; }
.amount { font-family: var(--display); font-weight: var(--display-w); font-size: 40px; min-height: 76px; text-align: center; padding-bottom: 6px; }
.amount-unit { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-size: 14px; font-weight: 700; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; min-height: 20px; }
.err { color: var(--hot); font-size: 14px; font-weight: 700; margin-top: 10px; min-height: 22px; }
.split-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--accent) 20%, var(--sheet)); border: 1.5px dashed var(--ink); font-size: 14px; }
.split-note b { font-size: 18px; }
.guest-rule { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; flex-wrap: wrap; }
.guest-rule select { min-height: 34px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--sheet); padding: 0 8px; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; z-index: 20; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(488px, calc(100% - 24px)); height: 68px; display: grid; grid-template-columns: 1fr 1fr 84px 1fr 1fr; align-items: center;
  background: var(--sheet); border: 2px solid var(--ink); border-radius: 24px; box-shadow: 4px 4px 0 var(--shadow);
}
.nav a { display: flex; flex-direction: column; align-items: center; gap: 1px; text-decoration: none; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 6px 0; }
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--ink); }
.nav a[aria-current="page"] svg { color: var(--primary); }
.nav .badge { position: absolute; transform: translate(-14px, -4px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--hot); color: #fff; font-size: 11px; display: grid; place-items: center; padding: 0 4px; }
.fab { justify-self: center; width: 76px; height: 76px; margin-top: -34px; border: 0; background: none; padding: 0; position: relative; }
.fab svg { width: 100%; height: 100%; transition: transform .35s cubic-bezier(.3,1.6,.5,1); filter: drop-shadow(3px 3px 0 var(--shadow)); }
.fab .plus { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; font-weight: 900; color: var(--on-primary); pointer-events: none; line-height: 1; padding-top: 2px; }
.fab[aria-expanded="true"] svg { transform: rotate(45deg); }

/* ---------- sheets ---------- */
.scrim { position: fixed; inset: 0; z-index: 40; background: color-mix(in srgb, var(--shadow) 45%, transparent); opacity: 0; transition: opacity .2s; }
.scrim.open { opacity: 1; }
.sheet {
  position: fixed; z-index: 41; left: 50%; bottom: 0; width: min(520px, 100%); max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  transform: translate(-50%, 100%); transition: transform .28s cubic-bezier(.2,.9,.3,1);
  background: var(--paper); border: 2px solid var(--ink); border-bottom: 0; border-radius: 28px 28px 0 0; padding: 8px 18px calc(24px + env(safe-area-inset-bottom));
}
.sheet.open { transform: translate(-50%, 0); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h3 { font-family: var(--display); font-weight: var(--display-w); font-size: 26px; margin: 0 0 4px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 22px; }
.sheet .actions .btn { flex: 1; }
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.menu-grid button { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 16px; border-radius: 18px; border: 2px solid var(--ink); background: var(--sheet); box-shadow: 3px 3px 0 var(--shadow); text-align: right; }
.menu-grid button .e { font-size: 28px; line-height: 1; }
.menu-grid button b { font-size: 16px; }
.menu-grid button span { font-size: 12.5px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { .sheet, .scrim, .fab svg { transition: none; } }

/* detail */
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1.5px dashed var(--line); font-size: 15px; gap: 12px; }
.kv:last-child { border-bottom: 0; }
.receipt { background: var(--sheet); border-radius: 18px; padding: 6px 16px; border: 1.5px solid var(--line); margin-top: 14px; }
.receipt-total { text-align: center; padding: 14px 0 6px; }
.receipt-total .display { font-size: 40px; line-height: 1.2; }

/* ---------- shopping ---------- */
.shop-add { display: flex; gap: 8px; }
.shop-add .input { flex: 1; }
.urgent-toggle { width: 50px; flex: none; border-radius: 14px; border: 2px solid var(--line); background: var(--sheet); font-size: 20px; }
.urgent-toggle[aria-pressed="true"] { border-color: var(--hot); background: color-mix(in srgb, var(--hot) 15%, var(--sheet)); }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1.5px dashed var(--line); }
.item:first-child { border-top: 0; }
.check { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--ink); background: var(--sheet); flex: none; display: grid; place-items: center; font-weight: 900; color: var(--on-primary); }
.item.done .check { background: var(--primary); }
.item.done .t { text-decoration: line-through; color: var(--muted); }
.item .t { font-weight: 700; }
.item .s { font-size: 12px; color: var(--muted); }
.item .x { background: none; border: 0; color: var(--muted); font-size: 18px; width: 34px; height: 34px; }
.fire { color: var(--hot); }
.bought-banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 20px; border: 2px solid var(--ink); background: var(--accent); color: var(--ink); margin-top: 14px; box-shadow: 4px 4px 0 var(--shadow); }
.bought-banner p { margin: 0; flex: 1; font-size: 14px; font-weight: 600; }

/* ---------- me ---------- */
.profile { display: flex; align-items: center; gap: 14px; padding: 18px; }
.profile .name { font-family: var(--display); font-weight: var(--display-w); font-size: 26px; line-height: 1.2; }
.themes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 14px; }
.theme-card { border-radius: 16px; border: 2px solid var(--line); padding: 0; overflow: hidden; background: none; text-align: center; font-size: 13px; font-weight: 700; }
.theme-card[aria-pressed="true"] { border-color: var(--ink); box-shadow: 3px 3px 0 var(--shadow); }
.theme-card .sw { display: flex; height: 52px; }
.theme-card .sw .half { flex: 1; display: flex; }
.theme-card .sw .half + .half { border-right: 2px solid var(--line); }
.theme-card .sw i { flex: 1; }
.theme-card .nm { display: block; padding: 6px 0; background: var(--sheet); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; padding: 4px 0; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--line); }
.swatch[aria-pressed="true"] { border: 3px solid var(--ink); transform: scale(1.1); }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-pick button { width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--sheet); font-size: 22px; }
.emoji-pick button[aria-pressed="true"] { border: 2px solid var(--ink); background: color-mix(in srgb, var(--primary) 18%, var(--sheet)); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-top: 1.5px dashed var(--line); gap: 10px; }
.toggle-row:first-child { border-top: 0; }
.switch { width: 52px; height: 30px; border-radius: 15px; border: 2px solid var(--ink); background: var(--line); position: relative; flex: none; padding: 0; }
.switch::after { content: ''; position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; background: var(--sheet); border: 1.5px solid var(--ink); transition: right .15s; }
.switch[aria-checked="true"] { background: var(--primary); }
.switch[aria-checked="true"]::after { right: 24px; }
.card-num { direction: ltr; letter-spacing: 1.5px; font-weight: 700; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 30px 4px 40px; }
.login-art { width: 150px; height: 150px; margin: 0 auto 6px; display: block; }
.login h1 { font-family: var(--display); font-weight: var(--display-w); font-size: 72px; line-height: 1.1; text-align: center; margin: 0; text-shadow: 4px 4px 0 var(--misreg); }
.login .tag { text-align: center; color: var(--muted); margin: 6px 0 28px; }
.login form { background: var(--sheet); border: 2px solid var(--ink); border-radius: 26px; padding: 6px 20px 22px; box-shadow: 6px 6px 0 var(--shadow); }
.login .hello { font-weight: 700; font-size: 17px; margin-top: 16px; }

/* ---------- toast ---------- */
.toast { position: fixed; z-index: 60; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translate(-50%, -150%); background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 14px; font-weight: 700; font-size: 14px; transition: transform .25s; max-width: calc(100% - 32px); text-align: center; }
.toast.show { transform: translate(-50%, 0); }
.toast.bad { background: var(--hot); color: #fff; }

.loading { min-height: 70dvh; display: grid; place-items: center; }
.loading svg { width: 64px; height: 64px; animation: spin 1.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading svg { animation: none; } }

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.stat { padding: 14px 16px; }
.stat + .stat { border-right: 1.5px dashed var(--line); }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .v { font-family: var(--display); font-weight: var(--display-w); font-size: 24px; line-height: 1.3; }
.stat .v small { font-family: 'Gramophone', sans-serif; font-size: 12px; color: var(--muted); }
.admin-row { padding: 12px 16px; border-top: 1.5px dashed var(--line); }
.admin-row:first-child { border-top: 0; }
.admin-row .top-line { display: flex; align-items: center; gap: 10px; }
.admin-row .btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pill { font-size: 11px; font-weight: 800; padding: 1px 8px; border-radius: 999px; border: 1.5px solid currentColor; color: var(--primary); }
.pill.off { color: var(--muted); }
.install-tip { margin-top: 14px; padding: 14px 16px; border-radius: 18px; border: 1.5px dashed var(--ink); font-size: 14px; display: flex; gap: 10px; align-items: center; }
.install-tip p { margin: 0; flex: 1; }

/* =========================================================
   حرکت — توکن‌ها و الگوها (الهام از transitions.dev و حال‌وهوای codeandchill)
   ========================================================= */
:root {
  --dur-quick: 160ms; --dur: 280ms; --dur-slow: 520ms;
  --ease-out: cubic-bezier(.2, .9, .3, 1);
  --ease-in: cubic-bezier(.5, 0, .75, 0);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-bounce: linear(0, .9 25%, 1.08 42%, .97 60%, 1.02 78%, 1);
}

/* صفحه‌به‌صفحه: صفحهٔ تازه از سمتِ دکمه‌ای که زدی می‌آید */
#view { view-transition-name: page; }
.nav { view-transition-name: nav; }
::view-transition-old(page) { animation: vt-out var(--dur) var(--ease-out) both; }
::view-transition-new(page) { animation: vt-in 340ms var(--ease-out) both; }
[data-dir="back"]::view-transition-old(page) { animation-name: vt-out-back; }
[data-dir="back"]::view-transition-new(page) { animation-name: vt-in-back; }
@keyframes vt-out { to { opacity: 0; transform: translateX(28px) scale(.985); filter: blur(4px); } }
@keyframes vt-in { from { opacity: 0; transform: translateX(-36px); filter: blur(4px); } }
@keyframes vt-out-back { to { opacity: 0; transform: translateX(-28px) scale(.985); filter: blur(4px); } }
@keyframes vt-in-back { from { opacity: 0; transform: translateX(36px); filter: blur(4px); } }

/* ردیف‌ها یکی‌یکی بالا می‌آیند */
.rise { animation: rise 420ms var(--ease-out) both; animation-delay: calc(var(--i) * 32ms); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); filter: blur(3px); } }

/* عدد قهرمان */
.hero-num { display: inline-block; will-change: filter; }

/* سهم هر نفر: پرش عدد */
.split-note b.ticking { animation: tick 360ms var(--ease-spring); }
@keyframes tick { 0% { transform: translateY(40%); opacity: 0; filter: blur(4px); } 100% { transform: none; opacity: 1; filter: none; } }

/* قرص لغزان */
.seg { position: relative; }
.seg button { position: relative; z-index: 1; transition: color var(--dur) var(--ease-out); }
.seg button[aria-pressed="true"] { background: transparent; }
.seg-pill { position: absolute; top: 3px; bottom: 3px; left: 0; border-radius: 11px; background: var(--ink); z-index: 0;
  transition: transform 380ms var(--ease-spring), width 380ms var(--ease-spring); }

/* نشان لیست خرید */
.nav .badge.pop { animation: badge-pop 520ms var(--ease-spring); }
@keyframes badge-pop { 0% { transform: translate(-30px, 12px) scale(.2); opacity: 0; } 60% { transform: translate(-12px, -7px) scale(1.25); } 100% { transform: translate(-14px, -4px) scale(1); } }

/* اعلانک: با تاری و کمی بزرگ‌نمایی بالا می‌آید */
.toast { transition: transform 420ms var(--ease-spring), filter var(--dur) var(--ease-out), opacity var(--dur); filter: blur(6px); opacity: 0; }
.toast.show { filter: none; opacity: 1; }

/* لرزش خطا */
.shake { animation: shake 420ms var(--ease-out); }
@keyframes shake { 15% { transform: translateX(-8px); } 30% { transform: translateX(7px); } 45% { transform: translateX(-5px); } 60% { transform: translateX(3px); } 75% { transform: translateX(-1px); } }
.toast.shake { animation: shake-t 420ms var(--ease-out); }
@keyframes shake-t { 15% { translate: -8px; } 30% { translate: 7px; } 45% { translate: -5px; } 60% { translate: 3px; } }

/* سوییچ: شست با دو جهش می‌نشیند */
.switch::after { transition: right 520ms var(--ease-bounce), background var(--dur); }
.switch { transition: background var(--dur) var(--ease-out); }

/* دکمه‌ها: فشرده شدن فیزیکی */
.btn, .chip, .fan-btn, .check, .swatch, .emoji-pick button, .theme-card { transition: transform var(--dur-quick) var(--ease-out), box-shadow var(--dur-quick) var(--ease-out), background var(--dur) var(--ease-out), border-color var(--dur); }
.chip:active, .emoji-pick button:active, .swatch:active, .theme-card:active { transform: scale(.94); }
.chip[aria-pressed="true"] { animation: chip-on 300ms var(--ease-spring); }
@keyframes chip-on { 0% { transform: scale(.92); } 100% { transform: none; } }

/* تیک خرید: دایره پر می‌شود، تیک کشیده می‌شود، خط روی عنوان می‌دود */
.item .t { background: linear-gradient(currentColor, currentColor) 100% 55% / 0 2px no-repeat; transition: background-size 380ms var(--ease-out) 80ms, color var(--dur); }
.item.checking .t { background-size: 100% 2px; color: var(--muted); }
.item.checking .check { background: var(--primary); animation: check-pop 420ms var(--ease-spring); }
.item.checking .check::before { content: ''; width: 12px; height: 7px; border-left: 3px solid var(--on-primary); border-bottom: 3px solid var(--on-primary); transform: rotate(-45deg) translate(1px, -1px); clip-path: inset(0 100% 0 0); animation: draw 260ms var(--ease-out) 120ms forwards; }
@keyframes check-pop { 0% { transform: scale(.7); } 100% { transform: none; } }
@keyframes draw { to { clip-path: inset(0 0 0 0); } }
.item.checking { animation: item-away 380ms var(--ease-in) 340ms forwards; }
@keyframes item-away { to { opacity: .4; transform: translateY(6px); } }

/* کاغذخردکن */
.shred-layer { position: fixed; z-index: 70; pointer-events: none; }
.shred-strip { position: absolute; inset: 0; margin: 0; animation: shred 520ms var(--ease-in) both; animation-delay: var(--d); }
@keyframes shred {
  0% { transform: none; }
  25% { transform: translateY(4px); }
  100% { transform: translate(var(--dx), 140px) rotate(var(--rx)); opacity: 0; filter: blur(1px); }
}

/* مهر لاستیکی */
.stamp-mark { position: fixed; z-index: 75; left: 50%; top: 45%; pointer-events: none;
  font-family: var(--display); font-weight: var(--display-w); font-size: 38px; line-height: 1;
  white-space: nowrap; color: var(--hot); border: 5px double currentColor; border-radius: 16px; padding: 14px 26px 12px; font-size: 44px; box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 30%, transparent) inset;
  transform: translate(-50%, -50%) rotate(-12deg); 
  animation: stamp-slam 520ms cubic-bezier(.2, 1.4, .4, 1) both; background: color-mix(in srgb, var(--sheet) 82%, transparent); backdrop-filter: blur(2px); }
.stamp-mark.good { color: var(--good); }
.stamp-mark span { display: block; filter: url(#rough); }
@keyframes stamp-slam { 0% { opacity: 0; transform: translate(-50%, -50%) rotate(-24deg) scale(2.4); } 60% { opacity: 1; transform: translate(-50%, -50%) rotate(-10deg) scale(.92); } 100% { opacity: 1; transform: translate(-50%, -50%) rotate(-12deg) scale(1); } }
.sheet.thud { animation: sheet-thud 300ms var(--ease-out) 260ms; }
.stamp-mark.lift { transition: opacity 300ms, transform 300ms var(--ease-in); opacity: 0; transform: translate(-50%, -60%) rotate(-12deg) scale(1.05); }
@keyframes sheet-thud { 30% { translate: 0 5px; } 100% { translate: 0 0; } }

/* کاغذ رنگی */
.confetti-layer { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.cf { position: absolute; left: 0; top: 0; width: 9px; height: 13px; border-radius: 2px; }
.cf.star { width: 14px; height: 14px; border-radius: 0; clip-path: polygon(50% 0, 62% 26%, 85% 15%, 74% 38%, 100% 50%, 74% 62%, 85% 85%, 62% 74%, 50% 100%, 38% 74%, 15% 85%, 26% 62%, 0 50%, 26% 38%, 15% 15%, 38% 26%); }

/* جابه‌جایی پند با تاری */
.q-text { cursor: pointer; transition: opacity 170ms var(--ease-out), filter 170ms, transform 170ms; }
.swap-out { opacity: 0; filter: blur(6px); transform: translateY(-6px); }
.swap-in { animation: swap-in 260ms var(--ease-out); }
@keyframes swap-in { from { opacity: 0; filter: blur(6px); transform: translateY(6px); } }

/* بادبزن چسبناک دکمهٔ ستاره */
.fan-scrim { position: fixed; inset: 0; z-index: 30; background: color-mix(in srgb, var(--paper) 72%, transparent); backdrop-filter: blur(3px); opacity: 0; transition: opacity var(--dur) var(--ease-out); }
.fan.open .fan-scrim { opacity: 1; }
body.fan-open .nav { z-index: 31; }
.goo-defs { position: absolute; width: 0; height: 0; }
.fan-stage { position: fixed; z-index: 32; width: 0; height: 0; }
.fan-blobs { position: absolute; left: 0; top: 0; filter: url(#goo); }
.fan-blobs i { position: absolute; left: -32px; top: -32px; width: 64px; height: 64px; border-radius: 50%; background: var(--primary);
  transform: translate(0, 0) scale(.4); transition: transform 460ms var(--ease-spring); transition-delay: var(--d, 0ms); }
.fan.open .fan-blobs i:not(.core) { transform: translate(var(--tx), var(--ty)) scale(1); }
.fan-btn { position: absolute; left: -32px; top: -32px; width: 64px; height: 64px; border: 0; background: none; padding: 0; color: var(--on-primary);
  display: grid; place-items: center; opacity: 0; transform: translate(0, 0) scale(.3);
  transition: transform 460ms var(--ease-spring), opacity 200ms var(--ease-out); transition-delay: var(--d); }
.fan.open .fan-btn { opacity: 1; transform: translate(var(--tx), var(--ty)) scale(1); }
.fan-btn .fe { font-size: 26px; line-height: 1; }
.fan-btn .fl { position: absolute; top: 100%; margin-top: 4px; white-space: nowrap; font-size: 13px; font-weight: 800; color: var(--ink);
  background: var(--sheet); border: 1.5px solid var(--ink); border-radius: 8px; padding: 0 8px; }
.fan-btn:active { transform: translate(var(--tx), var(--ty)) scale(.9); }
.fan.closing .fan-btn, .fan.closing .fan-blobs i:not(.core) { transition-duration: 200ms; transition-delay: 0ms; }

/* اسکلت بارگذاری با درخشش موج‌دار */
.skeleton { padding: 18px 0; display: grid; gap: 14px; }
.sk { border-radius: 18px; background: color-mix(in srgb, var(--ink) 7%, var(--paper)); position: relative; overflow: hidden; }
.sk::after { content: ''; position: absolute; inset: 0; transform: translateX(100%);
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--sheet) 70%, transparent) 50%, transparent 80%);
  animation: sk-sweep 1.3s var(--ease-out) infinite; }
.sk-top { height: 40px; width: 50%; justify-self: end; }
.sk-hero { height: 170px; border-radius: 26px; }
.sk-card { height: 110px; }
.sk-row { height: 58px; }
@keyframes sk-sweep { to { transform: translateX(-100%); } }

/* ستارهٔ دکمه هنگام لمس */
.fab:active svg { transform: scale(.9) rotate(-10deg); }
.fab[aria-expanded="true"] svg { transform: rotate(45deg) scale(1.05); }
.fab .plus { transition: transform 380ms var(--ease-spring); }
.fab[aria-expanded="true"] .plus { transform: rotate(45deg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
  ::view-transition-old(page), ::view-transition-new(page) { animation: none; }
}
