:root {
  --cream: #FAF6EE;
  --cream-2: #F2EBDB;
  --paper: #FDFAF3;
  --olive-text: #2B3324;
  --olive-soft: #6B8E50;
  --terracotta: #C97D5B;
  --terracotta-dark: #A85F3F;
  --terracotta-deep: #8E4A2E;
  --muted: #8B8273;
  --error: #B0644A;
  --error-bg: rgba(176, 100, 74, 0.08);

  /* Verdict tier accent + deeper "ink" colors for tiered list items.
     Allowed reuses --olive-soft, forbidden reuses --terracotta. */
  --tier-moderation: #B8893F;
  --ink-allowed:    #3D5226;
  --ink-moderation: #7A5A1F;
  --ink-forbidden:  #A85F3F;

  --serif: 'Fraunces', 'Hoefler Text', 'Georgia', serif;
  --sans: 'Instrument Sans', -apple-system, 'Segoe UI', sans-serif;
  --arabic: 'Tajawal', sans-serif;
}

* { box-sizing: border-box; }

/* The HTML `hidden` attribute must win over class rules that set
   display:flex/inline-flex (e.g. .activate-msg, .support-thanks), which
   otherwise override the UA [hidden]{display:none} and leak empty boxes. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  color: var(--olive-text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px 20px 48px;
  display: flex;
  flex-direction: column;
  position: relative;
  background:
    radial-gradient(ellipse 900px 500px at 95% -5%, rgba(201, 125, 91, 0.10), transparent 55%),
    radial-gradient(ellipse 900px 500px at -5% 100%, rgba(107, 142, 80, 0.08), transparent 55%),
    var(--cream);
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: url('/noise.svg');
  background-size: 240px 240px;
  opacity: 0.55;
  mix-blend-mode: multiply;
}

.wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 680px;
  width: 100%;
  margin-inline: auto;
  position: relative;
  z-index: 1;
}

/* --- Header (asymmetric) --- */

header {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 20px;
  align-items: start;
  padding: 44px 0 28px;
}

.logo {
  font-family: var(--arabic);
  font-size: 92px;
  font-weight: 700;
  color: var(--terracotta);
  line-height: 0.85;
  text-shadow: 0 2px 24px rgba(201, 125, 91, 0.18);
  user-select: none;
}

.title-block { padding-top: 10px; }

h1 {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-variation-settings: 'SOFT' 60, 'WONK' 1;
  font-size: 44px;
  font-weight: 500;
  margin: 0 0 8px;
  letter-spacing: -0.02em;
  line-height: 1;
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.title-ar {
  font-family: var(--arabic);
  font-size: 30px;
  font-weight: 500;
  color: var(--terracotta);
  letter-spacing: 0;
}

.olive-branch {
  width: 100px;
  height: auto;
  align-self: center;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 2px rgba(107, 142, 80, 0.18));
}

@media (max-width: 540px) {
  .olive-branch { width: 72px; }
}

.sub {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
  font-style: italic;
  font-family: var(--serif);
  font-weight: 400;
}

.sub-ar {
  font-family: var(--arabic);
  font-size: 15px;
  margin: 4px 0 0;
  color: var(--muted);
  text-align: left;
}

/* --- Input box --- */

.box {
  position: relative;
  background: var(--paper);
  border: 1px solid rgba(43, 51, 36, 0.08);
  border-radius: 14px;
  padding-block: 14px;
  padding-inline-start: 18px;
  padding-inline-end: 56px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 6px 24px rgba(43, 51, 36, 0.05),
    0 2px 6px rgba(201, 125, 91, 0.03);
  margin: 22px 0 18px;
  transition: border-color .2s, box-shadow .2s;
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.box:focus-within {
  border-color: rgba(201, 125, 91, 0.35);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.8) inset,
    0 8px 28px rgba(201, 125, 91, 0.10),
    0 0 0 3px rgba(201, 125, 91, 0.06);
}

textarea {
  display: block;
  flex: 1;
  width: 100%;
  min-height: 26px;
  max-height: 200px;
  border: 0;
  outline: 0;
  resize: none;
  font-family: var(--arabic), var(--sans);
  font-size: 16px;
  color: var(--olive-text);
  background: transparent;
  direction: rtl;
  text-align: right;
  line-height: 1.5;
  padding: 0;
}

textarea[dir="ltr"] {
  direction: ltr;
  text-align: left;
  font-family: var(--sans), var(--arabic);
}

textarea::placeholder { color: #B8AF9D; opacity: 1; }

button.send {
  position: absolute;
  bottom: 10px;
  inset-inline-end: 10px;
  background: var(--terracotta);
  color: #FFF;
  border: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s, box-shadow .15s, opacity .15s;
  box-shadow:
    0 3px 10px rgba(201, 125, 91, 0.30),
    0 1px 0 rgba(255, 255, 255, 0.22) inset;
}

button.send svg { display: block; }

button.send:hover:not(:disabled) {
  background: var(--terracotta-dark);
  box-shadow:
    0 5px 16px rgba(201, 125, 91, 0.40),
    0 1px 0 rgba(255, 255, 255, 0.22) inset;
}
button.send:active:not(:disabled) { transform: translateY(1px); }
button.send:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* --- Suggestion chips --- */

.suggestions {
  margin: 8px 0 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}

.suggestions[hidden] { display: none; }

/* When suggestions follow a visible answer, add a breathing separator */
#answer-section:not([hidden]) ~ .suggestions {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px dashed rgba(43, 51, 36, 0.10);
}

.sug-label {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.01em;
  padding-inline-start: 2px;
}

.chips {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 8px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 4px;
}

.chips::-webkit-scrollbar { display: none; }

/* Fade only the END side (where overflow extends), direction-aware */
.chips[dir="ltr"] {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
}

.chips[dir="rtl"] {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to left, #000 calc(100% - 24px), transparent);
}

.chip {
  background: transparent;
  border: 1px solid rgba(201, 125, 91, 0.30);
  color: var(--olive-text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13.5px;
  font-family: var(--sans);
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
  flex-shrink: 0;
}

.chip-ar {
  font-family: var(--arabic);
  font-size: 15px;
  font-weight: 500;
}

.chip:hover {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: #FFF;
}

/* --- Answer --- */

.answer-section {
  margin-top: 28px;
  position: relative;
}

.answer-card {
  background:
    linear-gradient(180deg, #FEFCF6 0%, #FBF7EB 100%);
  border: 1px solid rgba(201, 125, 91, 0.16);
  border-radius: 16px;
  padding: 30px 36px 22px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 14px 40px rgba(43, 51, 36, 0.06),
    0 3px 10px rgba(201, 125, 91, 0.04);
  position: relative;
  transition: box-shadow 0.45s ease, border-color 0.45s ease;
  /* fade/slide in when shown */
  animation: card-rise 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes card-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.answer-section.streaming .answer-card {
  border-color: rgba(201, 125, 91, 0.30);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.65) inset,
    0 14px 40px rgba(43, 51, 36, 0.06),
    0 0 0 3px rgba(201, 125, 91, 0.05),
    0 3px 10px rgba(201, 125, 91, 0.10);
}

.answer-card .answer-mark {
  font-family: var(--serif);
  color: var(--terracotta);
  font-size: 22px;
  line-height: 1;
  margin-bottom: 16px;
  opacity: 0.55;
  letter-spacing: 0.2em;
  text-align: start;
}

.answer {
  font-family: var(--arabic), var(--sans);
  font-size: 18px;
  line-height: 1.85;
  direction: rtl;
  text-align: right;
  padding: 0 0 4px;
  word-wrap: break-word;
  min-height: 1.85em;
  color: var(--olive-text);
  transition: opacity 0.45s ease, color 0.45s ease;
}

.answer[dir="ltr"] {
  direction: ltr;
  text-align: left;
  font-family: var(--sans), var(--arabic);
}

.answer-section.streaming .answer {
  opacity: 0.78;
  color: rgba(43, 51, 36, 0.82);
}

/* --- Markdown formatting inside the answer --- */

.answer p {
  margin: 0 0 0.85em;
}
.answer p:last-child { margin-bottom: 0; }
.answer > :first-child { margin-top: 0; }

/* Numbered list — manuscript italic numerals in terracotta, hanging indent */
.answer ol {
  list-style: none;
  counter-reset: tayyib;
  padding: 0;
  margin: 0.5em 0 0.9em;
  line-height: 1.75;
}

.answer ol > li {
  counter-increment: tayyib;
  position: relative;
  padding-inline-start: 2.2em;
  margin: 0.45em 0;
}

.answer ol > li::before {
  content: counter(tayyib) ".";
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 1.7em;
  text-align: end;
  padding-inline-end: 0.45em;
  font-family: var(--serif);
  font-variation-settings: 'SOFT' 60, 'WONK' 1;
  font-style: italic;
  font-weight: 500;
  font-size: 0.98em;
  color: var(--terracotta);
  opacity: 0.78;
  line-height: inherit;
}

/* Arabic answers: Arabic-Indic numerals in Tajawal (manuscript feel preserved) */
.answer[dir="rtl"] ol > li::before {
  content: counter(tayyib, arabic-indic) ".";
  font-family: var(--arabic);
  font-style: normal;
  font-weight: 700;
  font-size: 0.92em;
}

/* Bullet list — small olive diamond marker */
.answer ul {
  list-style: none;
  padding: 0;
  margin: 0.35em 0 0.8em;
  line-height: 1.75;
}

.answer ul > li {
  position: relative;
  padding-inline-start: 1.5em;
  margin: 0.32em 0;
}

.answer ul > li::before {
  content: '◆';
  position: absolute;
  inset-inline-start: 0.25em;
  top: 0.05em;
  color: var(--olive-soft);
  font-size: 0.55em;
  line-height: 2.1;
  opacity: 0.75;
}

/* Verdict markers — when the model emits a bullet item prefixed with
   ✓ / ◐ / ✕ + space, the renderer strips the prefix and tags the <li>
   with .allowed / .moderation / .forbidden. The class overrides the
   default ◆ with the tier glyph, tints the row's inline-start border,
   and shifts the bolded topic word's ink toward the tier's hue. */
.answer ul > li.allowed,
.answer ul > li.moderation,
.answer ul > li.forbidden {
  padding-inline-start: 1.9em;
  padding-block: 2px;
  border-inline-start: 2px solid transparent;
}
.answer ul > li.allowed::before,
.answer ul > li.moderation::before,
.answer ul > li.forbidden::before {
  font-size: 0.95em;
  line-height: 1.5;
  top: 0.22em;
  inset-inline-start: 0.55em;
  opacity: 1;
  font-weight: 700;
}

.answer ul > li.allowed {
  border-inline-start-color: rgba(107, 142, 80, 0.45);
}
.answer ul > li.allowed::before {
  content: '✓';
  color: var(--olive-soft);
}
.answer ul > li.allowed strong { color: var(--ink-allowed); }

.answer ul > li.moderation {
  border-inline-start-color: rgba(184, 137, 63, 0.50);
}
.answer ul > li.moderation::before {
  content: '◐';
  color: var(--tier-moderation);
  font-size: 1.02em;
  top: 0.12em;
}
.answer ul > li.moderation strong { color: var(--ink-moderation); }

.answer ul > li.forbidden {
  border-inline-start-color: rgba(201, 125, 91, 0.55);
}
.answer ul > li.forbidden::before {
  content: '✕';
  color: var(--terracotta);
}
.answer ul > li.forbidden strong { color: var(--ink-forbidden); }

/* Nested lists — demoted typography, gentler markers */
.answer li ol,
.answer li ul {
  margin: 0.25em 0 0.35em;
  font-size: 0.96em;
}

.answer li ul > li::before {
  content: '–';
  color: var(--muted);
  font-size: 0.9em;
  line-height: 1.55;
  inset-inline-start: 0.15em;
  opacity: 0.9;
}

.answer li ol > li::before {
  font-size: 0.85em;
  opacity: 0.65;
}

/* Bold — "illuminated" word emphasis. Warm-dark ink, display serif in LTR,
   heavier Tajawal in RTL. Avoids the harsh black of default <strong>. */
.answer strong {
  font-weight: 600;
  color: #4A3325;
}

.answer[dir="ltr"] strong {
  font-family: var(--serif);
  font-variation-settings: 'SOFT' 40, 'WONK' 0;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.answer[dir="rtl"] strong {
  font-family: var(--arabic);
  font-weight: 700;
}

/* Safety aside — only shown when model emits the --- marker */
.safety-aside {
  margin-top: 26px;
  padding-top: 22px;
  position: relative;
  font-family: var(--arabic), var(--sans);
  font-size: 14px;
  font-style: italic;
  line-height: 1.7;
  color: var(--muted);
  text-align: inherit;
}

.safety-aside[hidden] { display: none; }

.safety-aside p { margin: 0 0 0.6em; }
.safety-aside p:last-child { margin-bottom: 0; }
.safety-aside strong {
  font-family: inherit;
  font-weight: 600;
  font-style: inherit;
  color: inherit;
}

.safety-aside::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent,
    rgba(201, 125, 91, 0.32) 25%,
    rgba(201, 125, 91, 0.32) 75%,
    transparent);
}

.safety-aside::after {
  content: '❀';
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  background: #FCF9EE;
  padding: 0 12px;
  color: var(--terracotta);
  font-size: 13px;
  opacity: 0.65;
  line-height: 1;
}

/* Bottom seal — "stamp" of authorship, doubles as share button */
.answer-seal {
  margin-top: 22px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  background: transparent;
  border: 0;
  padding: 0;
  width: 100%;
  cursor: default;
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  opacity: 1;
  transition: opacity 0.45s ease;
  /* Only the seal circle is clickable, not the empty row */
  pointer-events: none;
}

.answer-seal .seal {
  pointer-events: auto;
  cursor: pointer;
}

.answer-section.streaming .answer-seal {
  opacity: 0;
}
.answer-section.streaming .answer-seal .seal {
  pointer-events: none;
}

/* `justify-content: flex-end` is direction-aware: right edge in LTR, left edge in RTL —
   so the seal naturally lands at the bottom-END corner of the answer's writing direction. */

.seal {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(201, 125, 91, 0.10);
  border: 1px solid rgba(201, 125, 91, 0.28);
  color: var(--terracotta);
  line-height: 1;
  opacity: 0.75;
  transition: opacity 0.2s, transform 0.2s, background-color 0.2s, border-color 0.2s;
}

.seal-icon {
  width: 14px;
  height: 14px;
  display: block;
  /* nudge up slightly so the "arrow + box" visually centers inside the circle */
  transform: translateY(-0.5px);
}

/* Inline hint that surfaces on hover/focus — sits on the inner side of the seal
   (left of it in LTR, right of it in RTL) via the logical inline-end inset. */
.seal::before {
  content: attr(data-hint);
  position: absolute;
  top: 50%;
  inset-inline-end: calc(100% + 8px);
  transform: translateY(-50%) translateX(var(--seal-slide, 4px));
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.01em;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Slide-in direction mirrors the card's writing direction */
.answer-card[dir="ltr"] { --seal-slide: 4px; }
.answer-card[dir="rtl"] { --seal-slide: -4px; }

.answer-seal[data-lang="ar"] .seal::before {
  font-family: var(--arabic);
  font-style: normal;
  font-size: 12.5px;
}

.answer-seal:hover .seal,
.answer-seal:focus-visible .seal {
  opacity: 1;
  transform: scale(1.06);
  background: rgba(201, 125, 91, 0.18);
  border-color: rgba(201, 125, 91, 0.48);
}

.answer-seal:hover .seal::before,
.answer-seal:focus-visible .seal::before,
.answer-seal.shared .seal::before {
  opacity: 0.85;
  transform: translateY(-50%) translateX(0);
}

.answer-seal:focus-visible {
  outline: none;
}
.answer-seal:focus-visible .seal {
  box-shadow: 0 0 0 3px rgba(201, 125, 91, 0.18);
}

.answer-seal:active .seal {
  transform: scale(0.96);
}

.answer-seal.shared .seal {
  background: rgba(107, 142, 80, 0.16);
  border-color: rgba(107, 142, 80, 0.45);
  color: var(--olive-soft);
}

.cursor {
  display: inline-block;
  color: var(--terracotta);
  font-weight: 700;
  margin-inline-start: 2px;
  animation: blink 1s steps(2) infinite;
}
.cursor[hidden] { display: none; }
@keyframes blink { 50% { opacity: 0; } }

/* --- Error --- */

.error {
  margin-top: 14px;
  padding: 14px 18px;
  background: var(--error-bg);
  border-right: 3px solid var(--error);
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.6;
  font-family: var(--arabic), var(--sans);
  color: var(--olive-text);
}
.error[dir="ltr"] { border-right: 0; border-left: 3px solid var(--error); }
.error .error-retry { margin-top: 4px; opacity: 0.85; }
.error .countdown { font-variant-numeric: tabular-nums; }

/* --- Footer --- */

footer {
  margin-top: auto;
  padding: 24px 0 0;
  border-top: 1px solid rgba(43, 51, 36, 0.08);
}

.footer-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  column-gap: 14px;
  row-gap: 8px;
  margin-bottom: 16px;
}

.quota {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 14px;
  background: var(--paper);
  border: 1px solid rgba(107, 142, 80, 0.20);
  border-radius: 999px;
  color: var(--olive-soft);
  font-weight: 600;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-family: var(--sans);
  letter-spacing: 0.005em;
}

.quota.exhausted {
  color: var(--error);
  border-color: rgba(176, 100, 74, 0.30);
}

/* Supporter chip — turns the plain quota into a "stamped" one. */
.quota.supporter {
  border-color: rgba(201, 125, 91, 0.38);
  background: linear-gradient(180deg, var(--paper) 0%, #FBF2E3 100%);
  color: var(--terracotta-deep);
  padding-inline-end: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.5),
    0 1px 0 rgba(142, 74, 46, 0.05);
}
.quota .supporter-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-inline-start: 8px;
  margin-inline-start: 2px;
  border-inline-start: 1px solid rgba(201, 125, 91, 0.28);
  font-family: var(--sans);
  font-size: 11px;
  text-transform: lowercase;
  letter-spacing: 0.04em;
  color: var(--terracotta-deep);
}
.quota[dir="rtl"] .supporter-label {
  font-family: var(--arabic);
  text-transform: none;
  font-size: 11.5px;
  font-weight: 500;
}

/* Wax-seal supporter mark — single olive imprint on a terracotta disc. */
.supporter-seal {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  display: inline-block;
  transform: translateY(0.5px);
  filter: drop-shadow(0 0.5px 0.5px rgba(94, 42, 22, 0.18));
}

/* Support CTA — terracotta-outline pill (used on the rate-limit card; points
   to the contact mailto). Physical (not logical) border on .arrow so the
   rotate value alone controls chevron direction across LTR/RTL. */
.support-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 14px;
  background: transparent;
  border: 1px solid rgba(201, 125, 91, 0.45);
  border-radius: 999px;
  color: var(--terracotta-deep);
  font-weight: 600;
  font-size: 12px;
  font-family: var(--sans);
  letter-spacing: 0.005em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.15s;
}
.support-cta[dir="rtl"] { font-family: var(--arabic); font-weight: 500; font-size: 12.5px; }
.support-cta:hover, .support-cta:focus-visible {
  background: rgba(201, 125, 91, 0.08);
  border-color: rgba(201, 125, 91, 0.65);
  outline: none;
}
.support-cta:active { transform: translateY(0.5px); }
.support-cta .arrow {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-top: 1.4px solid currentColor;
  border-right: 1.4px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s;
  margin-inline-start: 2px;
}
.support-cta[dir="rtl"] .arrow { transform: rotate(-135deg); }
.support-cta:hover .arrow { transform: rotate(45deg) translate(1.5px, -1.5px); }
.support-cta[dir="rtl"]:hover .arrow { transform: rotate(-135deg) translate(1.5px, -1.5px); }

/* Thanks-for-supporting variant: replaces the code link after activation. */
.support-thanks {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px;
  background: rgba(201, 125, 91, 0.10);
  border: 1px solid rgba(201, 125, 91, 0.28);
  border-radius: 999px;
  color: var(--terracotta-deep);
  font-family: var(--serif);
  font-style: italic;
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: 0.005em;
  font-variation-settings: 'SOFT' 60;
}
.support-thanks[dir="rtl"] {
  font-family: var(--arabic);
  font-style: normal;
  font-weight: 500;
}

/* "Have a code?" — quiet italic link, underline-on-hover. */
.code-link {
  background: none;
  border: 0;
  padding: 2px 4px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-style: italic;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dotted transparent;
  transition: color 0.2s, border-color 0.2s;
}
.code-link[dir="rtl"] { font-family: var(--arabic); font-style: normal; font-size: 12.5px; }
.code-link:hover, .code-link:focus-visible {
  color: var(--terracotta-deep);
  border-bottom-color: rgba(201, 125, 91, 0.6);
  outline: none;
}

/* Activate panel — slides in below the footer row / 429 card. */
.activate-wrap { margin-top: 4px; }
.activate-panel {
  display: flex;
  align-items: stretch;
  gap: 8px;
  max-width: 480px;
  margin: 14px auto 8px;
  padding: 6px 6px 6px 14px;
  background: var(--paper);
  border: 1px solid rgba(201, 125, 91, 0.32);
  border-radius: 28px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 1px 0 rgba(94, 42, 22, 0.04);
  animation: panel-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.activate-panel[dir="rtl"] { padding: 6px 14px 6px 6px; }
@keyframes panel-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

.activate-panel input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  padding: 6px 0;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--olive-text);
}
.activate-panel input::placeholder { color: var(--muted); opacity: 0.6; font-style: italic; letter-spacing: normal; }

.activate-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--terracotta);
  border: 0;
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.15s;
}
.activate-btn:hover { background: var(--terracotta-dark); }
.activate-btn:active { transform: scale(0.95); }
.activate-btn svg { width: 14px; height: 14px; display: block; }
.activate-btn[dir="rtl"] svg { transform: scaleX(-1); }

.activate-cancel {
  display: block;
  margin: 4px auto 0;
  background: none;
  border: 0;
  padding: 2px 8px;
  font-family: var(--sans);
  font-size: 11.5px;
  font-style: italic;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 1px dotted transparent;
}
.activate-cancel[dir="rtl"] { font-family: var(--arabic); font-style: normal; }
.activate-cancel:hover { color: var(--terracotta-deep); border-bottom-color: rgba(139, 130, 115, 0.4); }

.activate-panel.error {
  border-color: rgba(176, 100, 74, 0.55);
  animation: shake 0.32s cubic-bezier(0.36, 0.07, 0.19, 0.97) both, panel-in 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-3px); }
  40%, 60% { transform: translateX(3px); }
}
.activate-msg {
  display: block;
  margin: 6px auto 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12.5px;
  color: var(--error);
  letter-spacing: 0.005em;
}
.activate-msg[dir="rtl"] { font-family: var(--arabic); font-style: normal; }

/* Activation confirmation ribbon — ❀-flourished, auto-dismissed. */
.activation-ribbon {
  position: relative;
  max-width: 480px;
  margin: 22px auto 8px;
  padding: 16px 22px 14px;
  text-align: center;
  background: linear-gradient(180deg, #FCF7EA 0%, #FAF1DB 100%);
  border: 1px solid rgba(201, 125, 91, 0.30);
  border-radius: 10px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--olive-text);
  font-variation-settings: 'SOFT' 60, 'WONK' 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 1px 2px rgba(94, 42, 22, 0.05);
  animation: ribbon-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.activation-ribbon[dir="rtl"] { font-family: var(--arabic); font-style: normal; font-weight: 500; font-size: 15.5px; }
.activation-ribbon::before {
  content: '❀';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--paper);
  padding: 0 12px;
  color: var(--terracotta);
  font-size: 14px;
  opacity: 0.7;
  line-height: 1;
}
.activation-ribbon strong {
  font-weight: 600;
  font-style: normal;
  color: var(--terracotta-deep);
  font-variation-settings: 'SOFT' 0;
}
.activation-ribbon[dir="rtl"] strong { font-weight: 700; }
@keyframes ribbon-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 429 "continue today" card — sits below the error block. */
.rate-limit-continue {
  margin-top: 14px;
  padding: 14px 18px 16px;
  background: linear-gradient(180deg, #FCF7EA 0%, #FAF1DB 100%);
  border: 1px solid rgba(201, 125, 91, 0.32);
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--olive-text);
  position: relative;
}
.rate-limit-continue[dir="rtl"] { font-family: var(--arabic); font-size: 14px; }
.rate-limit-continue-label {
  display: block;
  margin-bottom: 10px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  font-variation-settings: 'SOFT' 60, 'WONK' 1;
  color: var(--muted);
  letter-spacing: 0.005em;
}
.rate-limit-continue[dir="rtl"] .rate-limit-continue-label { font-family: var(--arabic); font-style: normal; font-weight: 500; }
.rate-limit-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.rate-limit-note {
  margin: 12px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.005em;
  opacity: 0.9;
}
.rate-limit-note[dir="rtl"] { font-family: var(--arabic); font-style: normal; }

/* Copyable visible address — the bulletproof fallback beside the mailto pill.
   Dashed border (vs the solid support-cta) signals "copy" not "go". */
.copy-email {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: transparent;
  border: 1px dashed rgba(201, 125, 91, 0.45);
  border-radius: 999px;
  color: var(--terracotta-deep);
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.copy-email:hover, .copy-email:focus-visible {
  background: rgba(201, 125, 91, 0.08);
  border-color: rgba(201, 125, 91, 0.65);
  outline: none;
}
.copy-email .copy-ic { opacity: 0.55; font-size: 13px; }
.copy-email.copied {
  border-style: solid;
  border-color: rgba(107, 142, 80, 0.5);
  color: var(--olive-soft);
}
.copy-email.copied .copy-ic { display: none; }

.disclaimer {
  text-align: center;
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--serif);
  font-style: italic;
  line-height: 1.55;
  opacity: 0.85;
  max-width: 560px;
  margin: 0 auto;
}

.disclaimer p { margin: 4px 0; }
.disclaimer p[dir="rtl"] { font-family: var(--arabic); font-style: normal; }

/* --- Stagger entrance animation --- */

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.logo, h1, .sub, .sub-ar, .box, .suggestions, footer {
  animation: rise 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.logo        { animation-delay: 0.05s; }
h1           { animation-delay: 0.14s; }
.sub         { animation-delay: 0.22s; }
.sub-ar      { animation-delay: 0.28s; }
.box         { animation-delay: 0.38s; }
.suggestions { animation-delay: 0.50s; }
footer       { animation-delay: 0.62s; }

/* --- Mobile --- */

@media (max-width: 540px) {
  body { padding: 18px 16px 36px; }
  header {
    padding: 24px 0 16px;
    column-gap: 14px;
  }
  .logo { font-size: 64px; }
  .title-block { padding-top: 4px; }
  h1 { font-size: 32px; gap: 10px; }
  .title-ar { font-size: 22px; }
  .sub, .sub-ar { font-size: 14px; }
  .box { padding-block: 12px; padding-inline-start: 16px; padding-inline-end: 50px; border-radius: 13px; }
  textarea { font-size: 16px; }
  .answer { font-size: 17px; }
  button.send { width: 32px; height: 32px; bottom: 8px; inset-inline-end: 8px; }
  button.send svg { width: 16px; height: 16px; }
  .chip { font-size: 13px; }
  .chip-ar { font-size: 14px; }
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  .cursor { animation: none; }
  .logo, h1, .sub, .sub-ar, .box, .suggestions, footer { animation: none; }
  .activate-panel, .activate-panel.error, .activation-ribbon { animation: none !important; }
  * { transition: none !important; }
}
