/* Ferdaws — design tokens & shared components
   Visual language: soft off-white canvas, near-black ink, Geist headlines,
   hairline frames, pill badges, black primary buttons, color only in data. */

:root {
  --bg: #f7f7f7;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --sunken: rgba(23, 23, 23, 0.04);
  --text: #171717;
  --muted: rgba(23, 23, 23, 0.58);
  --faint: rgba(23, 23, 23, 0.38);
  --line: rgba(23, 23, 23, 0.08);
  --line-2: rgba(23, 23, 23, 0.13);
  --ink: #171717;
  --ink-text: #ffffff;
  --accent: #0b8f63;
  --accent-2: #12b37d;
  --accent-soft: rgba(11, 143, 99, 0.1);
  --accent-ring: rgba(11, 143, 99, 0.28);
  --danger: #d9363e;
  --tip-bg: #141414;
  --tip-text: #f2f2f2;
  --shadow-sm: 0 1px 2px rgba(23, 23, 23, 0.04);
  --shadow: 0 1px 2px rgba(23, 23, 23, 0.04), 0 4px 4px rgba(23, 23, 23, 0.03);
  --shadow-lg: 0 1px 2px rgba(23, 23, 23, 0.05), 0 12px 32px -8px rgba(23, 23, 23, 0.12);
  --r-xs: 6px;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --font: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-ar: "IBM Plex Sans Arabic", "Geist", ui-sans-serif, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0c0c;
    --surface: #151515;
    --surface-2: #121212;
    --sunken: rgba(255, 255, 255, 0.05);
    --text: #ededed;
    --muted: rgba(237, 237, 237, 0.6);
    --faint: rgba(237, 237, 237, 0.38);
    --line: rgba(255, 255, 255, 0.08);
    --line-2: rgba(255, 255, 255, 0.14);
    --ink: #f2f2f2;
    --ink-text: #111111;
    --accent: #2fcf95;
    --accent-2: #5be0b0;
    --accent-soft: rgba(47, 207, 149, 0.12);
    --accent-ring: rgba(47, 207, 149, 0.3);
    --tip-bg: #f2f2f2;
    --tip-text: #141414;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0c0c0c;
  --surface: #151515;
  --surface-2: #121212;
  --sunken: rgba(255, 255, 255, 0.05);
  --text: #ededed;
  --muted: rgba(237, 237, 237, 0.6);
  --faint: rgba(237, 237, 237, 0.38);
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --ink: #f2f2f2;
  --ink-text: #111111;
  --logo: #262626;
  --accent: #2fcf95;
  --accent-2: #5be0b0;
  --accent-soft: rgba(47, 207, 149, 0.12);
  --accent-ring: rgba(47, 207, 149, 0.3);
  --tip-bg: #f2f2f2;
  --tip-text: #141414;
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ar { font-family: var(--font-ar); }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--ink); color: var(--ink-text); padding: 8px 12px; border-radius: 6px; }
.skip:focus { left: 8px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r-xs);
  font-size: 14px; font-weight: 450; white-space: nowrap;
  transition: background .15s, box-shadow .15s, transform .05s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn-lg { height: 44px; padding: 0 18px; }
.btn-primary { background: var(--ink); color: var(--ink-text); }
.btn-primary:hover { opacity: .88; }
.btn-ghost { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line-2), 0 4px 4px rgba(23,23,23,.04); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(1.06); }
.btn-quiet { color: var(--muted); }
.btn-quiet:hover { color: var(--text); background: var(--sunken); }
.btn-danger { color: var(--danger); box-shadow: 0 0 0 1px var(--line-2); background: var(--surface); }
.btn-block { width: 100%; }
.btn svg { width: 16px; height: 16px; flex: none; }
.icon-btn { width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: var(--r-xs); color: var(--muted); }
.icon-btn:hover { background: var(--sunken); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- Badges / chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px; border-radius: 999px;
  background: var(--surface); box-shadow: 0 0 0 1px var(--line-2), var(--shadow-sm);
  font-size: 13px; color: var(--text);
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.badge svg { width: 14px; height: 14px; color: var(--muted); }
.kw {
  display: inline-flex; align-items: center; gap: 6px; vertical-align: middle;
  padding: 2px 9px; margin: 2px 2px; border-radius: var(--r-xs);
  background: var(--surface); box-shadow: 0 0 0 1px var(--line-2), 0 2px 3px rgba(23,23,23,.04);
  color: var(--text); font-size: .93em; line-height: 1.6;
}
.kw svg { width: 14px; height: 14px; color: var(--muted); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 0; }
.card-t { font-size: 14px; font-weight: 550; margin: 0; display: flex; align-items: center; gap: 8px; }
.card-t svg { width: 15px; height: 15px; color: var(--muted); }
.card-s { font-size: 13px; color: var(--muted); margin: 2px 0 0; }
.card-b { padding: 14px 16px 16px; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--r-sm); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line); }
.seg button { height: 28px; padding: 0 10px; border-radius: 6px; font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.seg button svg { width: 14px; height: 14px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line-2), var(--shadow-sm); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; }
.input, .select {
  height: 40px; width: 100%; padding: 0 12px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line-2); outline: none;
  transition: border-color .15s, box-shadow .15s; font-size: 14px;
}
.select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; background-size: 16px;
}
.select::-ms-expand { display: none; }
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.hint { font-size: 12.5px; color: var(--muted); }

/* ---------- Tooltip (shared) ---------- */
.tip {
  position: fixed; z-index: 60; pointer-events: none; min-width: 168px; max-width: 260px;
  background: var(--tip-bg); color: var(--tip-text); border-radius: 10px; padding: 10px 12px;
  font-size: 12.5px; box-shadow: 0 12px 28px -8px rgba(0,0,0,.35);
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.tip.on { opacity: 1; transform: none; }
.tip h6 { margin: 0 0 6px; font-size: 12.5px; font-weight: 550; }
.tip .row { display: flex; align-items: center; gap: 8px; line-height: 1.75; }
.tip .row i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.tip .row span:nth-child(2) { flex: 1; opacity: .75; }
.tip .row b { font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }
.brand svg { width: 26px; height: 26px; }
.brand small { font-family: var(--font-ar); font-weight: 500; font-size: 14px; color: var(--faint); letter-spacing: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Sun / crescent theme switch ---------- */
.theme-switch {
  position: relative; flex: none; width: 56px; height: 30px; border-radius: 999px;
  background: var(--sunken); box-shadow: inset 0 0 0 1px var(--line-2);
  display: inline-flex; align-items: center; justify-content: space-between; padding: 0 8px;
  transition: background .25s; -webkit-tap-highlight-color: transparent;
}
.theme-switch:hover { box-shadow: inset 0 0 0 1px var(--faint); }
.theme-switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 0 0 1px var(--line);
  transition: transform .28s cubic-bezier(.3,.7,.4,1);
}
.theme-switch[aria-checked="true"]::before { transform: translateX(26px); }
.theme-switch svg { position: relative; width: 14px; height: 14px; transition: color .25s, transform .4s; }
.theme-switch .ts-sun { color: #e8a317; }
.theme-switch .ts-moon { color: var(--faint); }
.theme-switch[aria-checked="true"] .ts-sun { color: var(--faint); transform: rotate(-45deg); }
.theme-switch[aria-checked="true"] .ts-moon { color: #f5d77a; transform: rotate(-12deg); }
