/* هوش مصنوعی آکادمی حمید عیوضی — design tokens follow hamideyvazi.com:
   dark navy is the default; gold (from the logo) = headings, thin borders, highlights;
   green = main action buttons only; red = errors only. */
@font-face { font-family: 'Vazirmatn'; src: url('/fonts/vazirmatn-400.woff2') format('woff2'); font-weight: 100 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('/fonts/vazirmatn-700.woff2') format('woff2'); font-weight: 600 900; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #090e18; --bg-soft: #0d1422; --bg-deep: #060a12;
  --glass: rgb(255 255 255 / 4%); --glass-strong: rgb(255 255 255 / 7%); --field: #0f1727;
  --text: #e9edf4; --muted: #a6b0c2; --faint: #7d879a;
  --line: rgb(227 183 102 / 16%); --border: rgb(227 183 102 / 26%); --border-strong: rgb(227 183 102 / 70%);
  --gold: #e3b766; --gold-strong: #f3d48e; --gold-soft: rgb(227 183 102 / 11%); --on-gold: #1a1204;
  --action: #22c55e; --action-strong: #4ade80; --on-action: #04230f;
  --danger: #ff7b72; --danger-bg: rgb(255 123 114 / 12%); --warn: #f3d9a4; --warn-bg: rgb(227 183 102 / 10%);
  --user-bubble: rgb(227 183 102 / 10%); --code-bg: #05080f; --code-fg: #e2e8f0; --code-line: #1b2435;
  --shadow: 0 1px 0 rgb(255 255 255 / 4%) inset, 0 12px 32px rgb(0 0 0 / 35%);
  --blur: saturate(140%) blur(14px);
  --radius: 14px; --radius-lg: 20px; --nav-h: 64px; --head-h: 58px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: 'Vazirmatn', Tahoma, 'Segoe UI', system-ui, sans-serif;
  --mono: ui-monospace, 'Cascadia Code', Consolas, monospace;
}
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #faf8f3; --bg-soft: #f2eee4; --bg-deep: #ece6d8;
  --glass: rgb(255 255 255 / 78%); --glass-strong: #ffffff; --field: #ffffff;
  --text: #1a1f2b; --muted: #505867; --faint: #6b7280;
  --line: rgb(122 82 18 / 14%); --border: rgb(122 82 18 / 24%); --border-strong: rgb(122 82 18 / 60%);
  --gold: #7a5212; --gold-strong: #5e3e0a; --gold-soft: rgb(122 82 18 / 8%); --on-gold: #ffffff;
  --action: #15803d; --action-strong: #116632; --on-action: #ffffff;
  --danger: #b42318; --danger-bg: #fdecea; --warn: #5c3b00; --warn-bg: #fff7e6;
  --user-bubble: rgb(122 82 18 / 8%); --code-bg: #0f172a; --code-line: #1e293b;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 8px 24px rgb(16 24 40 / 8%);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.75;
  -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
  background-image: radial-gradient(1200px 600px at 85% -10%, rgb(227 183 102 / 8%), transparent 60%),
                    radial-gradient(900px 500px at -10% 110%, rgb(34 197 94 / 4%), transparent 60%);
  background-attachment: fixed;
}
:root[data-theme='light'] body { background-image: radial-gradient(1200px 600px at 85% -10%, rgb(227 183 102 / 14%), transparent 60%); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); text-underline-offset: 3px; }
::selection { background: rgb(227 183 102 / 30%); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums lining-nums; direction: ltr; unicode-bidi: isolate; }
.gold { color: var(--gold); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
svg.i.fill { fill: currentColor; stroke: none; }
h1, h2, h3 { color: var(--gold); font-weight: 700; letter-spacing: -.005em; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--glass); color: var(--text);
  border-radius: 12px; padding: 8px 14px; min-height: 42px; text-decoration: none;
  transition: background .18s var(--ease), border-color .18s var(--ease), transform .12s var(--ease), color .18s;
}
.btn:hover { border-color: var(--border-strong); background: var(--glass-strong); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--action); color: var(--on-action); border-color: transparent; font-weight: 700; }
.btn.primary:hover { background: var(--action-strong); }
.btn.gold { color: var(--gold); border-color: var(--border-strong); background: var(--gold-soft); }
.btn.danger { color: var(--danger); border-color: rgb(255 123 114 / 35%); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { min-height: 34px; padding: 3px 10px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.icon-btn {
  border: 1px solid transparent; background: transparent; width: 42px; height: 42px; border-radius: 12px;
  display: inline-grid; place-items: center; color: var(--muted); transition: background .18s, color .18s, border-color .18s;
}
.icon-btn:hover { background: var(--glass-strong); color: var(--text); }
.icon-btn.on { color: var(--gold); background: var(--gold-soft); border-color: var(--border); }
input[type=text], input[type=password], input[type=number], input[type=search], textarea, select {
  width: 100%; border: 1px solid var(--border); background: var(--field); border-radius: 12px; padding: 10px 12px; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
input:focus, textarea:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
input::placeholder, textarea::placeholder { color: var(--faint); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 5px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); margin: 6px 0; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--action); }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 14px; }

.card {
  background: var(--glass); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; box-shadow: var(--shadow); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
.card h2 { font-size: 17px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--glass); color: var(--muted);
  border-radius: 999px; padding: 5px 13px; font-size: 13px; white-space: nowrap; transition: all .18s var(--ease);
  display: inline-flex; align-items: center; gap: 5px;
}
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.on { background: var(--gold-soft); color: var(--gold); border-color: var(--border-strong); font-weight: 700; }
.tag { display: inline-block; font-size: 11.5px; line-height: 1.7; padding: 0 8px; border-radius: 999px; background: var(--glass-strong); color: var(--muted); margin-inline-end: 4px; border: 1px solid var(--line); }
.tag.vision { color: #7dd3fc; } .tag.image { color: #f9a8d4; } .tag.code { color: #86efac; } .tag.free { color: var(--gold); border-color: var(--border); }
:root[data-theme='light'] .tag.vision { color: #075985; } :root[data-theme='light'] .tag.image { color: #9d174d; } :root[data-theme='light'] .tag.code { color: #166534; }
.tag.lvl-free { color: var(--gold); border-color: var(--border); }
.tag.lvl-selected { color: #7dd3fc; } .tag.lvl-all { color: var(--action-strong); }
:root[data-theme='light'] .tag.lvl-selected { color: #075985; } :root[data-theme='light'] .tag.lvl-all { color: #116632; }
.err { color: var(--danger); font-size: 13.5px; min-height: 1.4em; }

/* ---------- brand ---------- */
.logo-d, .logo-l { display: block; }
:root:not([data-theme='light']) .logo-l, :root[data-theme='light'] .logo-d { display: none; }
.brand-foot { text-align: center; color: var(--faint); font-size: 12px; padding: 14px 0 6px; }
.brand-foot b { color: var(--gold); font-weight: 600; }

/* ---------- login ---------- */
#login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
#login .box { width: 100%; max-width: 400px; animation: rise .5s var(--ease) both; }
#login .logo-wrap { display: grid; place-items: center; margin-bottom: 18px; }
#login .logo-wrap img { height: 96px; width: auto; }
#login h1 { margin: 0; font-size: 21px; text-align: center; }
#login .sub { text-align: center; color: var(--muted); font-size: 13.5px; margin: 4px 0 18px; }

/* ---------- shell ---------- */
#app { height: 100%; display: flex; flex-direction: column; }
header.top {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px; min-height: var(--head-h);
  background: rgb(9 14 24 / 72%); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); position: sticky; top: 0; z-index: 5;
}
:root[data-theme='light'] header.top { background: rgb(250 248 243 / 80%); }
header.top .brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
header.top .brand img { height: 34px; width: auto; }
header.top .title { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
header.top .title small { display: block; color: var(--gold); font-weight: 400; font-size: 11.5px; line-height: 1.2; }
.balance { font-size: 13px; color: var(--gold); border: 1px solid var(--border); background: var(--gold-soft); border-radius: 999px; padding: 4px 11px; font-weight: 700; white-space: nowrap; }
main { flex: 1; min-height: 0; overflow: auto; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
nav.bottom {
  position: fixed; bottom: 0; inset-inline: 0; height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; z-index: 6;
  background: rgb(9 14 24 / 82%); border-top: 1px solid var(--line); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
}
:root[data-theme='light'] nav.bottom { background: rgb(250 248 243 / 88%); }
nav.bottom button { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11.5px; color: var(--faint); position: relative; transition: color .18s; }
nav.bottom button svg.i { width: 22px; height: 22px; }
nav.bottom button.on { color: var(--gold); font-weight: 700; }
nav.bottom button.on::before { content: ''; position: absolute; top: 0; width: 28px; height: 2px; border-radius: 2px; background: var(--gold); }
.page { max-width: 880px; margin: 0 auto; padding: 16px; }
.page > h2:first-child { margin-top: 0; }
.tab:not(.hidden) { animation: fade .22s var(--ease) both; }
.section-title { font-size: 15px; color: var(--gold); margin: 22px 0 10px; display: flex; align-items: center; gap: 8px; }

/* ---------- chat ---------- */
#tab-chat { display: flex; flex-direction: column; height: 100%; }
body.on-chat main { overflow: hidden; padding-bottom: 0; }
body.on-chat #tab-chat { height: calc(100% - var(--nav-h) - env(safe-area-inset-bottom)); }
.chat-bar { display: flex; gap: 6px; align-items: center; padding: 8px 12px 6px; }
.model-btn {
  flex: 1; min-width: 0; text-align: start; border: 1px solid var(--border); background: var(--glass); border-radius: 14px;
  padding: 7px 12px; display: flex; align-items: center; gap: 10px; transition: border-color .18s;
}
.model-btn:hover { border-color: var(--border-strong); }
.model-btn .t { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.35; }
.model-btn b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.model-btn small { color: var(--muted); font-size: 11.5px; }
.model-btn > svg { color: var(--gold); }
.fav-row { display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 8px; scrollbar-width: none; }
.fav-row::-webkit-scrollbar { display: none; }
.fav-row .chip { max-width: 190px; }
.fav-row .chip svg.i { fill: currentColor; width: 16px; height: 16px; }
.fav-row .chip span { overflow: hidden; text-overflow: ellipsis; }
#messages { flex: 1; overflow-y: auto; padding: 8px 12px 10px; scroll-behavior: smooth; border-top: 1px solid var(--line); }
.msg { max-width: 780px; margin: 0 auto 14px; display: flex; animation: rise .25s var(--ease) both; }
.msg .bubble { border-radius: 18px; padding: 11px 15px; max-width: 90%; overflow-wrap: anywhere; }
.msg.user { justify-content: flex-start; }
.msg.user .bubble { background: var(--user-bubble); border: 1px solid var(--border); border-start-start-radius: 6px; white-space: pre-wrap; }
.msg.assistant .bubble { background: var(--glass); border: 1px solid var(--line); width: 100%; max-width: 100%; border-start-end-radius: 6px; }
.msg .meta { font-size: 11.5px; color: var(--faint); margin-top: 8px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.msg .meta button { border: 0; background: transparent; color: var(--faint); display: inline-flex; gap: 4px; align-items: center; padding: 2px 4px; border-radius: 6px; font-size: 11.5px; }
.msg .meta button:hover { color: var(--gold); }
.msg .meta svg.i { width: 15px; height: 15px; }
.msg .bubble img.att { max-width: 180px; max-height: 180px; border-radius: 10px; display: block; margin-top: 6px; }
.bubble p { margin: 0 0 9px; } .bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 4px 0 9px; padding-inline-start: 22px; }
.bubble li::marker { color: var(--gold); }
.bubble h2, .bubble h3, .bubble h4 { margin: 14px 0 6px; font-size: 16px; }
.bubble strong { color: var(--gold-strong); }
:root[data-theme='light'] .bubble strong { color: var(--text); }
.bubble blockquote { margin: 6px 0; padding: 4px 12px; border-inline-start: 3px solid var(--border-strong); color: var(--muted); }
.bubble code { background: var(--glass-strong); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; font-family: var(--mono); font-size: 13px; }
.code { margin: 10px 0; border-radius: 12px; overflow: hidden; background: var(--code-bg); direction: ltr; border: 1px solid var(--code-line); }
.code-bar { display: flex; justify-content: space-between; align-items: center; padding: 5px 8px 5px 12px; color: #94a3b8; font-size: 12px; font-family: var(--mono); border-bottom: 1px solid var(--code-line); }
.code-bar .copy { border: 1px solid #334155; background: #111a2b; color: #e2e8f0; border-radius: 8px; font-size: 12px; padding: 2px 10px; font-family: var(--font); display: inline-flex; align-items: center; gap: 4px; }
.code-bar .copy:hover { border-color: var(--gold); color: #f3d48e; }
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; color: var(--code-fg); }
.code pre code { background: transparent; border: 0; padding: 0; color: inherit; font-size: 13px; line-height: 1.6; white-space: pre; }
.tbl { overflow-x: auto; margin: 8px 0; }
.tbl table, table.data { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.tbl th, .tbl td, table.data th, table.data td { border-bottom: 1px solid var(--line); padding: 7px 9px; text-align: start; vertical-align: top; }
.tbl th, table.data th { color: var(--gold); font-weight: 600; font-size: 12.5px; border-bottom-color: var(--border); white-space: nowrap; }
table.data td.num, table.data th.num { text-align: end; white-space: nowrap; }
table.data tbody tr { transition: background .15s; }
table.data tbody tr:hover { background: var(--glass); }
details.think { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
details.think summary { cursor: pointer; color: var(--gold); }
details.think pre { white-space: pre-wrap; font-family: inherit; margin: 4px 0 0; max-height: 220px; overflow: auto; }
.typing::after { content: ''; display: inline-block; width: 8px; height: 15px; margin-inline-start: 2px; vertical-align: -2px; background: var(--gold); animation: blink 1s steps(1) infinite; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .mark { width: 120px; height: auto; opacity: .9; margin: 0 auto 12px; }
.empty h3 { margin: 0 0 4px; }
.starter { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; max-width: 560px; margin: 16px auto 0; }
.starter button { text-align: start; border: 1px solid var(--line); background: var(--glass); border-radius: 14px; padding: 10px 12px; color: var(--text); font-size: 13.5px; transition: border-color .18s; }
.starter button:hover { border-color: var(--border-strong); }
.starter button small { display: block; color: var(--faint); font-size: 12px; }

.composer { border-top: 1px solid var(--line); background: rgb(9 14 24 / 70%); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); padding: 8px 10px; }
:root[data-theme='light'] .composer { background: rgb(250 248 243 / 85%); }
.composer textarea { resize: none; max-height: 40vh; min-height: 46px; border-radius: 14px; }
.composer .tools { display: flex; align-items: center; gap: 2px; margin-top: 4px; }
.attachments { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.att-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: 12.5px; background: var(--glass); max-width: 240px; }
.att-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip button { border: 0; background: transparent; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.estimate { font-size: 12.5px; color: var(--muted); margin: 0 4px 6px; }
.estimate.warn { color: var(--warn); background: var(--warn-bg); border: 1px solid var(--border); border-radius: 10px; padding: 4px 10px; }
.send { width: 46px; height: 46px; border-radius: 14px; border: 0; background: var(--action); color: var(--on-action); display: grid; place-items: center; transition: background .18s, transform .12s; flex: none; }
.send:hover { background: var(--action-strong); }
.send:active { transform: scale(.96); }
.send.stop { background: var(--danger); color: #fff; }
.send.confirm { width: auto; padding: 0 14px; font-size: 13px; font-weight: 700; background: var(--gold); color: var(--on-gold); }
body.code-mode .composer textarea { direction: ltr; font-family: var(--mono); font-size: 13.5px; text-align: left; }
body.code-mode .msg { max-width: 1120px; }
body.code-mode .msg.user .bubble { font-family: var(--mono); font-size: 13px; direction: ltr; text-align: left; }

/* ---------- drawer & modal ---------- */
.drawer-back, .modal-back { position: fixed; inset: 0; background: rgb(3 6 12 / 60%); z-index: 20; animation: fade .2s both; }
.drawer { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; width: min(340px, 86vw); background: var(--bg-soft); border-inline-end: 1px solid var(--border); z-index: 21; display: flex; flex-direction: column; animation: slide-in .25s var(--ease) both; }
.drawer .head { padding: 12px; border-bottom: 1px solid var(--line); display: flex; gap: 8px; }
.drawer .list { overflow-y: auto; flex: 1; padding: 6px; }
.conv { display: flex; align-items: center; gap: 4px; border-radius: 12px; padding: 2px 4px 2px 10px; transition: background .15s; }
.conv:hover { background: var(--glass); }
.conv.on { background: var(--gold-soft); }
.conv.on button.t { color: var(--gold); }
.conv button.t { flex: 1; min-width: 0; text-align: start; border: 0; background: transparent; padding: 9px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-back { z-index: 30; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--bg-soft); border: 1px solid var(--border); width: 100%; max-width: 660px; max-height: 92vh; border-radius: 22px 22px 0 0; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 -10px 40px rgb(0 0 0 / 40%); animation: sheet .28s var(--ease) both; }
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: 22px; animation-name: pop; } }
.modal .head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal .head h3 { margin: 0; flex: 1; font-size: 16px; }
.modal .body { padding: 14px 16px; overflow-y: auto; }
.modal .foot { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.tabs { display: flex; gap: 4px; background: var(--glass); border: 1px solid var(--line); border-radius: 12px; padding: 3px; margin-bottom: 10px; }
.tabs button { flex: 1; border: 0; background: transparent; border-radius: 9px; padding: 6px; color: var(--muted); transition: all .18s; }
.tabs button.on { background: var(--gold-soft); color: var(--gold); font-weight: 700; }

/* ---------- models ---------- */
.filters { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; align-items: center; }
.filters::-webkit-scrollbar { display: none; }
.filters select { width: auto; margin-inline-start: auto; padding: 5px 10px; border-radius: 999px; font-size: 13px; }
.model-item { border: 1px solid var(--line); border-radius: 16px; padding: 11px 13px; background: var(--glass); margin-bottom: 8px; transition: border-color .18s, background .18s; }
.model-item .name { font-weight: 700; }
.model-item .id { font-size: 12px; color: var(--faint); direction: ltr; text-align: end; font-family: var(--mono); overflow-wrap: anywhere; }
.model-item .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--muted); margin-top: 4px; align-items: center; }
.model-item .facts b { color: var(--text); font-weight: 600; }
.model-item.pick { cursor: pointer; }
.model-item.pick:hover { border-color: var(--border-strong); }
.model-item.sel { border-color: var(--gold); background: var(--gold-soft); }
.star { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--faint); transition: color .18s, transform .18s; flex: none; }
.star:hover { color: var(--gold); }
.star.on { color: var(--gold); }
.star.on svg.i { fill: currentColor; }
.star:active { transform: scale(.88); }
.sub-head { font-size: 12.5px; color: var(--gold); margin: 10px 0 6px; display: flex; align-items: center; gap: 6px; }

/* ---------- image ---------- */
.ratios { display: flex; gap: 6px; flex-wrap: wrap; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.gallery figure { margin: 0; background: var(--glass); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; transition: border-color .18s; }
.gallery figure:hover { border-color: var(--border-strong); }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--bg-deep); }
.gallery figcaption { font-size: 12px; padding: 6px 8px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.result img { max-width: 100%; border-radius: 14px; display: block; }

/* ---------- usage ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat .v { font-size: 24px; font-weight: 700; color: var(--text); }
.stat .l { font-size: 12.5px; color: var(--muted); }
.bar { height: 6px; background: var(--glass-strong); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--gold-strong)); border-radius: 99px; }
.bar.hot > i { background: var(--danger); }
.days { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding: 10px 0 4px; direction: ltr; border-bottom: 1px solid var(--line); }
.days div { flex: 1; max-width: 22px; background: linear-gradient(180deg, var(--gold-strong), var(--gold)); border-radius: 4px 4px 0 0; min-height: 2px; opacity: .9; }
.days div.zero { background: var(--line); }
.scroll-x { overflow-x: auto; }
.status-ok { color: var(--action-strong); } .status-error { color: var(--danger); } .status-pending { color: var(--warn); }
:root[data-theme='light'] .status-ok { color: #116632; }

/* ---------- more / admin ---------- */
.menu-list { display: grid; gap: 8px; }
.menu-item { display: flex; align-items: center; gap: 12px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--glass); color: var(--text); text-align: start; width: 100%; transition: border-color .18s, background .18s; }
.menu-item:hover { border-color: var(--border-strong); background: var(--glass-strong); }
.menu-item .ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--gold-soft); color: var(--gold); border: 1px solid var(--line); flex: none; }
.menu-item .tx { flex: 1; min-width: 0; }
.menu-item .tx b { display: block; font-weight: 700; }
.menu-item .tx small { color: var(--muted); font-size: 12.5px; }
.menu-item .count { color: var(--gold); font-weight: 700; }
.user-row { display: flex; gap: 10px; align-items: center; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.user-row:last-child { border-bottom: 0; }
.user-row .who { flex: 1; min-width: 0; }
.user-row .who b { direction: ltr; unicode-bidi: isolate; }
.user-row .facts { font-size: 12.5px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.access-opts { display: grid; gap: 8px; }
.access-opts label.opt { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 14px; color: var(--text); cursor: pointer; transition: border-color .18s, background .18s; font-size: 14px; }
.access-opts label.opt:has(input:checked) { border-color: var(--gold); background: var(--gold-soft); }
.access-opts label.opt input { margin-top: 5px; accent-color: var(--action); }
.access-opts label.opt small { display: block; color: var(--muted); font-size: 12.5px; }
.pick-list { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 4px 10px; margin-top: 6px; }
.pick-list .check { font-size: 13px; }
.pick-list .check span { direction: ltr; unicode-bidi: isolate; }
.lib-item { border: 1px solid var(--line); border-radius: 16px; padding: 11px 13px; background: var(--glass); margin-bottom: 8px; }
.lib-item.hid { opacity: .55; border-style: dashed; }
.lib-item b { display: block; }
.lib-item .d { color: var(--muted); font-size: 13px; }
.lib-item .cat { font-size: 11.5px; color: var(--gold); }
.lib-item pre { white-space: pre-wrap; font-family: var(--font); font-size: 13px; color: var(--muted); background: var(--bg-deep); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 8px 0 0; max-height: 9.5em; overflow: auto; }
.lib-item pre mark, .ph { background: var(--gold-soft); color: var(--gold); border-radius: 4px; padding: 0 2px; }
.lib-item .acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.about { text-align: center; }
.about img { height: 88px; margin: 0 auto 8px; }
.copy-box { white-space: pre-wrap; font-family: var(--font); background: var(--bg-deep); border: 1px solid var(--border); border-radius: 12px; padding: 12px; direction: rtl; }

.toast { position: fixed; bottom: calc(var(--nav-h) + 16px); inset-inline: 16px; margin: auto; max-width: 480px; background: var(--bg-soft); color: var(--text); border: 1px solid var(--border); padding: 11px 15px; border-radius: 14px; z-index: 50; font-size: 14px; box-shadow: 0 12px 30px rgb(0 0 0 / 35%); animation: rise .25s var(--ease) both; }
.toast.bad { border-color: rgb(255 123 114 / 55%); color: var(--danger); background: var(--bg-soft); }
.banner { background: var(--warn-bg); color: var(--warn); border-bottom: 1px solid var(--border); padding: 8px 14px; font-size: 13.5px; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (min-width: 900px) { header.top .brand img { height: 38px; } }
