/* The Spirit of Mithila — core design system
   Pink is the accent, never the wallpaper. Pink fills carry ink text (#291823),
   which passes WCAG AA; white text on #FF2F86 does not. */

:root {
  --pink: #FF2F86;
  --pink-hover: #FF4F99;
  --pink-ink: #C2125F;      /* pink for text/links on white, 5.6:1 */
  --pink-soft: #FFC5DC;
  --pink-pale: #FFF0F6;
  --ink: #291823;
  --ink-2: #5E4553;
  --ink-3: #82697A;
  --bg: #FFFFFF;
  --bg-soft: #FFF8FB;
  --surface: #FFFFFF;
  --line: #F2E1EA;
  --line-strong: #E5C9D7;
  --success: #0B7A55; --success-bg: #E6F6EF;
  --warn: #8F5300;    --warn-bg: #FFF4DE;
  --danger: #B4202F;  --danger-bg: #FDECEE;
  --info: #2B5FA8;    --info-bg: #EAF1FC;
  --app-accent: var(--pink);
  --r-xs: 6px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(41, 24, 35, .06);
  --shadow-2: 0 1px 2px rgba(41, 24, 35, .05), 0 10px 28px -14px rgba(194, 18, 95, .22);
  --shadow-3: 0 24px 60px -20px rgba(41, 24, 35, .35);
  --font: "Bricolage Grotesque", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-deva: "Noto Sans Devanagari", "Bricolage Grotesque", system-ui, sans-serif;
  --header-h: 64px;
  --bottom-h: 64px;
  --max: 1320px;
  --gutter: clamp(16px, 3vw, 32px);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --pink-ink: #FF77AE; --pink-pale: #2C1522; --pink-soft: #5A2442;
    --ink: #FBEFF5; --ink-2: #D9C3CF; --ink-3: #AE95A3;
    --bg: #160C12; --bg-soft: #1D1118; --surface: #21141C;
    --line: #36222D; --line-strong: #4A3040;
    --success-bg: #0F2C21; --warn-bg: #33240C; --danger-bg: #3A1218; --info-bg: #13233D;
    --success: #4FD1A1; --warn: #F5B54A; --danger: #FF7C88; --info: #8DB5F5;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --pink-ink: #FF77AE; --pink-pale: #2C1522; --pink-soft: #5A2442;
  --ink: #FBEFF5; --ink-2: #D9C3CF; --ink-3: #AE95A3;
  --bg: #160C12; --bg-soft: #1D1118; --surface: #21141C;
  --line: #36222D; --line-strong: #4A3040;
  --success-bg: #0F2C21; --warn-bg: #33240C; --danger-bg: #3A1218; --info-bg: #13233D;
  --success: #4FD1A1; --warn: #F5B54A; --danger: #FF7C88; --info: #8DB5F5;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.55; color: var(--ink);
  background: var(--bg); -webkit-font-smoothing: antialiased; font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}
:lang(hi), :lang(mai) { font-family: var(--font-deva); line-height: 1.7; }
img, video, svg { max-width: 100%; display: block; }
img { height: auto; }
a { color: var(--pink-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 .5em; font-weight: 650; letter-spacing: -.015em; text-wrap: balance; }
h1 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.6rem); font-weight: 700; letter-spacing: -.025em; }
h2 { font-size: clamp(1.3rem, 1.05rem + 1vw, 1.75rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
p { margin: 0 0 1em; }
small, .small { font-size: .875rem; }
.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
:focus-visible { outline: 3px solid var(--pink); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--pink-soft); color: var(--ink); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r-sm); }
.skip-link:focus { top: 12px; }
.i { width: 20px; height: 20px; flex: none; }
.i-sm { width: 16px; height: 16px; flex: none; }
.i-lg { width: 28px; height: 28px; flex: none; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.container-narrow { max-width: 760px; margin: 0 auto; padding: 0 var(--gutter); }
.container-mid { max-width: 1040px; margin: 0 auto; padding: 0 var(--gutter); }
.stack > * + * { margin-top: var(--stack, 16px); }
.row { display: flex; gap: var(--gap, 12px); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: var(--gap, 20px); }
.grid-2 { display: grid; gap: var(--gap, 20px); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--gap, 20px); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: var(--gap, 20px); grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { display: grid; gap: var(--gap, 20px); grid-template-columns: repeat(auto-fill, minmax(var(--min, 200px), 1fr)); }
.split { display: grid; gap: 32px; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
.split-left { display: grid; gap: 32px; grid-template-columns: 260px minmax(0, 1fr); align-items: start; }
.sticky { position: sticky; top: calc(var(--header-h) + 16px); }
.section { padding: clamp(28px, 4vw, 56px) 0; }
.section-tight { padding: 20px 0; }
.page { padding: 24px 0 56px; min-height: 60vh; }
.page-head { display: flex; gap: 16px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.section-head h2 { margin: 0; }
.section-head a { font-weight: 550; text-decoration: none; white-space: nowrap; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0 } .mb-0 { margin-bottom: 0 } .mt-1 { margin-top: 8px } .mt-2 { margin-top: 16px } .mt-3 { margin-top: 24px } .mt-4 { margin-top: 40px } .mb-1 { margin-bottom: 8px } .mb-2 { margin-bottom: 16px } .mb-3 { margin-bottom: 24px }
.w-full { width: 100%; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hide-mobile { }
.show-mobile { display: none !important; }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .split { grid-template-columns: minmax(0, 1fr) 320px; } }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split, .split-left { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .hide-mobile { display: none !important; }
  .show-mobile { display: revert !important; }
  .brand.show-mobile { display: flex !important; }
  .page { padding-top: 16px; }
}

/* ---------- Buttons ---------- */
.btn {
  --b-bg: var(--surface); --b-fg: var(--ink); --b-line: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-sm); border: 1px solid var(--b-line);
  background: var(--b-bg); color: var(--b-fg); font: inherit; font-weight: 600; font-size: .95rem;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, transform .08s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn-primary { --b-bg: var(--pink); --b-fg: #291823; --b-line: var(--pink); }
.btn-primary:hover { --b-bg: var(--pink-hover); border-color: var(--pink-hover); }
.btn-dark { --b-bg: #291823; --b-fg: #fff; --b-line: #291823; }
:root[data-theme="dark"] .btn-dark { --b-bg: #FBEFF5; --b-fg: #291823; --b-line: #FBEFF5; }
.btn-soft { --b-bg: var(--pink-pale); --b-fg: var(--pink-ink); --b-line: transparent; }
.btn-soft:hover { --b-bg: var(--pink-soft); border-color: transparent; }
.btn-ghost { --b-bg: transparent; --b-line: transparent; }
.btn-ghost:hover { --b-bg: var(--bg-soft); border-color: transparent; }
.btn-danger { --b-bg: var(--danger-bg); --b-fg: var(--danger); --b-line: transparent; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .875rem; border-radius: 8px; }
.btn-lg { min-height: 52px; padding: 0 26px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--pink-ink); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .field .row-between > label, .label { font-weight: 600; font-size: .9rem; }
.field .hint { font-size: .825rem; color: var(--ink-3); }
.field .error, .error-text { font-size: .85rem; color: var(--danger); }
.input, .select, .textarea, input[type=text].input {
  width: 100%; min-height: 46px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 1rem; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2382697A' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--pink); box-shadow: 0 0 0 4px color-mix(in srgb, var(--pink) 18%, transparent); }
.input[aria-invalid=true], .is-invalid { border-color: var(--danger); }
.input-sm { min-height: 36px; padding: 6px 10px; font-size: .9rem; }
.select.input-sm { padding-right: 32px; background-position: right 10px center; } /* keep room for the chevron on small selects */
.input-group { display: flex; }
.input-group .input { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.input-group .btn { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.check { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; font-size: .95rem; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--pink-ink); flex: none; }
.radio-cards { display: grid; gap: 10px; }
.radio-card { display: flex; gap: 12px; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: var(--r-md); cursor: pointer; align-items: flex-start; }
.radio-card:has(input:checked) { border-color: var(--pink); background: var(--pink-pale); box-shadow: inset 0 0 0 1px var(--pink); }
.radio-card input { accent-color: var(--pink-ink); margin-top: 3px; }
.form-grid { display: grid; gap: 0 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
fieldset { border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px 20px; margin: 0 0 20px; }
legend { font-weight: 650; padding: 0 6px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-1); transition: transform .15s var(--ease); }
.switch input:checked { background: var(--pink); }
.switch input:checked::after { transform: translateX(18px); }

/* ---------- Surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 20px; }
.card-flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: 1.05rem; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line); background: var(--bg-soft); }
.panel-soft { background: var(--pink-pale); border-radius: var(--r-lg); padding: 24px; }
.raised { box-shadow: var(--shadow-2); border-color: transparent; }
.divider-list > * + * { border-top: 1px solid var(--line); }
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; }
.list-row-pad { padding: 14px 20px; }

/* ---------- Badges & status ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: var(--r-pill); font-size: .78rem; font-weight: 600; background: var(--bg-soft); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; line-height: 1.6; }
.badge-pink { background: var(--pink-pale); color: var(--pink-ink); border-color: transparent; }
.badge-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-bg); color: var(--info); border-color: transparent; }
.badge-dark { background: var(--ink); color: var(--bg); border-color: transparent; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: .9rem; font-weight: 550; text-decoration: none; cursor: pointer; white-space: nowrap; }
.chip:hover { border-color: var(--ink-3); text-decoration: none; }
.chip.is-active, .chip[aria-pressed=true] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }

/* ---------- Alerts & flash ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-sm); background: var(--info-bg); color: var(--ink); margin-bottom: 16px; font-size: .95rem; }
.alert .i { color: var(--info); margin-top: 2px; }
.alert-success { background: var(--success-bg); } .alert-success .i { color: var(--success); }
.alert-warn { background: var(--warn-bg); } .alert-warn .i { color: var(--warn); }
.alert-danger { background: var(--danger-bg); } .alert-danger .i { color: var(--danger); }
.toast-host { position: fixed; z-index: 90; left: 50%; transform: translateX(-50%); bottom: 24px; display: grid; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; background: #291823; color: #fff; padding: 12px 16px; border-radius: var(--r-sm); box-shadow: var(--shadow-3); display: flex; gap: 12px; align-items: center; animation: toast-in .25s var(--ease); font-size: .95rem; }
.toast button { margin-left: auto; background: none; border: 0; color: var(--pink-soft); font: inherit; font-weight: 650; cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (max-width: 760px) { .toast-host { bottom: calc(var(--bottom-h) + 16px + env(safe-area-inset-bottom)); } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: .82rem; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg-soft); white-space: nowrap; }
.table th a { color: inherit; text-decoration: none; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg-soft); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { min-height: 40px; width: auto; }
.bulk-bar { display: none; gap: 10px; align-items: center; padding: 10px 14px; background: var(--pink-pale); border-radius: var(--r-sm); margin-bottom: 12px; }
.bulk-bar.is-visible { display: flex; }
@media (max-width: 760px) {
  .table-stack thead { display: none; }
  .table-stack tr { display: block; padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table-stack td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; }
  .table-stack td[data-label]::before { content: attr(data-label); color: var(--ink-3); font-size: .85rem; }
}

/* ---------- Stats ---------- */
.stats { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat { padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.stat-label { color: var(--ink-2); font-size: .875rem; }
.stat-value { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 4px; line-height: 1.2; }
.stat-delta { font-size: .82rem; margin-top: 4px; color: var(--ink-3); }
.stat-delta.up { color: var(--success); } .stat-delta.down { color: var(--danger); }
.bar-chart { display: flex; align-items: flex-end; gap: 4px; height: 160px; padding-top: 8px; }
.bar-chart .bar { flex: 1; background: var(--pink-soft); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bar-chart .bar:hover { background: var(--pink); }
.bar-chart .bar span { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: .7rem; color: var(--ink-2); white-space: nowrap; opacity: 0; }
.bar-chart .bar:hover span { opacity: 1; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--pink); border-radius: 99px; }

/* ---------- Empty / skeleton ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--ink-2); }
.empty .empty-icon { width: 56px; height: 56px; margin: 0 auto 14px; display: grid; place-items: center; border-radius: 50%; background: var(--pink-pale); color: var(--pink-ink); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty p { max-width: 42ch; margin: 0 auto 16px; }
.skeleton { background: linear-gradient(90deg, var(--line) 0%, var(--bg-soft) 50%, var(--line) 100%); background-size: 200% 100%; animation: sk 1.3s linear infinite; border-radius: var(--r-xs); }
@keyframes sk { to { background-position: -200% 0; } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { padding: 12px 14px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .95rem; border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; font-family: inherit; }
.tabs a:hover, .tabs button:hover { color: var(--ink); }
.tabs .is-active, .tabs [aria-selected=true] { color: var(--ink); border-bottom-color: var(--pink); }

/* ---------- Dialog / sheet ---------- */
dialog.dialog { border: 0; padding: 0; border-radius: var(--r-lg); width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3); }
dialog.dialog::backdrop { background: rgba(41, 24, 35, .45); backdrop-filter: blur(2px); }
dialog.dialog[open] { animation: dlg-in .2s var(--ease); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.dialog-head h2 { font-size: 1.15rem; margin: 0; }
.dialog-body { padding: 16px 20px 20px; overflow-y: auto; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@media (max-width: 640px) {
  dialog.dialog.sheet-mobile { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: env(safe-area-inset-bottom); }
  dialog.dialog.sheet-mobile[open] { animation: sheet-in .25s var(--ease); }
}
@keyframes sheet-in { from { transform: translateY(100%); } }

/* ---------- Menus ---------- */
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3); padding: 6px; z-index: 60; display: none; }
.menu.is-open { display: block; animation: dlg-in .14s var(--ease); }
.menu a, .menu button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 10px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; font: inherit; font-size: .95rem; background: none; border: 0; cursor: pointer; text-align: left; }
.menu a:hover, .menu button:hover { background: var(--bg-soft); }
.menu .menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.menu .menu-label { padding: 8px 12px 4px; font-size: .8rem; color: var(--ink-3); }

/* ---------- Header ---------- */
.site-header { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); }
.header-inner { display: flex; align-items: center; gap: 16px; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-text { display: grid; line-height: 1.05; }
.brand-name { font-weight: 750; font-size: 1.02rem; letter-spacing: -.02em; }
.brand-app { font-size: .78rem; color: var(--pink-ink); font-weight: 600; }
.header-search { flex: 1 1 auto; max-width: 640px; position: relative; }
.header-search .input { padding-left: 44px; min-height: 44px; border-radius: var(--r-pill); background: var(--bg-soft); border-color: var(--line); }
.header-search .input:focus { background: var(--surface); }
.header-search > .i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.header-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: var(--ink); background: none; border: 0; cursor: pointer; text-decoration: none; }
.icon-btn:hover { background: var(--bg-soft); }
.icon-btn .count { position: absolute; top: 4px; right: 2px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--pink); color: #291823; font-size: .7rem; font-weight: 750; display: grid; place-items: center; line-height: 1; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--pink-soft); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: .8rem; overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.subnav { border-bottom: 1px solid var(--line); background: var(--bg); }
.subnav-inner { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.subnav-inner::-webkit-scrollbar { display: none; }
.subnav a { display: flex; align-items: center; gap: 6px; padding: 11px 12px; color: var(--ink-2); text-decoration: none; font-weight: 550; font-size: .92rem; white-space: nowrap; border-bottom: 2px solid transparent; }
.subnav a:hover { color: var(--ink); }
.subnav a.is-active { color: var(--ink); border-bottom-color: var(--app-accent); }
.announcement { background: var(--ink); color: #FBEFF5; font-size: .875rem; text-align: center; padding: 8px 16px; }
.announcement a { color: var(--pink-soft); }

/* App switcher */
.app-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px; width: 330px; }
.app-tile { display: grid; justify-items: center; gap: 6px; padding: 12px 6px; border-radius: var(--r-sm); text-decoration: none; color: var(--ink); font-size: .82rem; font-weight: 550; text-align: center; }
.app-tile:hover { background: var(--bg-soft); }
.app-tile-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--pink-pale); color: var(--pink-ink); }

/* Mobile app chrome */
.bottom-nav { display: none; }
@media (max-width: 760px) {
  :root { --header-h: 56px; }
  .header-inner { gap: 8px; }
  .header-search { display: none; }
  .header-search.mobile-visible { display: block; }
  .brand-text .brand-name { font-size: .95rem; }
  .subnav { display: none; }
  body.has-bottom-nav { padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom)); }
  .bottom-nav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; z-index: 55; left: 0; right: 0; bottom: 0;
    height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  }
  .bottom-nav a { display: grid; justify-items: center; align-content: center; gap: 3px; color: var(--ink-3); text-decoration: none; font-size: .7rem; font-weight: 600; position: relative; -webkit-tap-highlight-color: transparent; }
  .bottom-nav a .i { width: 22px; height: 22px; }
  .bottom-nav a.is-active { color: var(--ink); }
  .bottom-nav a.is-active::before { content: ""; position: absolute; top: 0; width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--app-accent); }
  .bottom-nav .count { position: absolute; top: 6px; left: calc(50% + 4px); min-width: 16px; height: 16px; border-radius: 99px; background: var(--pink); color: #291823; font-size: .65rem; font-weight: 750; display: grid; place-items: center; padding: 0 4px; }
  .sticky-action { position: fixed; z-index: 54; left: 0; right: 0; bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding: 10px 16px; background: var(--surface); border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; }
  body.no-bottom-nav .sticky-action { bottom: 0; padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}
@media (display-mode: standalone) { .hide-standalone { display: none !important; } }

/* Full-screen mobile search */
.search-overlay { position: fixed; inset: 0; z-index: 80; background: var(--bg); display: none; flex-direction: column; padding-top: env(safe-area-inset-top); }
.search-overlay.is-open { display: flex; }
.search-overlay-head { display: flex; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.search-overlay-head .input { border-radius: var(--r-pill); }
.search-overlay-body { padding: 16px; overflow-y: auto; }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-3); padding: 6px; z-index: 70; display: none; }
.suggest.is-open { display: block; }
.suggest a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.suggest a:hover, .suggest a.is-hl { background: var(--bg-soft); }
.suggest .suggest-label { font-size: .78rem; color: var(--ink-3); padding: 8px 12px 2px; }

/* ---------- Install app ---------- */
.install-card { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border-radius: var(--r-md); background: var(--pink-pale); border: 1px solid var(--pink-soft); }
.install-card img { width: 44px; height: 44px; border-radius: 11px; }
.install-banner { position: fixed; z-index: 58; left: 12px; right: 12px; bottom: calc(var(--bottom-h) + 12px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-3); display: none; }
.install-banner.is-visible { display: flex; animation: toast-in .3s var(--ease); }
@media (min-width: 761px) { .install-banner { left: auto; right: 24px; bottom: 24px; width: 400px; } }
.ios-steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.ios-steps li { counter-increment: s; display: grid; grid-template-columns: 32px 1fr; gap: 12px; align-items: start; }
.ios-steps li::before { content: counter(s); width: 32px; height: 32px; border-radius: 50%; background: var(--pink-pale); color: var(--pink-ink); display: grid; place-items: center; font-weight: 700; }
.ios-share { display: inline-flex; vertical-align: -4px; }

/* ---------- Media tiles (shared by apps) ---------- */
.tile { display: block; text-decoration: none; color: var(--ink); }
.tile-media { aspect-ratio: 1; border-radius: var(--r-md); overflow: hidden; background: var(--bg-soft); position: relative; }
.tile-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s var(--ease); }
.tile:hover .tile-media img { transform: scale(1.03); }
.tile-title { font-weight: 600; margin-top: 10px; line-height: 1.3; }
.tile-sub { color: var(--ink-3); font-size: .875rem; margin-top: 2px; }
.ratio-16x9 { aspect-ratio: 16 / 9; } .ratio-4x5 { aspect-ratio: 4 / 5; } .ratio-9x16 { aspect-ratio: 9 / 16; } .ratio-3x2 { aspect-ratio: 3 / 2; }
.scroller { display: grid; grid-auto-flow: column; grid-auto-columns: var(--col, 220px); gap: 16px; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; padding-bottom: 4px; overscroll-behavior-x: contain; }
.scroller::-webkit-scrollbar { display: none; }
.scroller > * { scroll-snap-align: start; }
@media (max-width: 640px) { .scroller { --col: 62vw; margin: 0 calc(var(--gutter) * -1); padding: 0 var(--gutter); scroll-padding: 0 var(--gutter); } }
.rating { display: inline-flex; align-items: center; gap: 4px; font-size: .85rem; font-weight: 600; }
.rating .i-sm { color: #E8A100; fill: #E8A100; }
.price { font-weight: 700; font-variant-numeric: tabular-nums; }
.price-was { color: var(--ink-3); text-decoration: line-through; font-weight: 400; font-size: .9em; }
.price-off { color: var(--success); font-weight: 650; font-size: .9em; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin-top: 28px; }
.pagination a, .pagination span { min-width: 40px; height: 40px; padding: 0 10px; display: grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 550; }
.pagination .is-current { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pagination .is-disabled { color: var(--ink-3); }

/* ---------- Footer ---------- */
.site-footer { margin-top: 48px; background: var(--bg-soft); border-top: 1px solid var(--line); padding: 48px 0 32px; font-size: .92rem; }
.site-footer .motif-border { height: 18px; margin-top: -48px; margin-bottom: 40px; background: url(/img/motif-border.svg) repeat-x center / auto 18px; opacity: .9; }
.footer-grid { display: grid; gap: 32px; grid-template-columns: 1.4fr repeat(4, 1fr); }
.footer-grid h4 { font-size: .9rem; margin-bottom: 12px; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.footer-grid a { color: var(--ink-2); text-decoration: none; }
.footer-grid a:hover { color: var(--ink); text-decoration: underline; }
.footer-bottom { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; border-top: 1px solid var(--line); margin-top: 32px; padding-top: 20px; color: var(--ink-3); font-size: .85rem; }
@media (max-width: 900px) { .footer-grid { grid-template-columns: 1fr 1fr; } }

/* ---------- Auth pages ---------- */
.auth-shell { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-art { background: var(--pink-pale); position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: 40px; }
.auth-art .motif { position: absolute; right: -60px; bottom: -40px; width: 520px; opacity: .95; }
.auth-art blockquote { margin: 0; font-size: 1.6rem; line-height: 1.25; font-weight: 600; letter-spacing: -.02em; max-width: 18ch; position: relative; }
.auth-main { display: grid; place-items: center; padding: 40px var(--gutter); }
.auth-box { width: 100%; max-width: 400px; }
.auth-box h1 { font-size: 1.8rem; }
.or { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-size: .85rem; margin: 18px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
@media (max-width: 900px) { .auth-shell { grid-template-columns: 1fr; } .auth-art { display: none; } .auth-main { place-items: start center; padding-top: 32px; } }
.otp-input { letter-spacing: .5em; font-size: 1.4rem; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Dashboard layout (seller, creators, admin) ---------- */
.dash { display: grid; grid-template-columns: 252px minmax(0, 1fr); min-height: 100dvh; }
.dash-side { position: sticky; top: 0; height: 100dvh; overflow-y: auto; border-right: 1px solid var(--line); background: var(--bg-soft); padding: 16px 12px 24px; display: flex; flex-direction: column; gap: 4px; }
.dash-side .brand { padding: 4px 8px 16px; }
.dash-group { font-size: .78rem; color: var(--ink-3); padding: 14px 10px 4px; font-weight: 600; }
.dash-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 550; font-size: .92rem; }
.dash-link:hover { background: var(--surface); color: var(--ink); }
.dash-link.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.dash-link.is-active .i { color: var(--pink-ink); }
.dash-main { min-width: 0; }
.dash-scrim { display: none; } /* only shown (fixed overlay) on small screens; must never take a grid cell on desktop */
.dash-top { position: sticky; top: 0; z-index: 40; height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 28px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); }
.dash-content { padding: 28px; max-width: 1400px; }
.dash-burger { display: none; }
@media (max-width: 1000px) {
  .dash { grid-template-columns: 1fr; }
  .dash-side { position: fixed; z-index: 70; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .25s var(--ease); }
  .dash-side.is-open { transform: none; box-shadow: var(--shadow-3); } /* no shadow while hidden: it bled onto the page edge */
  .dash-burger { display: inline-grid; }
  .dash-top { padding: 0 12px; }
  .dash-content { padding: 20px 16px 96px; }
  .dash-scrim { position: fixed; inset: 0; z-index: 65; background: rgba(41, 24, 35, .4); display: none; }
  .dash-scrim.is-open { display: block; }
}

/* ---------- Decorative motif ---------- */
.motif-line { height: 14px; background: url(/img/motif-border.svg) repeat-x center / auto 14px; }

/* ---------- Print ---------- */
@media print {
  .site-header, .bottom-nav, .site-footer, .no-print, .dash-side, .dash-top, .install-banner, .toast-host { display: none !important; }
  body { background: #fff; color: #000; }
  .dash { display: block; }
}
.h3 { font-size: 1.15rem; } .h2 { font-size: clamp(1.3rem, 1.05rem + 1vw, 1.75rem); }

/* Foundation fixes */
[hidden] { display: none !important; }
@media (min-width: 1001px) { .dash-scrim { display: none; } }
