/* ESPADSELL: design system v6 "editorial ledger" (was v5 "warm precision") (teal brand #026f7d on warm cream, ink text, coral and mint accents)
   Mobile first. Tokens drive both themes; components only use tokens.
   Theme: follows the device unless the user picks one (html[data-theme]). */

:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #17212b;
  --text-2: #4f5a63;
  --text-3: #5b6670;
  --border: #e4e0d6;
  --border-strong: #d3cec2;

  --primary: #026f7d;
  --primary-hover: #015a66;
  --primary-soft: #e3f2f4;
  --primary-text: #ffffff;
  --grad-a: #0b8292;
  --grad-b: #026f7d;
  --grad-c: #01434d;
  --on-grad-strong: #025a66;
  /* "gold" is the coral accent: icons and decoration only, never body text. */
  --gold: #c65a3f;
  --gold-soft: #fbe7e1;
  --mint: #b9e8d5;
  --mint-text: #0b5d51;

  --ok: #17845a;
  --ok-soft: #e3f4ec;
  --warn: #9a5b00;
  --warn-soft: #fff2db;
  --warn-line: #e5a53b;
  --danger: #b4321f;
  --danger-soft: #fdeceb;

  --radius-s: 8px;
  --radius: 14px;
  --radius-l: 22px;
  --shadow-1: 0 1px 2px rgba(10, 34, 38, .06), 0 1px 1px rgba(10, 34, 38, .04);
  --shadow-2: 0 10px 30px -12px rgba(10, 34, 38, .28);
  --focus: 0 0 0 3px rgba(2, 111, 125, .35);

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Noto Sans Arabic", Tahoma, sans-serif;
  --font-display: "Fraunces", ui-serif, Georgia, "Times New Roman", serif;
  --font-mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 248px;
  --tabbar: 68px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=light]) {
    color-scheme: dark;
    --bg: #0a1517;
    --surface: #111f22;
    --surface-2: #18292d;
    --text: #ecf4f5;
    --text-2: #a9bec2;
    --text-3: #87a0a5;
    --border: #223639;
    --border-strong: #2f474b;
    --primary: #4fc3d0;
    --primary-hover: #72d1db;
    --primary-soft: #0b2f34;
    --primary-text: #04262b;
    --on-grad-strong: #025a66;
    --gold: #f0937a;
    --gold-soft: #3a1f19;
    --mint: #123b33;
    --mint-text: #9ee0c6;
    --ok: #45c48d;
    --ok-soft: #13291f;
    --warn: #f2b45a;
    --warn-soft: #2f2412;
    --warn-line: #c78a2a;
    --danger: #f08a7a;
    --danger-soft: #34191a;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 14px 34px -12px rgba(0, 0, 0, .65);
    --focus: 0 0 0 3px rgba(79, 195, 208, .45);
  }
}
:root[data-theme=dark] {
  color-scheme: dark;
  --bg: #0a1517;
  --surface: #111f22;
  --surface-2: #18292d;
  --text: #ecf4f5;
  --text-2: #a9bec2;
  --text-3: #87a0a5;
  --border: #223639;
  --border-strong: #2f474b;
  --primary: #4fc3d0;
  --primary-hover: #72d1db;
  --primary-soft: #0b2f34;
  --primary-text: #04262b;
  --on-grad-strong: #025a66;
  --gold: #f0937a;
  --gold-soft: #3a1f19;
  --mint: #123b33;
  --mint-text: #9ee0c6;
  --ok: #45c48d;
  --ok-soft: #13291f;
  --warn: #f2b45a;
  --warn-soft: #2f2412;
  --warn-line: #c78a2a;
  --danger: #f08a7a;
  --danger-soft: #34191a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 14px 34px -12px rgba(0, 0, 0, .65);
  --focus: 0 0 0 3px rgba(79, 195, 208, .45);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-underline-offset: 2px; }
img { max-width: 100%; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: 26px; font-weight: 750; }
h2 { font-size: 19px; font-weight: 700; margin: 28px 0 12px; }
h3 { font-size: 16px; font-weight: 650; }
p { margin: 0 0 12px; }
.lead { color: var(--text-2); margin: 6px 0 22px; }
.muted { color: var(--text-2); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.logo { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 750; letter-spacing: -0.01em; }
.logo-mark {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b) 55%, var(--grad-c));
  box-shadow: 0 4px 12px -4px rgba(2, 111, 125, .5);
}
.logo-mark .icon { width: 18px; height: 18px; stroke-width: 2; }
.beta { font-size: 11px; font-weight: 600; color: var(--text-2); border: 1px solid var(--border-strong); border-radius: 99px; padding: 1px 7px; }
.topbar .spacer { flex: 1; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: var(--primary-soft); color: var(--primary); border: 0; cursor: pointer; text-decoration: none;
}
.content { padding: 20px 16px calc(var(--tabbar) + 36px); max-width: 880px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .lead { margin-bottom: 0; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary); margin-bottom: 6px; }

/* Bottom tab bar (phones) */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; height: calc(var(--tabbar) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); text-decoration: none; font-size: 11px; font-weight: 600;
}
.tabbar a.on { color: var(--primary); }
.tabbar .fab {
  width: 52px; height: 52px; margin: -18px auto 0; border-radius: 18px; color: #fff; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--grad-a), var(--grad-b)); box-shadow: var(--shadow-2);
}
.tabbar .fab .icon { width: 24px; height: 24px; stroke-width: 2.2; }
.tabbar .fab-label { margin-top: 2px; }

/* Account menu */
.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-2);
}
.menu-panel[hidden] { display: none; }
.menu-panel a, .menu-panel button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border-radius: 10px; border: 0; background: none;
  color: var(--text); text-decoration: none; font: inherit; font-size: 15px; cursor: pointer; text-align: left;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); }
.menu-panel .who { padding: 10px 12px 8px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: var(--sidebar) 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
    padding: 20px 14px; border-right: 1px solid var(--border); background: var(--surface);
  }
  .sidebar .logo { padding: 4px 8px 18px; }
  .nav-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 11px;
    color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 15px;
  }
  .nav-link:hover { background: var(--surface-2); color: var(--text); }
  .nav-link.on { background: var(--primary-soft); color: var(--primary); }
  .sidebar .create { margin: 6px 0 14px; justify-content: center; }
  .sidebar .grow { flex: 1; }
  .sidebar .usage { padding: 12px; border-radius: var(--radius); background: var(--surface-2); font-size: 13px; color: var(--text-2); }
  .tabbar { display: none; }
  .topbar { padding: 12px 40px; }
  .topbar .logo, .topbar .beta { display: none; }
  .content { padding: 36px 40px 60px; }
  h1 { font-size: 30px; }
}

/* ---------- Cards & layout ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l);
  padding: 18px; box-shadow: var(--shadow-1); margin-bottom: 16px;
}
.card.flat { box-shadow: none; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title h2, .card-title h3 { margin: 0; }
.stack > * + * { margin-top: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-2 { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
/* Long translations (fa: "ترجیح می‌دهم نگویم") do not fit half a phone screen. */
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; gap: 0; } }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
.row.tight { margin-top: 0; }
.between { justify-content: space-between; }
@media (min-width: 640px) { .card { padding: 22px; } }

.hero {
  position: relative; overflow: hidden; border: 0; color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, var(--grad-a) 0%, var(--grad-b) 45%, var(--grad-c) 100%);
}
.hero::after {
  content: ""; position: absolute; width: 260px; height: 260px; right: -80px; top: -90px; border-radius: 50%;
  background: rgba(255, 255, 255, .12);
}
.hero h2 { color: #fff; margin: 0 0 4px; font-size: 21px; }
.hero p { color: rgba(255, 255, 255, .85); }
.hero label.field-label { color: rgba(255, 255, 255, .9); }
.hero .pill { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); color: #fff; }
.hero .pill:has(input:checked) { background: #fff; color: var(--on-grad-strong); border-color: #fff; }
.hero .btn.light { background: #fff; color: var(--on-grad-strong); }
.hero .btn.light:hover { background: #e3f2f4; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px;
  border-radius: 12px; border: 1px solid transparent; background: var(--primary); color: var(--primary-text);
  font: inherit; font-weight: 650; font-size: 15px; text-decoration: none; cursor: pointer;
  transition: background .15s, transform .05s, border-color .15s;
}
.btn:hover { background: var(--primary-hover); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.small { min-height: 38px; padding: 7px 13px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 16px; padding: 12px 22px; border-radius: 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.linklike { background: none; border: 0; color: var(--text-2); text-decoration: underline; cursor: pointer; font: inherit; padding: 0 0 0 6px; }

/* ---------- Forms ---------- */
label, .field-label { display: block; font-weight: 650; font-size: 14.5px; margin: 16px 0 7px; }
.hint { display: block; font-weight: 400; color: var(--text-2); font-size: 13.5px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea {
  width: 100%; min-height: 46px; padding: 11px 13px; font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 38px; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a8393' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type=file] { font: inherit; font-size: 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: 15px; }
.check input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.disclosure-toggle { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 14.5px; color: var(--text-2); margin-top: 16px; }
details[open] .disclosure-toggle .chev { transform: rotate(90deg); }
.disclosure-toggle .chev { transition: transform .15s; }

/* Pills (radio/checkbox styled as chips) */
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices label, .pill {
  position: relative; display: inline-flex; align-items: center; gap: 8px; margin: 0; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--border-strong); border-radius: 99px; background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; cursor: pointer; transition: background .12s, border-color .12s, color .12s;
}
.choices label input, .pill input { position: absolute; opacity: 0; pointer-events: none; }
.choices label:has(input:checked), .pill:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.choices label:has(input:focus-visible), .pill:has(input:focus-visible) { box-shadow: var(--focus); }
.pill .thumb { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; margin-left: -6px; background: var(--surface-2); }

/* Segmented control */
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.segmented label {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; margin: 0; min-height: 40px; padding: 6px 10px;
  border-radius: 10px; font-weight: 650; font-size: 14px; color: var(--text-2); cursor: pointer; text-align: center;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.segmented label:has(input:focus-visible) { box-shadow: var(--focus); }

/* ---------- Feedback & status ---------- */
.toast {
  position: fixed; z-index: 60; left: 50%; top: 14px; transform: translateX(-50%); width: min(560px, calc(100% - 32px));
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow-2); font-size: 14.5px;
  animation: toast-in .25s ease-out;
}
.toast.hide { opacity: 0; transform: translate(-50%, -8px); transition: .3s; }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; cursor: pointer; opacity: .7; font-size: 18px; line-height: 1; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -10px); } }
.errors { display: flex; gap: 10px; background: var(--danger-soft); color: var(--danger); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px; font-size: 14.5px; }
.errors ul { margin: 0; padding-left: 18px; }
.status { background: var(--ok-soft); color: var(--ok); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px; font-size: 14.5px; }
.callout { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--radius); background: var(--gold-soft); color: var(--text); font-size: 14.5px; margin-bottom: 16px; }
.callout .icon { color: var(--gold); margin-top: 1px; }
.notice { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--text-2); margin: 0 0 16px; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.tag { display: inline-block; font-size: 12px; font-weight: 600; border: 1px solid var(--border-strong); border-radius: 99px; padding: 1px 8px; color: var(--text-2); background: var(--surface); margin-left: 6px; vertical-align: 1px; }
.clean { display: flex; align-items: center; gap: 8px; color: var(--ok); font-weight: 650; font-size: 14px; margin: 12px 0 0; }

/* Busy overlay while the AI works */
.busy {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.busy[hidden] { display: none; }
.busy-card { width: min(380px, 100%); text-align: center; padding: 28px 24px; background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow-2); border: 1px solid var(--border); }
.spinner { width: 46px; height: 46px; margin: 0 auto 16px; border-radius: 50%; border: 4px solid var(--primary-soft); border-top-color: var(--primary); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.busy-step { font-weight: 650; min-height: 24px; }

/* ---------- Home ---------- */
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.quick a {
  display: flex; flex-direction: column; gap: 8px; padding: 14px 12px; border-radius: var(--radius); text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); font-weight: 650; font-size: 14px; box-shadow: var(--shadow-1);
}
.quick a:hover { border-color: var(--border-strong); }
.quick .ico { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.quick .ico.gold { background: var(--gold-soft); color: var(--gold); }
.quick .ico.ok { background: var(--ok-soft); color: var(--ok); }
.quick small { color: var(--text-2); font-weight: 500; font-size: 12.5px; line-height: 1.35; }
.meter { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.meter span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.setup { list-style: none; padding: 0; margin: 0; }
.setup li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); font-size: 15px; }
.setup li:first-child { border-top: 0; }
.setup .dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; border: 2px solid var(--border-strong); }
.setup .done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.setup .done span.t { color: var(--text-2); text-decoration: line-through; }
.setup a { margin-left: auto; font-size: 14px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.feed { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.feed a {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text);
}
.feed a:hover { border-color: var(--border-strong); }
.feed .kind { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.feed .title { font-weight: 650; font-size: 14.5px; }
.feed .snippet { color: var(--text-2); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed time { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.empty { text-align: center; padding: 34px 20px; color: var(--text-2); }
.empty .ico { width: 54px; height: 54px; margin: 0 auto 12px; border-radius: 18px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }

/* ---------- Results ---------- */
.draft { padding: 0; overflow: hidden; }
.draft-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.draft-head h2 { margin: 0; font-size: 16px; }
.draft-body { padding: 16px 18px 4px; }
.output { white-space: pre-wrap; font-size: 16px; line-height: 1.6; margin: 0 0 14px; overflow-wrap: anywhere; }
.output.boxed { background: var(--surface-2); border-radius: var(--radius); padding: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 16px; }
.draft-flags { border-top: 1px solid var(--border); padding: 12px 18px 16px; background: var(--surface); }
mark { background: var(--gold-soft); color: var(--warn); border-radius: 4px; padding: 0 3px; font-weight: 600; }
mark.risk { background: transparent; color: inherit; font-weight: inherit; padding: 0; border-bottom: 2px solid var(--warn-line); border-radius: 0; text-decoration: none; }
.flag { border-left: 3px solid var(--warn-line); background: var(--warn-soft); border-radius: 0 12px 12px 0; padding: 10px 12px; margin: 8px 0; font-size: 14.5px; }
.flag .phrase { font-weight: 700; }
.flag-summary { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 14.5px; color: var(--warn); }

.rate { display: flex; flex-wrap: wrap; gap: 8px; }
.rate button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: 14px;
}
.rate button[aria-pressed=true] { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }

/* Image maker */
.card-maker { border-top: 1px solid var(--border); padding: 16px 18px 18px; background: var(--surface-2); }
.maker-grid { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.maker-grid label { margin-top: 12px; }
.maker-grid canvas { width: 100%; max-width: 420px; height: auto; border-radius: 12px; border: 1px solid var(--border); display: block; box-shadow: var(--shadow-2); }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--border-strong); }
@media (max-width: 680px) { .maker-grid { grid-template-columns: 1fr; } .maker-grid canvas { margin: 0 auto; } }

/* ---------- Products ---------- */
.products { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.product-card { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.product-card .ph { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); overflow: hidden; }
.product-card .ph img { width: 100%; height: 100%; object-fit: cover; }
.product-card .pc-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.product-card .pc-body .row { margin-top: auto; padding-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.section-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.section-nav a { flex: none; padding: 7px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); font-size: 13.5px; font-weight: 650; color: var(--text-2); text-decoration: none; }
.form-section { scroll-margin-top: 80px; }
.form-section > h2 { margin-top: 0; display: flex; align-items: center; gap: 10px; }
.step { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 750; background: var(--primary-soft); color: var(--primary); flex: none; }
.dropzone { display: flex; gap: 14px; align-items: center; padding: 14px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); }
.dropzone img { width: 88px; height: 88px; object-fit: cover; border-radius: 12px; }
.sticky-actions {
  position: sticky; bottom: calc(var(--tabbar) + 10px); z-index: 10; display: flex; gap: 10px; justify-content: flex-end;
  padding: 12px; margin-top: 8px; border-radius: var(--radius-l); background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border); box-shadow: var(--shadow-2); backdrop-filter: blur(10px);
}
@media (min-width: 960px) { .sticky-actions { bottom: 16px; } }
.scene-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-top: 16px; }
.scene-grid figure { margin: 0; }
.scene-grid img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); display: block; }
.scene-grid figcaption { margin-top: 6px; color: var(--text-2); }
.presets { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.presets form { margin: 0; }
.presets .btn { width: 100%; justify-content: flex-start; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; }
.auth-aside { display: none; }
.auth-main { display: grid; place-items: center; padding: 28px 16px 40px; }
.auth-card { width: min(420px, 100%); }
.auth-card .logo { margin-bottom: 26px; }
.auth-card h1 { margin-bottom: 6px; }
.value-list { list-style: none; padding: 0; margin: 26px 0 0; display: grid; gap: 16px; }
.value-list li { display: flex; gap: 12px; }
.value-list .ico { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex: none; background: rgba(255, 255, 255, .16); }
@media (min-width: 960px) {
  .auth { grid-template-columns: 1.05fr 1fr; }
  .auth-aside {
    display: flex; flex-direction: column; justify-content: space-between; padding: 48px; color: #fff;
    background: radial-gradient(120% 120% at 0% 0%, var(--grad-a) 0%, var(--grad-b) 45%, var(--grad-c) 100%);
  }
  .auth-aside h2 { font-family: var(--font-display); font-size: 40px; line-height: 1.1; letter-spacing: -0.01em; margin: 0; color: #fff; font-weight: 600; }
  .auth-aside p { color: rgba(255, 255, 255, .85); }
  .auth-aside .logo { color: #fff; }
  .auth-aside .logo-mark { background: rgba(255, 255, 255, .18); box-shadow: none; }
}

/* ---------- Tables (admin) ---------- */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 6px; }
.stat-card { padding: 16px; }
.stat-card .label { color: var(--text-2); font-size: 13px; font-weight: 600; }
.stat { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; margin: 2px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); font-weight: 700; padding: 8px; border-bottom: 1px solid var(--border); }
td { padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; background: var(--surface-2); border-radius: 6px; padding: 2px 6px; }

/* ---------- Footer ---------- */
.legal { margin-top: 36px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-3); font-size: 12.5px; }
.legal a { color: var(--text-2); }

/* ---------- Header controls: theme, language, account ---------- */
.controls { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); text-decoration: none;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn .lang-code { font-size: 11px; font-weight: 750; letter-spacing: .02em; }
.lang-btn { width: auto; padding: 0 10px; display: inline-flex; gap: 6px; }
.theme-dark-only { display: none; }
:root[data-theme=dark] .theme-dark-only { display: block; }
:root[data-theme=dark] .theme-light-only { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-dark-only { display: block; }
  :root:not([data-theme]) .theme-light-only { display: none; }
}
.lang-panel { min-width: 230px; max-height: min(70vh, 480px); overflow-y: auto; }
.lang-panel button[aria-current=true] { background: var(--primary-soft); color: var(--primary); font-weight: 650; }
.lang-panel .native { flex: 1; }
.lang-panel .code { color: var(--text-3); font-size: 12px; text-transform: uppercase; }
.guest-controls { position: fixed; z-index: 30; top: 14px; inset-inline-end: 14px; }
/* On phones the floating buttons covered the logo; give them their own row instead. */
@media (max-width: 959px) {
  .guest-controls { position: static; display: flex; justify-content: flex-end; padding: 12px 14px 0; }
  .auth-main { padding-top: 8px; }
}
.btn-google { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-google:hover { background: var(--surface-2); }
.btn-google svg { width: 18px; height: 18px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 13px; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Right-to-left (Persian, Arabic, Urdu) ---------- */
[dir=rtl] .menu-panel { right: auto; left: 0; text-align: right; }
[dir=rtl] .menu-panel a, [dir=rtl] .menu-panel button { text-align: right; }
[dir=rtl] select { background-position: left 12px center; padding-right: 13px; padding-left: 38px; }
[dir=rtl] .flag { border-left: 0; border-right: 3px solid var(--warn-line); border-radius: 12px 0 0 12px; }
[dir=rtl] .setup a { margin-left: 0; margin-right: auto; }
[dir=rtl] .icon-chevron-flip, [dir=rtl] .disclosure-toggle .chev, [dir=rtl] .setup a .icon { transform: scaleX(-1); }
[dir=rtl] details[open] .disclosure-toggle .chev { transform: rotate(90deg); }
[dir=rtl] th { text-align: right; }
[dir=rtl] .pill .thumb { margin-left: 0; margin-right: -6px; }
[dir=rtl] .linklike { padding: 0 6px 0 0; }
[dir=rtl] .hero::after { right: auto; left: -80px; }
@media (min-width: 960px) {
  [dir=rtl] .sidebar { border-right: 0; border-left: 1px solid var(--border); }
}

/* ---------- Right-to-left scripts (fa, ar, ur) ----------
   Vazirmatn (self-hosted, OFL, public/fonts) covers Arabic script and Latin, so one face
   serves the whole page. No letter-spacing: it breaks the joining of Arabic letters. */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-wght.woff2") format("woff2-variations"), url("../fonts/Vazirmatn-wght.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
html[dir=rtl] {
  --font: "Vazirmatn", Tahoma, sans-serif;
  --font-display: "Vazirmatn", Tahoma, sans-serif;
  --font-mono: "Vazirmatn", Tahoma, sans-serif;
}
html[dir=rtl] body { line-height: 1.8; }
html[dir=rtl] *, html[dir=rtl] *::before, html[dir=rtl] *::after { letter-spacing: 0 !important; }
html[dir=rtl] h1, html[dir=rtl] h2, html[dir=rtl] h3 { line-height: 1.45; font-weight: 800; }
html[dir=rtl] .eyebrow, html[dir=rtl] th { text-transform: none; }
html[dir=rtl] .btn, html[dir=rtl] .logo { font-weight: 700; }
html[dir=rtl] .auth-aside h2 { font-weight: 800; font-size: 36px; line-height: 1.5; }
html[dir=rtl] textarea { line-height: 1.8; }

/* ---------- Home stats and entrance motion (v5) ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); min-width: 0; }
.kpi .ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--primary-soft); color: var(--primary); }
.kpi .ico.ok { background: var(--ok-soft); color: var(--ok); }
.kpi .ico.gold { background: var(--gold-soft); color: var(--gold); }
.kpi div { display: grid; min-width: 0; line-height: 1.25; }
.kpi strong { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.kpi span:not(.ico) { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) { .kpi { flex-direction: column; align-items: flex-start; gap: 6px; } }
.hero { box-shadow: 0 24px 50px -28px rgba(2, 67, 77, .7); }
.hero::before { content: ""; position: absolute; width: 220px; height: 220px; left: -60px; bottom: -120px; border-radius: 50%; background: radial-gradient(circle, rgba(231, 178, 77, .35), transparent 70%); pointer-events: none; }
.hero > * { position: relative; }
.quick a, .feed a, .product-card, .kpi { transition: transform .2s, border-color .2s, box-shadow .2s; }
.quick a:hover, .feed a:hover, .product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.nav-link { transition: background .15s, color .15s; }
@media (prefers-reduced-motion: no-preference) {
  .rise { animation: rise .55s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--d, 0) * 70ms); }
  @keyframes rise { from { opacity: 0; transform: translateY(14px); } }
}
.msg + .msg { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.topbar .logo span { white-space: nowrap; }
@media (max-width: 480px) { .kpi span:not(.ico) { white-space: normal; } }

/* ---------- v6 "editorial ledger" layer (shared with the public site) ----------
   Serif display headings, a mono label voice, flat hairline surfaces, and one brand mark. */
:root { --radius-l: 16px; --radius: 12px; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; position: relative;
  background: #026f7d; box-shadow: none; color: #f7f5ef;
}
.logo-mark::before { content: "e"; font-family: "Fraunces", Georgia, serif; font-style: italic; font-weight: 500; font-size: 22px; line-height: 1; transform: translateY(-2px); }
.logo-mark::after { content: ""; position: absolute; inset-inline-end: 5px; bottom: 6px; width: 5px; height: 5px; border-radius: 50%; background: #f0937a; }
.logo-mark .icon { display: none; }
.logo { font-weight: 700; letter-spacing: .14em; font-size: 14.5px; }
h1 { font-family: var(--font-display); font-optical-sizing: auto; font-weight: 420; font-size: 30px; letter-spacing: -0.03em; line-height: 1.08; }
@media (min-width: 960px) { h1 { font-size: 38px; } }
.eyebrow { font-family: var(--font-mono); font-weight: 500; font-size: 11.5px; letter-spacing: .12em; }
.card-title h2, .card > h2:first-child { font-family: var(--font-display); font-weight: 450; letter-spacing: -0.02em; }
.btn { font-weight: 600; }
.kpi strong { font-family: var(--font-display); font-weight: 450; font-size: 26px; letter-spacing: -0.03em; }
.kpi { box-shadow: none; }
.card { box-shadow: none; }

/* Dashboard "today" card and the auth aside: flat teal / ink with ruled lines, no glows. */
.hero { background: #025a66; box-shadow: none; }
.hero::after, .hero::before { display: none; }
.hero, .auth-aside { background-image: linear-gradient(to bottom, transparent 35px, rgba(255, 255, 255, .05) 35px); background-size: 100% 36px; }
.logo .beta { letter-spacing: 0; }
.hero h2 { font-family: var(--font-display); font-weight: 450; font-size: 26px; letter-spacing: -0.02em; }
@media (min-width: 960px) {
  .auth-aside { background-color: #111b22; }
  .auth-aside h2 { font-weight: 380; font-size: 52px; line-height: 1.02; letter-spacing: -0.035em; max-width: 12ch; }
  .auth-aside .logo-mark { background: #026f7d; }
  .value-list { gap: 0; border-top: 1px solid rgba(255, 255, 255, .16); margin-top: 36px; }
  .value-list li { padding: 16px 0; border-bottom: 1px solid rgba(255, 255, 255, .16); }
  .value-list .ico { background: none; width: 24px; color: #8fd8e0; }

  .sidebar { padding: 24px 16px; background: var(--bg); }
  .sidebar .logo { padding: 2px 8px 22px; margin-bottom: 6px; border-bottom: 1px solid var(--border); }
  .nav-link { position: relative; border-radius: 8px; font-weight: 500; }
  .nav-link.on { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
  .nav-link.on .icon { color: var(--primary); }
  .sidebar .usage { background: none; border-top: 1px solid var(--border); border-radius: 0; padding: 14px 8px 0; }
}
html[dir=rtl] h1, html[dir=rtl] .kpi strong, html[dir=rtl] .hero h2, html[dir=rtl] .auth-aside h2 { font-weight: 800; letter-spacing: 0; }
html[dir=rtl] .auth-aside h2 { line-height: 1.4; font-size: 40px; }
html[dir=rtl] .eyebrow { font-size: 12.5px; font-weight: 600; }
html[dir=rtl] .logo { letter-spacing: .14em !important; }
