:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f2ef;
  --text: #17201d;
  --muted: #5d6b66;
  --border: #e1e5e2;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e3f2ef;
  --green: #15803d;
  --green-soft: #e4f4e8;
  --amber: #b45309;
  --amber-soft: #fbf0dc;
  --red: #b91c1c;
  --red-soft: #fbe4e4;
  --gray: #64748b;
  --gray-soft: #eceff3;
  --star: #e0a100;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 24, 20, .05), 0 4px 16px rgba(16, 24, 20, .05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1412;
    --surface: #171e1b;
    --surface-2: #1f2824;
    --text: #e8eeeb;
    --muted: #9aa8a2;
    --border: #2a3530;
    --brand: #2dd4bf;
    --brand-ink: #062a26;
    --brand-soft: #123631;
    --green: #4ade80;
    --green-soft: #143222;
    --amber: #fbbf24;
    --amber-soft: #3a2c10;
    --red: #f87171;
    --red-soft: #3b1717;
    --gray: #94a3b8;
    --gray-soft: #232b30;
    --star: #facc15;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1412; --surface: #171e1b; --surface-2: #1f2824; --text: #e8eeeb; --muted: #9aa8a2;
  --border: #2a3530; --brand: #2dd4bf; --brand-ink: #062a26; --brand-soft: #123631;
  --green: #4ade80; --green-soft: #143222; --amber: #fbbf24; --amber-soft: #3a2c10;
  --red: #f87171; --red-soft: #3b1717; --gray: #94a3b8; --gray-soft: #232b30; --star: #facc15;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.35; margin: 0 0 .5rem; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.container { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; font-size: 1.1rem; }
.logo { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.nav { display: flex; gap: 4px; margin-inline-start: auto; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 6px 10px; border-radius: 10px; color: var(--muted); text-decoration: none; white-space: nowrap; font-size: .92rem; }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; margin: 0; }
  #logout { margin-inline-start: auto; }
}

/* ---------- basics ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
button, .btn {
  font: inherit; cursor: pointer; border: 0; border-radius: 12px; padding: 11px 18px;
  background: var(--brand); color: var(--brand-ink); font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
button:disabled { opacity: .55; cursor: default; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.small { padding: 6px 12px; font-size: .875rem; border-radius: 10px; }
button.link { background: none; color: var(--brand); padding: 0; font-weight: 600; }
input, textarea {
  font: inherit; width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
label { display: block; font-weight: 600; margin: 10px 0 6px; font-size: .95rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); font-size: .82rem; color: var(--muted); }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; vertical-align: middle; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.gray { background: var(--gray-soft); color: var(--gray); }
.src { font-size: .72rem; padding: 0 6px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); text-decoration: none; font-weight: 600; margin-inline-start: 3px; white-space: nowrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 12px; z-index: 50; max-width: calc(100% - 32px); }
.error { color: var(--red); }

/* ---------- auth ---------- */
.auth { max-width: 420px; margin: 8vh auto 0; }
.hero-title { font-size: 2rem; margin-bottom: .25rem; }
.tagline { color: var(--muted); font-size: 1.05rem; margin-bottom: 1.5rem; }

/* ---------- home ---------- */
.ask-title { font-size: 1.6rem; margin: 18px 0 14px; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, 1fr); } }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text); font-weight: 600; box-shadow: var(--shadow);
}
.tile .ico { font-size: 1.6rem; line-height: 1; }
.tile:hover { border-color: var(--brand); }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.att { position: relative; display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); font-size: .85rem; max-width: 100%; }
.att img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.att button { background: none; color: var(--muted); padding: 0 4px; }
.examples { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.examples button { background: var(--surface); color: var(--muted); border: 1px dashed var(--border); font-weight: 400; font-size: .85rem; padding: 6px 12px; }

/* ---------- progress ---------- */
.steps { list-style: none; padding: 0; margin: 0; }
.steps li { display: flex; gap: 12px; padding: 10px 0; align-items: flex-start; }
.steps .dot { width: 26px; height: 26px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: .8rem; background: var(--surface-2); color: var(--muted); }
.steps .done .dot { background: var(--green-soft); color: var(--green); }
.steps .running .dot { background: var(--brand-soft); color: var(--brand); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .steps .running .dot { animation: none; } }

/* ---------- result ---------- */
.verdict { display: flex; gap: 18px; align-items: center; }
.ring { position: relative; width: 112px; height: 112px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1.1; }
.ring .num b { font-size: 2rem; }
.ring .num span { font-size: .75rem; color: var(--muted); display: block; }
.c-green { color: var(--green); } .c-amber { color: var(--amber); } .c-red { color: var(--red); } .c-gray { color: var(--gray); }
.verdict-label { font-size: 1.35rem; font-weight: 700; }
@media (max-width: 480px) { .verdict { flex-direction: column; text-align: center; } }

.dims { width: 100%; border-collapse: collapse; }
.dims td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.dims tr:last-child td { border-bottom: 0; }
.stars { color: var(--star); letter-spacing: 2px; white-space: nowrap; text-align: left; direction: ltr; }
.stars.risk { color: var(--red); }
.final { background: var(--brand-soft); border-color: transparent; }
.final .label { color: var(--brand); font-weight: 700; font-size: .9rem; }
.final .text { font-size: 1.15rem; font-weight: 600; }

.why { border-top: 1px dashed var(--border); margin-top: 12px; padding-top: 12px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.factor { display: flex; gap: 8px; padding: 6px 0; }
.factor .ic { flex: none; width: 22px; text-align: center; font-weight: 700; }
.factor.positive .ic { color: var(--green); } .factor.negative .ic { color: var(--red); } .factor.neutral .ic { color: var(--muted); }

.price-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
@media (max-width: 480px) { .price-grid { grid-template-columns: 1fr; } }
.price-grid div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.price-grid small { display: block; color: var(--muted); font-size: .8rem; }
.price-grid b { font-size: 1.1rem; }

ul.clean { list-style: none; padding: 0; margin: 0; }
ul.clean li { padding: 6px 0; border-bottom: 1px solid var(--border); }
ul.clean li:last-child { border-bottom: 0; }
ul.check li::before { content: "☐ "; color: var(--brand); }
.sev { font-size: .72rem; }
.warn-note { display: block; font-size: .78rem; color: var(--amber); }

.neg-thread { display: flex; flex-direction: column; gap: 10px; margin: 10px 0; }
.bubble { padding: 10px 14px; border-radius: 14px; max-width: 92%; }
.bubble.user { align-self: flex-start; background: var(--surface-2); }
.bubble.agent { align-self: flex-end; background: var(--brand-soft); width: 100%; }
.msg-box { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin: 8px 0; white-space: pre-wrap; }

.sources li { font-size: .88rem; }
.sources li:target { background: var(--brand-soft); }

table.cmp { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.cmp th, table.cmp td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: center; vertical-align: top; }
table.cmp th:first-child, table.cmp td:first-child { text-align: right; }
.table-wrap { overflow-x: auto; }
.win { outline: 2px solid var(--brand); }

.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 680px) { .plans { grid-template-columns: 1fr; } }
.plan.current { border-color: var(--brand); }
.plan .price { font-size: 1.6rem; font-weight: 700; }

.hist-item { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.hist-score { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-weight: 700; flex: none; background: var(--surface-2); }
.hist-score.green { background: var(--green-soft); color: var(--green); }
.hist-score.amber { background: var(--amber-soft); color: var(--amber); }
.hist-score.red { background: var(--red-soft); color: var(--red); }
.hist-score.gray { background: var(--gray-soft); color: var(--gray); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.min0 { min-width: 0; }
