:root { --nastaliq-family: "IranNastaliq"; --ns: 1.5; --nlh: 2.2; }
/* ------------------------------------------------------------------
   Fal-e Hafez design tokens: warm manuscript cream, lacquer red, gold.
   Spacing rhythm 4/8/12/16/24/32. Buttons: 40px (md) / 32px (sm).
   ------------------------------------------------------------------ */
:root {
  --bg: #f4eee3; --bg-2: #efe6d6; --card: #fffcf6; --ink: #2b2219; --ink-2: #4e4034; --muted: #7c6b5b;
  --line: #e6dac6; --line-2: #d8c9ae;
  --accent: #96362a; --accent-2: #7d2b21; --accent-ink: #fff7ee; --accent-soft: #f6e6e1;
  --gold: #b8923a; --gold-soft: #f5ecd6; --gold-ink: #6e5420;
  --teal: #2e6f6a; --teal-soft: #e1efec;
  --ok: #2f7a4a; --ok-soft: #e3f1e7; --warn: #a66a00; --warn-soft: #fbefd6; --bad: #b3261e; --bad-soft: #f9e2df;
  --soft: #f3ebdd;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 12px 32px -12px rgba(60, 40, 20, .18);
  --r-lg: 20px; --r-md: 12px; --r-sm: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15110d; --bg-2: #1b1612; --card: #201a15; --ink: #f0e7d8; --ink-2: #d9ccb8; --muted: #a79684;
    --line: #342b22; --line-2: #4a3d30;
    --accent: #d8745c; --accent-2: #e5866f; --accent-ink: #1b0f0b; --accent-soft: #3a221c;
    --gold: #d9b65f; --gold-soft: #332a17; --gold-ink: #e8cf8e;
    --teal: #6fb8b0; --teal-soft: #1b2e2c;
    --ok: #7fcb97; --ok-soft: #1c3124; --warn: #e6b04e; --warn-soft: #3a2d12; --bad: #f08a82; --bad-soft: #3d1c19;
    --soft: #2a231c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -12px rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --bg: #15110d; --bg-2: #1b1612; --card: #201a15; --ink: #f0e7d8; --ink-2: #d9ccb8; --muted: #a79684;
  --line: #342b22; --line-2: #4a3d30;
  --accent: #d8745c; --accent-2: #e5866f; --accent-ink: #1b0f0b; --accent-soft: #3a221c;
  --gold: #d9b65f; --gold-soft: #332a17; --gold-ink: #e8cf8e;
  --teal: #6fb8b0; --teal-soft: #1b2e2c;
  --ok: #7fcb97; --ok-soft: #1c3124; --warn: #e6b04e; --warn-soft: #3a2d12; --bad: #f08a82; --bad-soft: #3d1c19;
  --soft: #2a231c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px -12px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif; line-height: 1.85; font-size: 16px; font-feature-settings: "ss01"; }
body::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background: radial-gradient(900px 420px at 85% -10%, color-mix(in srgb, var(--gold) 18%, transparent), transparent 65%),
              radial-gradient(700px 400px at 0% 100%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 60%); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
.wrap { max-width: 860px; margin: 0 auto; padding: 16px 16px 48px; }

/* header */
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0 20px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.3px; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 12.5px; }
nav { display: flex; gap: 2px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
nav a { height: 32px; display: inline-flex; align-items: center; padding: 0 14px; border-radius: 999px; color: var(--muted); font-size: 14px; font-weight: 600; transition: color .15s, background .15s; }
nav a:hover { color: var(--ink); text-decoration: none; }
nav a.active { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.user-chip:empty { display: none; }
.user-chip img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line-2); }

/* cards + text */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 21px; font-weight: 800; line-height: 1.4; }
.card h3 { font-size: 16.5px; font-weight: 800; margin: 24px 0 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card > h3:first-of-type { margin-top: 16px; }
.muted { color: var(--muted); font-size: 14px; }
p { margin: 0 0 8px; }
.invocation { background: var(--gold-soft); color: var(--ink-2); border-radius: var(--r-md); padding: 12px 16px; font-size: 15px; border-right: 3px solid var(--gold); margin: 0 0 16px; }

/* forms */
label { display: block; font-weight: 700; margin: 16px 0 6px; font-size: 14px; }
input, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 0 14px; height: 44px; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 88px; height: auto; padding: 10px 14px; resize: vertical; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
input:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 28%, transparent); }

/* buttons: rows always packed to the LEFT, primary action at the far left */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; font: inherit; font-size: 15px; font-weight: 700; line-height: 1;
  border: 1px solid transparent; border-radius: var(--r-md); cursor: pointer; background: var(--accent); color: var(--accent-ink); white-space: nowrap;
  transition: background .15s, transform .08s ease, box-shadow .15s, border-color .15s; }
.btn:hover { background: var(--accent-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.ghost { background: var(--card); color: var(--ink-2); border-color: var(--line-2); }
.btn.ghost:hover { background: var(--soft); border-color: var(--line-2); color: var(--ink); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13.5px; border-radius: var(--r-sm); }
.btn[disabled] { opacity: .6; cursor: progress; transform: none; }
.row { display: flex; flex-direction: row-reverse; justify-content: flex-start; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.row .muted { margin-inline-start: 4px; }
.error { color: var(--bad); font-size: 14px; min-height: 20px; margin-top: 8px; }
.error:empty { display: none; }
.tg-login { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line-2); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }

/* ghazal */
.ghazal-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 8px; }
.ghazal-head h2 { margin: 0; font-size: 22px; font-family: var(--nastaliq-family), "Noto Nastaliq Urdu", Vazirmatn, serif; line-height: 2; }
.ghazal-head .meta { font-size: 12.5px; color: var(--muted); }
.couplet { display: grid; grid-template-columns: 1fr 1fr; gap: 0 32px; padding: 10px 12px; border-radius: var(--r-sm); font-family: var(--nastaliq-family), "Noto Nastaliq Urdu", Vazirmatn, serif; font-size: 20px; line-height: 2.6; }
.couplet span { text-align: center; }
#couplets .couplet:nth-child(even), .shahed .couplet { background: var(--soft); }
.couplet .meaning { grid-column: 1 / -1; font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif; line-height: 1.8; font-size: 13.5px; color: var(--muted); line-height: 1.8; border-top: 1px dotted var(--line-2); padding-top: 6px; margin-top: 4px; text-align: right; }
@media (max-width: 600px) { .couplet { grid-template-columns: 1fr; gap: 0; font-size: 18px; line-height: 2.5; } .couplet span { text-align: right; } .couplet span:nth-child(2) { padding-right: 22px; } }
.pill { display: inline-flex; align-items: center; height: 22px; font-size: 12px; font-weight: 600; background: var(--soft); color: var(--muted); border-radius: 999px; padding: 0 10px; }
.pill.ok { color: var(--ok); background: var(--ok-soft); } .pill.warn { color: var(--warn); background: var(--warn-soft); } .pill.bad { color: var(--bad); background: var(--bad-soft); }
.section { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.section h3 { margin: 0 0 10px; }
.interp { font-size: 17px; line-height: 2.1; background: linear-gradient(135deg, var(--gold-soft), transparent 70%); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); border-radius: var(--r-md); padding: 14px 18px; }
.src { font-size: 13px; color: var(--muted); }
.src ul { margin: 8px 0 0; padding-inline-start: 18px; }
.shahed { background: var(--soft); border-radius: var(--r-md); padding: 12px 14px; }
.shahed .couplet { font-size: 18px; padding: 4px 0; }
.shahed .muted { margin-top: 6px; }
audio { width: 100%; margin-top: 8px; }
#shareMsg { margin-top: 8px; } #shareMsg:empty { display: none; }

/* history */
.hist-item { display: grid; grid-template-columns: 52px 1fr; gap: 6px 14px; padding: 12px 8px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: var(--r-sm); transition: background .15s; }
.hist-item:last-child { border-bottom: 0; }
.hist-item:hover { background: var(--soft); }
.hist-item .n { font-weight: 800; color: var(--accent); font-size: 19px; height: 44px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); border-radius: var(--r-sm); }
.hist-item .line { font-size: 17px; font-family: var(--nastaliq-family), "Noto Nastaliq Urdu", Vazirmatn, serif; line-height: 2.2; }
.hist-item .sub { font-size: 13px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0 16px; }
.stat { background: var(--soft); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--muted); }
.stat.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); } .stat.ok b { color: var(--ok); }
.stat.warn { background: var(--warn-soft); } .stat.warn b { color: var(--warn); }

/* tables (benchmark) */
table { width: 100%; border-collapse: collapse; font-size: 14px; margin-top: 4px; }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
thead th, tr:first-child th { color: var(--muted); font-weight: 600; font-size: 12.5px; background: var(--bg-2); }
tr:first-child th:first-child { border-start-start-radius: var(--r-sm); } tr:first-child th:last-child { border-start-end-radius: var(--r-sm); }
tbody tr:last-child td { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
td .muted { font-size: 12.5px; }
.ok-badge, .fail-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.ok-badge { color: var(--ok); background: var(--ok-soft); } .fail-badge { color: var(--bad); background: var(--bad-soft); }
.bar { position: relative; height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 6px; width: 100%; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--ok); border-radius: 999px; }
.bar.warn i { background: var(--warn); }
.verdict { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent); margin: 12px 0 4px; }
.verdict.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.verdict .big { font-size: 30px; font-weight: 800; line-height: 1; color: var(--ok); font-variant-numeric: tabular-nums; }
.verdict.warn .big { color: var(--warn); }
.verdict div:last-child { font-size: 14px; }
.verdict b { display: block; font-size: 15px; }

/* misc */
.loading { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg) } }
.fade { animation: fade .4s ease both; } @keyframes fade { from { opacity: 0; transform: translateY(6px) } to { opacity: 1; transform: none } }
.hidden { display: none !important; }
footer { margin-top: 24px; font-size: 12.5px; color: var(--muted); text-align: center; line-height: 1.8; }
details summary { cursor: pointer; font-weight: 700; }
.about p { margin: 0 0 10px; }
@media (max-width: 600px) {
  .card { padding: 18px 16px; border-radius: 16px; }
  .brand h1 { font-size: 22px; }
  nav a { padding: 0 11px; font-size: 13.5px; }
  .ghazal-head h2 { font-size: 20px; }
}
input[type="radio"], input[type="checkbox"] { width: auto; height: auto; margin: 0 0 0 6px; vertical-align: -2px; accent-color: var(--accent); }

.draw-line { font-size: 15px; margin-bottom: 10px; padding: 10px 14px; background: var(--gold-soft); border-radius: var(--r-md); }
.share-intro { text-align: center; background: linear-gradient(160deg, var(--card), var(--gold-soft)); }
.share-intro h2 { font-size: 22px; margin: 6px 0 10px; }
.share-kicker { color: var(--gold-ink); font-weight: 700; font-size: 14px; letter-spacing: .2px; }
.share-intro .invocation { text-align: right; }

.couplet.key { background: var(--gold-soft) !important; box-shadow: inset 3px 0 0 var(--gold); }
.rich .message { font-size: 18px; font-weight: 600; }
.rich .analysis { font-size: 15.5px; line-height: 2; margin: 14px 0 8px; color: var(--ink-2); }
.keycouplet { margin: 12px 0 4px; padding: 6px 12px; border-radius: var(--r-md); background: var(--soft); }
.keycouplet .couplet { background: none !important; padding: 2px 0; font-size: 18px; }
.keycouplet .muted { font-size: 12.5px; }
.advice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0 8px; }
.advice-item { background: var(--soft); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px; font-size: 14.5px; line-height: 1.9; }
.advice-item b { display: block; margin-bottom: 4px; font-size: 14px; }
.advice-item.focus { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 45%, transparent); grid-column: 1 / -1; font-size: 15.5px; }
@media (max-width: 600px) { .advice { grid-template-columns: 1fr; } }
.timing { margin-top: 6px; }
.kw .pill { margin: 2px 0 2px 4px; }
.interp.trad { font-size: 15.5px; }
.trad2 { margin-top: 10px; } .trad2 summary { font-size: 14.5px; } .trad2 .interp { margin-top: 8px; }

.login-box { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; margin-top: 8px; }
.login-box .qr { background: #fff; border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 8px; }
.login-box .qr svg { display: block; width: 100%; height: auto; }
.login-steps ol { margin: 8px 0 0; padding-inline-start: 20px; font-size: 15px; }
.login-steps b { font-size: 17px; }
@media (max-width: 600px) { .login-box { grid-template-columns: 1fr; } .login-box .qr { max-width: 220px; margin: 0 auto; } }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 70px; margin: 8px 0 2px; direction: ltr; }
.bar-v { flex: 1; height: 100%; display: flex; align-items: flex-end; min-width: 4px; }
.bar-v i { display: block; width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }

.name-btn { font: inherit; font-weight: 700; color: var(--ink); background: none; border: 1px dashed transparent; border-radius: var(--r-sm); padding: 2px 8px; cursor: pointer; }
.name-btn:hover { border-color: var(--line-2); background: var(--soft); }
.name-btn .muted { font-size: 12px; }
.name-form { display: flex; gap: 6px; align-items: center; }
.name-form input { height: 32px; width: 180px; font-size: 14px; border-radius: var(--r-sm); }

.hist-row td { background: var(--soft); }
.hist-row .hist-item { padding: 8px 4px; }

.share-box { margin-top: 22px; padding: 18px 18px 16px; border-radius: var(--r-lg); background: linear-gradient(150deg, var(--gold-soft), var(--card) 70%); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); }
.share-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.share-head b { font-size: 17px; }
.share-icon { font-size: 26px; line-height: 1; }
.share-url { display: flex; gap: 8px; align-items: center; }
.share-url input { flex: 1; direction: ltr; text-align: left; font-size: 13.5px; height: 40px; background: var(--card); }
@media (max-width: 600px) { .share-url { flex-direction: column; align-items: stretch; } }

.analysis p { font-size: 16px; line-height: 2.05; margin: 0 0 10px; }
.analysis.pending { background: var(--soft); border-radius: var(--r-md); padding: 14px 16px; border-top: 0; }
.analysis.pending p { font-size: 15px; margin: 0; color: var(--ink-2); }

select { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 0 14px; height: 44px; }
select:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 28%, transparent); }
#forUserMsg:empty { display: none; }

/* waiting-for-analysis scene: candle + quill writing on a scroll */
.analysis.pending { text-align: center; padding: 22px 18px 18px; background: linear-gradient(160deg, var(--gold-soft), var(--soft) 70%); border: 1px solid color-mix(in srgb, var(--gold) 40%, transparent); }
.scribe { display: flex; align-items: flex-end; justify-content: center; gap: 28px; height: 96px; margin-bottom: 10px; }
.candle { position: relative; width: 22px; height: 70px; }
.candle .wax { position: absolute; bottom: 0; left: 0; width: 22px; height: 46px; border-radius: 4px 4px 3px 3px; background: linear-gradient(90deg, #f4e6c6, #e2cfa3 60%, #cdb584); box-shadow: inset 0 -6px 10px rgba(0,0,0,.08); }
.candle .wick { position: absolute; bottom: 46px; left: 10px; width: 2px; height: 7px; background: #4a3a2a; }
.candle .flame { position: absolute; bottom: 51px; left: 4px; width: 14px; height: 22px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(ellipse at 50% 70%, #fff6c2 0%, #ffc63a 45%, rgba(255,120,40,.55) 75%, transparent 100%); filter: blur(.2px); transform-origin: 50% 100%; animation: flicker 1.1s ease-in-out infinite alternate; box-shadow: 0 0 18px 6px rgba(255,180,60,.35); }
@keyframes flicker { 0% { transform: scaleX(1) scaleY(1) rotate(-2deg); opacity: .95 } 50% { transform: scaleX(.9) scaleY(1.08) rotate(2deg); opacity: 1 } 100% { transform: scaleX(1.05) scaleY(.94) rotate(-1deg); opacity: .9 } }
.scroll { position: relative; width: 190px; height: 64px; background: var(--card); border: 1px solid var(--line-2); border-radius: 6px; box-shadow: 0 6px 14px -8px rgba(0,0,0,.25); padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; align-items: flex-end; }
.ink-line { height: 4px; border-radius: 2px; background: linear-gradient(90deg, transparent, var(--ink-2) 20%, var(--ink-2)); background-size: 200% 100%; animation: write 2.4s ease-in-out infinite; }
.ink-line.w1 { width: 78%; animation-delay: 0s } .ink-line.w2 { width: 92%; animation-delay: .8s } .ink-line.w3 { width: 60%; animation-delay: 1.6s }
@keyframes write { 0% { clip-path: inset(0 0 0 100%) } 60% { clip-path: inset(0 0 0 0) } 100% { clip-path: inset(0 0 0 0) } }
.quill { position: absolute; left: 10px; bottom: 8px; font-size: 22px; animation: quill 2.4s ease-in-out infinite; transform-origin: 80% 80%; }
@keyframes quill { 0% { transform: translate(120px, -26px) rotate(-20deg) } 60% { transform: translate(6px, -2px) rotate(-14deg) } 70% { transform: translate(6px, -2px) rotate(-14deg) } 100% { transform: translate(120px, -26px) rotate(-20deg) } }
.scribe-title { justify-content: center; margin: 4px 0 6px !important; font-family: var(--nastaliq-family), "Noto Nastaliq Urdu", Vazirmatn, serif; font-size: 20px; line-height: 2; }
.scribe-verse { font-size: 15.5px; color: var(--ink-2); max-width: 560px; margin: 0 auto 6px; line-height: 2; }
.scribe-note { font-size: 13px; }
@media (prefers-reduced-motion: reduce) { .flame, .ink-line, .quill { animation: none } }

.waiting-card { padding: 8px; }
.waiting-card .analysis.pending { margin-top: 0; border: 0; border-radius: 16px; padding: 34px 20px 28px; }
.waiting-card .scribe { height: 110px; margin-bottom: 14px; }
.waiting-card .scribe-title { font-size: 24px; }
.waiting-card .scribe-verse { margin: 2px auto; }
.waiting-card .scribe-note { margin-top: 10px; }

.scribe-text { max-width: 440px; margin: 6px auto 0; text-align: right; font-size: 15.5px; line-height: 2.1; color: var(--ink-2); }
.waiting-card .scribe-text { margin-top: 10px; }

/* waiting scene v2: a single candle with a breathing glow */
.scene { position: relative; height: 150px; display: flex; align-items: flex-end; justify-content: center; margin: 4px auto 6px; }
.scene .glow { position: absolute; left: 50%; bottom: 10px; width: 260px; height: 160px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(ellipse at 50% 70%, rgba(255,190,80,.28), rgba(255,190,80,.08) 45%, transparent 70%); animation: breathe 3.2s ease-in-out infinite; pointer-events: none; }
@keyframes breathe { 0%, 100% { opacity: .75; transform: translateX(-50%) scale(.96) } 50% { opacity: 1; transform: translateX(-50%) scale(1.04) } }
.scene .candle { position: relative; width: 26px; height: 112px; }
.scene .candle .wax { position: absolute; bottom: 0; left: 0; width: 26px; height: 78px; border-radius: 5px 5px 4px 4px; background: linear-gradient(90deg, #f6e9cb, #e6d3a6 60%, #cfb88a); box-shadow: inset 0 -8px 12px rgba(0,0,0,.08); }
.scene .candle .wick { position: absolute; bottom: 78px; left: 12px; width: 2px; height: 9px; background: #4a3a2a; }
.scene .candle .flame { position: absolute; bottom: 85px; left: 5px; width: 16px; height: 27px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(ellipse at 50% 70%, #fff6c2 0%, #ffc63a 45%, rgba(255,120,40,.55) 75%, transparent 100%); transform-origin: 50% 100%; animation: flicker 1.1s ease-in-out infinite alternate; box-shadow: 0 0 22px 8px rgba(255,180,60,.35); }
.waiting-card .analysis.pending { padding: 36px 24px 30px; }
.waiting-card .scribe-title { font-size: 26px; margin: 2px 0 4px !important; }
.waiting-card .scribe-text { max-width: 480px; margin: 10px auto 0; font-size: 16px; }

/* ===== waiting scene v3 (pixel-tuned, centered) ===== */
.waiting-card { padding: 6px; overflow: hidden; }
.waiting-card .analysis.pending {
  position: relative; margin: 0; border: 0; border-radius: 18px; padding: 40px 24px 36px; text-align: center;
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--gold) 22%, var(--card)) 0%, var(--card) 55%, color-mix(in srgb, var(--accent) 6%, var(--card)) 100%);
}
.waiting-card .scene { position: relative; height: 190px; margin: 0 auto 6px; display: flex; align-items: flex-end; justify-content: center; }
.waiting-card .scene .glow { position: absolute; left: 50%; bottom: 0; width: 340px; height: 220px; transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(ellipse at 50% 72%, rgba(255,196,96,.42), rgba(255,196,96,.14) 42%, transparent 70%); animation: breathe 3.4s ease-in-out infinite; pointer-events: none; filter: blur(2px); }
.waiting-card .scene .candle { position: relative; width: 30px; height: 132px; z-index: 2; }
.waiting-card .scene .candle .wax { position: absolute; bottom: 0; left: 0; width: 30px; height: 90px; border-radius: 6px 6px 5px 5px;
  background: linear-gradient(90deg, #f9efd6 0%, #efe0bd 45%, #d8c197 75%, #c9b084 100%); box-shadow: inset 0 -10px 14px rgba(0,0,0,.08), 0 10px 24px -10px rgba(0,0,0,.45); }
.waiting-card .scene .candle .wax::before { content: ""; position: absolute; top: -3px; left: 2px; right: 2px; height: 7px; border-radius: 50%; background: #fbf2dc; box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
.waiting-card .scene .candle .wick { position: absolute; bottom: 92px; left: 14px; width: 2px; height: 10px; background: #3b2d20; border-radius: 1px; }
.waiting-card .scene .candle .flame { position: absolute; bottom: 100px; left: 6px; width: 18px; height: 32px; z-index: 3;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 72%, #fffbe6 0%, #ffe08a 30%, #ffb02e 58%, rgba(255,110,30,.6) 80%, transparent 100%);
  transform-origin: 50% 100%; animation: flicker 1.15s ease-in-out infinite alternate; filter: drop-shadow(0 0 6px rgba(255,190,80,.8)); }
.waiting-card .scene .candle .halo { position: absolute; bottom: 92px; left: -26px; width: 82px; height: 82px; border-radius: 50%; z-index: 1;
  background: radial-gradient(circle, rgba(255,210,120,.55) 0%, rgba(255,190,80,.18) 45%, transparent 70%); animation: breathe 2.2s ease-in-out infinite; }
.waiting-card .sparks { position: absolute; inset: 0; pointer-events: none; }
.waiting-card .sparks i { position: absolute; left: var(--x); bottom: 70px; width: 4px; height: 4px; border-radius: 50%; background: #ffd27a; opacity: 0;
  box-shadow: 0 0 8px 2px rgba(255,200,100,.6); animation: rise var(--t) linear infinite; animation-delay: var(--d); }
@keyframes rise { 0% { transform: translateY(0) scale(.6); opacity: 0 } 15% { opacity: .9 } 60% { opacity: .5 } 100% { transform: translateY(-150px) translateX(10px) scale(1); opacity: 0 } }
.waiting-card .ornament { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 10px auto 10px; width: min(360px, 80%); }
.waiting-card .ornament span { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--gold) 70%, transparent), transparent); }
.waiting-card .ornament b { color: var(--gold); font-size: 13px; line-height: 1; animation: twinkle 2.6s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: .55; transform: scale(.9) } 50% { opacity: 1; transform: scale(1.15) } }
.waiting-card .scribe-title { display: block; margin: 0 0 10px !important; font-size: 30px; line-height: 2.2; color: var(--ink);
  text-shadow: 0 0 22px color-mix(in srgb, var(--gold) 45%, transparent); animation: fadeUp .9s ease both; }
.waiting-card .scribe-lines { max-width: 520px; margin: 0 auto; }
.waiting-card .scribe-lines p { margin: 0; font-size: 16px; line-height: 2.2; color: var(--ink-2); text-align: center; text-wrap: balance;
  animation: fadeUp .8s ease both; animation-delay: calc(.25s + var(--i) * .25s); }
.waiting-card .scribe-lines p + p { margin-top: 2px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
.waiting-card .dots { display: flex; justify-content: center; gap: 8px; margin-top: 22px; }
.waiting-card .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); opacity: .35; animation: pulse 1.5s ease-in-out infinite; }
.waiting-card .dots i:nth-child(2) { animation-delay: .25s } .waiting-card .dots i:nth-child(3) { animation-delay: .5s }
@keyframes pulse { 0%, 100% { opacity: .3; transform: scale(.85) } 50% { opacity: 1; transform: scale(1.15) } }
@media (max-width: 600px) { .waiting-card .scribe-title { font-size: 25px; } .waiting-card .scene { height: 170px; } .waiting-card .scribe-lines p { font-size: 15px; } }
@media (prefers-reduced-motion: reduce) { .waiting-card * { animation: none !important; } }

/* ===== waiting scene v3 (pixel-tuned, centered) ===== */
.waiting-card { padding: 6px; overflow: hidden; }
.waiting-card .analysis.pending {
  position: relative; margin: 0; border: 0; border-radius: 18px; padding: 40px 24px 36px; text-align: center;
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--gold) 22%, var(--card)) 0%, var(--card) 55%, color-mix(in srgb, var(--accent) 6%, var(--card)) 100%);
}
.waiting-card .scene { position: relative; height: 190px; margin: 0 auto 6px; display: flex; align-items: flex-end; justify-content: center; }
.waiting-card .scene .glow { position: absolute; left: 50%; bottom: 0; width: 340px; height: 220px; transform: translateX(-50%); border-radius: 50%;
  background: radial-gradient(ellipse at 50% 72%, rgba(255,196,96,.42), rgba(255,196,96,.14) 42%, transparent 70%); animation: breathe 3.4s ease-in-out infinite; pointer-events: none; filter: blur(2px); }
.waiting-card .scene .candle { position: relative; width: 30px; height: 132px; z-index: 2; }
.waiting-card .scene .candle .wax { position: absolute; bottom: 0; left: 0; width: 30px; height: 90px; border-radius: 6px 6px 5px 5px;
  background: linear-gradient(90deg, #f9efd6 0%, #efe0bd 45%, #d8c197 75%, #c9b084 100%); box-shadow: inset 0 -10px 14px rgba(0,0,0,.08), 0 10px 24px -10px rgba(0,0,0,.45); }
.waiting-card .scene .candle .wax::before { content: ""; position: absolute; top: -3px; left: 2px; right: 2px; height: 7px; border-radius: 50%; background: #fbf2dc; box-shadow: inset 0 1px 2px rgba(0,0,0,.08); }
.waiting-card .scene .candle .wick { position: absolute; bottom: 92px; left: 14px; width: 2px; height: 10px; background: #3b2d20; border-radius: 1px; }
.waiting-card .scene .candle .flame { position: absolute; bottom: 100px; left: 6px; width: 18px; height: 32px; z-index: 3;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(ellipse at 50% 72%, #fffbe6 0%, #ffe08a 30%, #ffb02e 58%, rgba(255,110,30,.6) 80%, transparent 100%);
  transform-origin: 50% 100%; animation: flicker 1.15s ease-in-out infinite alternate; filter: drop-shadow(0 0 6px rgba(255,190,80,.8)); }
.waiting-card .scene .candle .halo { position: absolute; bottom: 92px; left: -26px; width: 82px; height: 82px; border-radius: 50%; z-index: 1;
  background: radial-gradient(circle, rgba(255,210,120,.55) 0%, rgba(255,190,80,.18) 45%, transparent 70%); animation: breathe 2.2s ease-in-out infinite; }
.waiting-card .sparks { position: absolute; inset: 0; pointer-events: none; }
.waiting-card .sparks i { position: absolute; left: var(--x); bottom: 70px; width: 4px; height: 4px; border-radius: 50%; background: #ffd27a; opacity: 0;
  box-shadow: 0 0 8px 2px rgba(255,200,100,.6); animation: rise var(--t) linear infinite; animation-delay: var(--d); }
@keyframes rise { 0% { transform: translateY(0) scale(.6); opacity: 0 } 15% { opacity: .9 } 60% { opacity: .5 } 100% { transform: translateY(-150px) translateX(10px) scale(1); opacity: 0 } }
.waiting-card .ornament { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 10px auto 10px; width: min(360px, 80%); }
.waiting-card .ornament span { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--gold) 70%, transparent), transparent); }
.waiting-card .ornament b { color: var(--gold); font-size: 13px; line-height: 1; animation: twinkle 2.6s ease-in-out infinite; }
@keyframes twinkle { 0%, 100% { opacity: .55; transform: scale(.9) } 50% { opacity: 1; transform: scale(1.15) } }
.waiting-card .scribe-title { display: block; margin: 0 0 10px !important; font-size: 30px; line-height: 2.2; color: var(--ink);
  text-shadow: 0 0 22px color-mix(in srgb, var(--gold) 45%, transparent); animation: fadeUp .9s ease both; }
.waiting-card .scribe-lines { max-width: 520px; margin: 0 auto; }
.waiting-card .scribe-lines p { margin: 0; font-size: 16px; line-height: 2.2; color: var(--ink-2); text-align: center; text-wrap: balance;
  animation: fadeUp .8s ease both; animation-delay: calc(.25s + var(--i) * .25s); }
.waiting-card .scribe-lines p + p { margin-top: 2px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: none } }
.waiting-card .dots { display: flex; justify-content: center; gap: 8px; margin-top: 22px; }
.waiting-card .dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); opacity: .35; animation: pulse 1.5s ease-in-out infinite; }
.waiting-card .dots i:nth-child(2) { animation-delay: .25s } .waiting-card .dots i:nth-child(3) { animation-delay: .5s }
@keyframes pulse { 0%, 100% { opacity: .3; transform: scale(.85) } 50% { opacity: 1; transform: scale(1.15) } }
@media (max-width: 600px) { .waiting-card .scribe-title { font-size: 25px; } .waiting-card .scene { height: 170px; } .waiting-card .scribe-lines p { font-size: 15px; } }
@media (prefers-reduced-motion: reduce) { .waiting-card * { animation: none !important; } }

.hist-item { grid-template-columns: 52px 1fr auto; }
.hist-actions { align-self: center; }
.hist-item.is-archived { opacity: .7; }
details.archived { margin-top: 18px; padding-top: 10px; border-top: 1px dashed var(--line-2); }
details.archived summary { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
@media (max-width: 600px) { .hist-item { grid-template-columns: 52px 1fr; } .hist-actions { grid-column: 2; justify-self: start; } }
.stat { text-align: center; }
.stat b { text-align: center; }

/* ===== responsive hardening: nothing overflows the viewport ===== */
html, body { max-width: 100%; overflow-x: hidden; }
img, svg, video { max-width: 100%; height: auto; }
input, select, textarea, button { min-width: 0; max-width: 100%; }
.card { min-width: 0; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 6px 0 4px; border-radius: var(--r-sm); scrollbar-width: thin; }
.table-scroll table { min-width: 520px; margin-top: 0; }
.table-scroll td, .table-scroll th { white-space: nowrap; }
.table-scroll td .muted { white-space: normal; min-width: 180px; display: inline-block; }
.table-scroll .row { flex-wrap: nowrap; }
@media (max-width: 600px) {
  .wrap { padding: 12px 12px 40px; }
  header { padding-bottom: 14px; }
  nav { width: 100%; justify-content: space-between; }
  nav a { flex: 1; justify-content: center; padding: 0 6px; }
  .user-chip { width: 100%; justify-content: flex-end; flex-wrap: wrap; gap: 6px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .verdict { flex-direction: column; align-items: flex-start; }
  .share-box { padding: 14px 12px; }
  .login-box .qr { max-width: 200px; }
  .row { gap: 6px; }
  .btn { padding: 0 14px; }
  .hist-item { grid-template-columns: 44px 1fr; gap: 4px 10px; }
  .hist-item .n { height: 38px; font-size: 16px; }
  .hist-actions { grid-column: 2; justify-self: start; }
}

.name-cell { display: flex; align-items: center; gap: 6px; }
.icon-btn { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); font: inherit; font-size: 15px; line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--soft); color: var(--ink); }
.icon-btn.ok { color: var(--ok); } .icon-btn.bad { color: var(--bad); }
.row.icons { gap: 6px; flex-direction: row; }
.table-scroll table.users { min-width: 640px; }

.inline-msg { font-size: 12.5px; margin-inline-start: 6px; }

/* landing hero (logged-out) */
.hero { text-align: center; padding-top: 10px; overflow: hidden; }
.hero .hero-scene { position: relative; height: 150px; margin: 0 auto 4px; display: flex; align-items: flex-end; justify-content: center; }
.hero .hero-scene .glow { position: absolute; left: 50%; bottom: 0; width: 320px; height: 190px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(closest-side, rgba(255,196,96,.42), rgba(255,196,96,.12) 55%, transparent 75%); }
.hero .hero-scene .candle { position: relative; width: 26px; height: 112px; z-index: 2; }
.hero .hero-scene .candle .wax { position: absolute; bottom: 0; left: 0; width: 26px; height: 76px; border-radius: 6px 6px 5px 5px; background: linear-gradient(90deg, #efe3c9, #fbf3df 45%, #e2d3b4); box-shadow: 0 6px 14px rgba(0,0,0,.12); }
.hero .hero-scene .candle .wax::before { content: ""; position: absolute; top: -3px; left: 2px; right: 2px; height: 6px; border-radius: 50%; background: #fbf2dc; }
.hero .hero-scene .candle .wick { position: absolute; bottom: 78px; left: 12px; width: 2px; height: 9px; background: #3b2d20; border-radius: 1px; }
.hero .hero-scene .candle .flame { position: absolute; bottom: 85px; left: 5px; width: 16px; height: 28px; z-index: 3; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: radial-gradient(ellipse at 50% 70%, #fff6d8 0 18%, #ffcf5a 40%, #ff8a2a 75%, transparent 78%); transform-origin: 50% 100%; animation: flicker 1.6s ease-in-out infinite; }
.hero .hero-scene .candle .halo { position: absolute; bottom: 78px; left: -24px; width: 74px; height: 74px; border-radius: 50%; z-index: 1; background: radial-gradient(circle, rgba(255,210,120,.55), transparent 70%); animation: breathe 2.2s ease-in-out infinite; }
.hero .hero-scene .sparks { position: absolute; inset: 0; pointer-events: none; }
.hero .ornament { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 6px auto 4px; width: min(360px, 80%); }
.hero .ornament span { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--gold) 70%, transparent), transparent); }
.hero .ornament b { color: var(--gold); font-size: 13px; line-height: 1; animation: twinkle 2.6s ease-in-out infinite; }
.hero .hero-scene .sparks i { position: absolute; bottom: 10px; left: var(--x); width: 3px; height: 3px; border-radius: 50%; background: #ffd27a; opacity: 0; box-shadow: 0 0 8px 2px rgba(255,200,100,.6); animation: rise var(--t) linear infinite; animation-delay: var(--d); }
.hero-title { font-family: var(--nastaliq-family), "Noto Nastaliq Urdu", Vazirmatn, serif; font-weight: 400; font-size: 27px; line-height: 2.1; margin: 4px 0 2px; color: var(--ink); }
.hero-lead { max-width: 560px; margin: 0 auto 16px; font-size: 16px; line-height: 2; color: var(--ink-2); }
.hero-text { max-width: 600px; margin: 4px auto 18px; padding: 16px 20px; background: var(--gold-soft); border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent); border-radius: var(--r-md); text-align: right; }
.hero-text p { margin: 0; font-size: 16px; line-height: 2.1; color: var(--ink-2); }
.hero-text p + p { margin-top: 10px; padding-top: 10px; border-top: 1px dashed color-mix(in srgb, var(--gold) 40%, transparent); }
.hero .hero-cta { justify-content: center; flex-direction: row; }
.hero .hero-cta .btn { height: 46px; font-size: 16px; padding: 0 22px; }
.hero-note { margin: 12px 0 0; font-size: 13px; }
@media (max-width: 600px) {
  header { padding-bottom: 10px; }
  .hero { padding: 4px 12px 12px; }
  .hero .hero-scene { height: 74px; margin-bottom: 0; }
  .hero .hero-scene .glow { width: 220px; height: 110px; }
  .hero .hero-scene .candle { width: 18px; height: 60px; }
  .hero .hero-scene .candle .wax { width: 18px; height: 38px; }
  .hero .hero-scene .candle .wick { bottom: 40px; left: 8px; height: 6px; }
  .hero .hero-scene .candle .flame { bottom: 45px; left: 3px; width: 12px; height: 20px; }
  .hero .hero-scene .candle .halo { bottom: 40px; left: -19px; width: 56px; height: 56px; }
  .hero .ornament { margin: 0 auto; }
  .hero-title { font-size: 18px; line-height: 1.8; margin: 0; }
  .hero-lead { font-size: 13.5px; line-height: 1.75; margin-bottom: 8px; }
  .hero-text { padding: 10px 12px; margin: 0 auto 10px; }
  .hero-text p { font-size: 14px; line-height: 1.8; }
  .hero-text p + p { margin-top: 6px; padding-top: 6px; }
  .hero .hero-cta { flex-direction: column; gap: 6px; } .hero .hero-cta .btn { width: 100%; height: 42px; font-size: 15px; }
  .hero-note { margin-top: 8px; font-size: 12px; }
}
/* waiting-only mode: nothing but the scene while the analysis is being written */
body.waiting-only header, body.waiting-only footer { display: none; }
body.waiting-only .wrap { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding-top: 12px; padding-bottom: 12px; }
body.waiting-only main { width: 100%; }
/* settings form */
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 10px 0 0 14px; font-weight: 600; }
label.inline input { margin: 0; }
hr { border: 0; border-top: 1px dashed var(--line-2); margin: 20px 0 14px; }
.email-login input[type="email"], .email-login #codeInput { direction: ltr; text-align: left; }
.email-login #codeInput { font-size: 22px; letter-spacing: 8px; text-align: center; max-width: 220px; }
.hist-item.is-given .n { background: var(--ok-soft); color: var(--ok); }
/* share box: equal icon buttons */
.share-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 8px; margin-top: 12px; }
.share-ic { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 64px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, transform .08s, border-color .15s; }
.share-ic svg { width: 22px; height: 22px; fill: currentColor; }
.share-ic:hover { background: var(--soft); color: var(--ink); border-color: var(--gold); text-decoration: none; }
.share-ic:active { transform: translateY(1px); }
.share-ic#shareNative { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.share-ic#shareNative:hover { background: var(--accent-2); }

/* feedback */
.feedback { margin-top: 18px; padding: 14px 16px; border-radius: var(--r-md); background: var(--soft); border: 1px solid var(--line); }
.feedback .fb-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.feedback .fb-head b { font-size: 15.5px; }
.feedback .small { font-size: 13px; }
.stars { display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 4px; margin: 4px 0 10px; }
.star { width: 36px; height: 36px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--line-2); transition: transform .1s, color .15s; }
.star svg { width: 28px; height: 28px; fill: currentColor; }
.star:hover { transform: scale(1.12); }
.star.on { color: var(--gold); }
.feedback .fb-text { min-height: 64px; height: 64px; font-size: 14.5px; }
.feedback .row { margin-top: 10px; }
.fb-thanks { padding: 6px 0; font-weight: 600; color: var(--ok); }
.site-feedback { margin: 10px 0 0; text-align: center; }
.site-feedback .btn { margin: 0 auto; }
.site-feedback .feedback { text-align: right; margin-top: 12px; }
.stars-ro { display: inline-flex; gap: 1px; color: var(--line-2); }
.stars-ro i { display: inline-flex; } .stars-ro svg { width: 14px; height: 14px; fill: currentColor; } .stars-ro i.on { color: var(--gold); }
.fb-text-cell { max-width: 360px; white-space: normal; line-height: 1.8; }
@media (max-width: 600px) { .star { width: 40px; height: 40px; } .star svg { width: 30px; height: 30px; } }
/* admin text editor */
.text-field { margin-top: 14px; }
.text-field label { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.md-toolbar { display: flex; gap: 4px; margin: 4px 0 6px; flex-direction: row; }
.md-toolbar button { height: 30px; min-width: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); font: inherit; font-size: 13px; cursor: pointer; }
.md-toolbar button:hover, .md-toolbar button.active { background: var(--soft); color: var(--ink); }
.md-toolbar .sep { flex: 1; }
.text-field textarea { min-height: 0; height: auto; line-height: 1.9; font-size: 14.5px; }
.md-preview { margin-top: 8px; padding: 12px 14px; background: var(--gold-soft); border: 1px dashed color-mix(in srgb, var(--gold) 50%, transparent); border-radius: var(--r-md); font-size: 15px; }
.md-preview p, .about p { margin: 0 0 10px; }
.md-preview ul, .md-preview ol, .about ul, .about ol { margin: 0 0 10px; padding-right: 22px; }
.md-preview h2, .md-preview h3, .md-preview h4 { margin: 8px 0 6px; font-size: 17px; }
.hero-text ul, .hero-text ol { margin: 6px 0; padding-right: 20px; }
.hero-text h2, .hero-text h3, .hero-text h4 { margin: 4px 0 6px; font-size: 17px; }
.icon-btn svg { width: 15px; height: 15px; fill: currentColor; }
code { background: var(--soft); padding: 1px 6px; border-radius: 6px; font-size: 13px; direction: ltr; unicode-bidi: embed; }
/* fal form: segmented target choice, compact on phones */
.seg { display: flex; gap: 6px; margin: 12px 0 10px; }
.seg-btn { flex: 1; height: 40px; border-radius: var(--r-md); border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s, color .15s, border-color .15s; white-space: nowrap; }
.seg-btn:hover { background: var(--soft); color: var(--ink); }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.fal-form #forOther, .fal-form #forSite { margin: 0 0 14px; }
.fal-form #forOther input, .fal-form #forSite input, .fal-form #forSite select { margin-top: 2px; }
.fal-form #forSite .small { margin-top: 6px; }
.fal-form .small { font-size: 13px; }
.fal-form textarea { min-height: 120px; line-height: 1.8; }
.fal-form .row { margin-top: 14px; }
@media (max-width: 600px) {
  .fal-form { padding: 16px 14px; }
  .fal-form h2 { font-size: 20px; margin: 0 0 10px; }
  .fal-form .invocation { font-size: 14px; line-height: 1.8; padding: 10px 12px; margin: 0 0 6px; }
  .seg { margin: 12px 0 12px; } .seg-btn { height: 40px; font-size: 13.5px; }
  .fal-form #forOther, .fal-form #forSite { margin-bottom: 12px; }
  .fal-form textarea { min-height: 104px; height: 104px; }
  .fal-form .row { margin-top: 14px; gap: 10px; }
  .fal-form .small { font-size: 12.5px; }
}

/* spacing pass: consistent rhythm for card intros, sub-headings and the login box */
.card > h2 + p, .card > h2 + p.muted { margin: -2px 0 14px; line-height: 1.85; }
.card h3 { margin: 20px 0 8px; font-size: 17px; line-height: 1.5; }
.section h3 { margin: 0 0 12px; }
.card > .stats:first-child { margin-top: 0; }
#loginCard p.muted + p.muted { margin-top: -6px; }
.login-box { margin-top: 14px; gap: 22px; }
.login-box .qr { padding: 10px; }
.login-steps > b { display: block; font-size: 17px; margin: 2px 0 6px; }
.login-steps li b { display: inline; font-size: inherit; margin: 0; }
.login-steps ol { margin: 0 0 6px; line-height: 1.95; }
.login-steps li { margin-bottom: 4px; }
.login-steps li:last-child { margin-bottom: 0; }
.login-steps .row { margin-top: 12px; }
.login-steps #loginStatus { margin: 10px 0 0; line-height: 1.8; }
.email-login label:first-child { margin-top: 6px; }
.email-login .row { margin-top: 12px; }
.email-login #emailMsg, .email-login #codeMsg { margin-top: 8px; line-height: 1.8; }
.email-login #codeMsg:empty, .email-login #emailMsg:empty { display: none; }
@media (max-width: 600px) {
  .login-box { gap: 14px; margin-top: 10px; }
  .login-box .qr { max-width: 168px; padding: 7px; }
  .login-steps ol { font-size: 14.5px; padding-inline-start: 18px; }
  .login-steps > b { font-size: 16px; }
  .card h3 { margin-top: 16px; font-size: 16.5px; }
}
.analysis-actions { margin-top: 10px; }
.analysis-actions .small { font-size: 13px; }
.btn.pulse { animation: btnpulse 1.3s ease-in-out 2; }
@keyframes btnpulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 50% { box-shadow: 0 0 0 10px transparent; } }
/* logged-out: no top menu */
body.no-nav #nav { display: none; }
body.no-nav header { padding-bottom: 12px; }

/* IranNastaliq sits ~1.5x smaller than Noto Nastaliq at the same size: scale every Nastaliq element */
.couplet { font-size: 30px; line-height: 2.1; padding: 8px 12px; }
.shahed .couplet { font-size: 27px; }
.keycouplet .couplet { font-size: 27px; }
.ghazal-head h2 { font-size: 34px; line-height: 1.9; }
.hist-item .line { font-size: 25px; line-height: 1.9; }
.scribe-title { font-size: 32px; }
.waiting-card .scribe-title { font-size: 44px; line-height: 1.9; }
.hero-title { font-size: 40px; line-height: 1.9; }
@media (max-width: 600px) {
  .couplet { font-size: 26px; line-height: 2.05; }
  .shahed .couplet, .keycouplet .couplet { font-size: 24px; }
  .ghazal-head h2 { font-size: 30px; }
  .hist-item .line { font-size: 22px; }
  .waiting-card .scribe-title { font-size: 36px; }
  .hero-title { font-size: 28px; line-height: 1.8; }
}

/* Nastaliq sizes = Noto-tuned base × --ns (per-font multiplier chosen in admin settings) */
.couplet { font-size: calc(20px * var(--ns)); line-height: 2.1; padding: 8px 12px; }
.shahed .couplet, .keycouplet .couplet { font-size: calc(18px * var(--ns)); }
.ghazal-head h2 { font-size: calc(22px * var(--ns)); line-height: 1.9; }
.hist-item .line { font-size: calc(17px * var(--ns)); line-height: 1.9; }
.scribe-title { font-size: calc(20px * var(--ns)); }
.waiting-card .scribe-title { font-size: calc(30px * var(--ns)); line-height: 1.9; }
.hero-title { font-size: calc(27px * var(--ns)); line-height: 1.9; }
.font-preview { font-family: var(--nastaliq-family), "Noto Nastaliq Urdu", Vazirmatn, serif; font-size: calc(22px * var(--ns)); line-height: 1.9; text-align: center; padding: 10px 12px; background: var(--gold-soft); border-radius: var(--r-md); margin: 8px 0 4px; }
@media (max-width: 600px) {
  .couplet { font-size: calc(18px * var(--ns)); line-height: 2.05; }
  .shahed .couplet, .keycouplet .couplet { font-size: calc(16px * var(--ns)); }
  .ghazal-head h2 { font-size: calc(20px * var(--ns)); }
  .hist-item .line { font-size: calc(15px * var(--ns)); }
  .waiting-card .scribe-title { font-size: calc(25px * var(--ns)); }
  .hero-title { font-size: calc(18px * var(--ns)); line-height: 1.8; }
}

/* verses: one hemistich per line, as large as the line allows (JS shrinks to fit) */
.couplet span { display: block; white-space: nowrap; overflow: visible; padding: 0.18em 0; }
@media (max-width: 600px) {
  .couplet { font-size: calc(26px * var(--ns)); line-height: var(--nlh, 2.2); padding: 8px 10px; }
  .couplet span { text-align: center; }
  .couplet span:nth-child(2) { padding-right: 0; }
  .shahed .couplet, .keycouplet .couplet { font-size: calc(22px * var(--ns)); }
}
@media (min-width: 601px) {
  .couplet { font-size: calc(24px * var(--ns)); line-height: var(--nlh, 2.2); }
}
.couplet span { text-align: center; }
.font-preview { line-height: var(--nlh, 2.2); }
.ghazal-head h2, .hero-title, .waiting-card .scribe-title, .hist-item .line { line-height: calc(var(--nlh, 2.2) * 0.9); }
.moment { margin: -6px 0 10px; }
.moment-head { display: flex; flex-direction: row-reverse; justify-content: flex-start; align-items: center; gap: 8px; margin-bottom: 6px; }
.moment .chips { display: flex; flex-direction: row-reverse; justify-content: flex-start; flex-wrap: wrap; gap: 6px; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); color: var(--ink-2); font: inherit; font-size: 13.5px; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.chip:hover { background: var(--soft); color: var(--ink); }
.chip.occasion { border-color: var(--accent); color: var(--accent); }
.chip.sober { border-color: var(--line-2); color: var(--muted); }
.chip.place { border-style: dashed; }
.chip.locate { color: var(--muted); }
.chip.dismiss { height: 22px; width: 22px; padding: 0; line-height: 1; color: var(--muted); border: 0; background: transparent; font-size: 16px; }
.chip.dismiss:hover { color: var(--ink); background: var(--soft); }
