/* TITAN — RTL Persian dark neon theme. No external fonts/CDN; no inline styles (CSP). */
:root {
  --bg: #080a14; --bg2: #0d1020; --card: #121631; --card2: #181d3d; --line: #262c57;
  --text: #eaf0ff; --muted: #97a0c8; --neon: #5ef2ff; --neon2: #b07bff; --ok: #3ee89a; --warn: #ffc857; --err: #ff5d7a;
  --radius: 14px; --glow: 0 0 0 1px rgba(94,242,255,.35), 0 0 18px rgba(94,242,255,.18);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: radial-gradient(1200px 600px at 80% -10%, #1a1f4a 0%, transparent 60%), var(--bg); color: var(--text);
  font-family: Vazirmatn, "Segoe UI", Tahoma, system-ui, sans-serif; line-height: 1.7; min-height: 100vh; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.35; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: .25rem 0 .75rem; }
a { color: var(--neon); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .ltr { direction: ltr; unicode-bidi: embed; display: inline-block; }
:focus-visible { outline: 2px solid var(--neon); outline-offset: 2px; border-radius: 6px; }

/* layout */
.shell { max-width: 760px; margin: 0 auto; padding: 12px 16px 92px; }
header.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0 12px; }
header.top .brand { font-weight: 800; letter-spacing: .5px; background: linear-gradient(90deg, var(--neon), var(--neon2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
nav.tabs { position: fixed; inset-inline: 0; bottom: 0; display: flex; justify-content: space-around; gap: 2px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  background: rgba(13,16,32,.92); backdrop-filter: blur(10px); border-top: 1px solid var(--line); z-index: 20; }
nav.tabs a { flex: 1; text-align: center; padding: 6px 2px; color: var(--muted); text-decoration: none; font-size: .78rem; border-radius: 10px; }
nav.tabs a .ico { display: block; font-size: 1.25rem; line-height: 1.2; }
nav.tabs a[aria-current="page"] { color: var(--neon); background: rgba(94,242,255,.08); box-shadow: var(--glow); }
.offline { background: var(--err); color: #fff; text-align: center; padding: 4px; font-size: .85rem; position: sticky; top: 0; z-index: 30; }

/* cards & grids */
.card { background: linear-gradient(180deg, var(--card), var(--bg2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0 0 12px; }
a.card { display: block; color: inherit; text-decoration: none; }
a.card:hover { border-color: var(--neon); }
a.card h3 { color: var(--neon); }
.card.glow { box-shadow: var(--glow); }
.grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat { background: var(--card2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .v { font-size: 1.25rem; font-weight: 800; color: var(--neon); } .stat .k { color: var(--muted); font-size: .8rem; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .row.end { justify-content: flex-end; } .row.center { justify-content: center; } .row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.list { list-style: none; margin: 0; padding: 0; } .list li { padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; gap: 10px; justify-content: space-between; align-items: center; } .list li:last-child { border: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: .85rem; }
.chip[aria-pressed="true"], .chip[aria-selected="true"] { color: #06121a; background: var(--neon); border-color: var(--neon); font-weight: 700; }

/* controls */
.btn { font: inherit; border: 1px solid var(--line); background: var(--card2); color: var(--text); padding: 8px 14px; border-radius: 10px; cursor: pointer; min-height: 40px; }
.btn:hover:not(:disabled) { border-color: var(--neon); } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: linear-gradient(90deg, var(--neon), var(--neon2)); color: #06121a; border: 0; font-weight: 800; }
.btn.danger { background: rgba(255,93,122,.12); border-color: var(--err); color: var(--err); } .btn.ghost { background: transparent; } .btn.small { padding: 4px 10px; min-height: 32px; font-size: .85rem; }
.input, select.input, textarea.input { width: 100%; font: inherit; color: var(--text); background: #0a0d1d; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-height: 40px; }
textarea.input { min-height: 84px; resize: vertical; }
.field { display: block; margin-bottom: 10px; } .field .lbl { display: block; color: var(--muted); font-size: .85rem; margin-bottom: 3px; }
.switch { display: flex; align-items: center; gap: 10px; padding: 6px 0; } .switch input { width: 20px; height: 20px; accent-color: var(--neon); }
meter { width: 100%; height: 12px; } .meter { display: flex; flex-direction: column; gap: 2px; }

/* badges, tables, states */
.badge { display: inline-block; font-size: .75rem; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: var(--ok); } .badge.warn { color: var(--warn); border-color: var(--warn); } .badge.err { color: var(--err); border-color: var(--err); } .badge.info { color: var(--neon); border-color: var(--neon); }
.table-wrap { overflow-x: auto; } .table { width: 100%; border-collapse: collapse; font-size: .9rem; } .table th, .table td { padding: 8px 10px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; } .table th { color: var(--muted); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 28px 8px; } .empty-ico { font-size: 2rem; opacity: .6; }
.error-box { border-color: var(--err); }
.skeleton .sk-line { height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--card2), #232957, var(--card2)); background-size: 200% 100%; animation: sk 1.4s linear infinite; margin: 10px 0; }
@keyframes sk { to { background-position: -200% 0; } }

/* chat */
.chat { display: flex; flex-direction: column; gap: 8px; min-height: 40vh; }
.bubble { max-width: 88%; padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); }
.bubble.user { align-self: flex-start; background: rgba(94,242,255,.1); border-color: rgba(94,242,255,.4); border-end-start-radius: 4px; }
.bubble.ai { align-self: flex-end; background: var(--card2); border-end-end-radius: 4px; } .bubble.err { border-color: var(--err); color: var(--err); }
.composer { position: sticky; bottom: 76px; display: flex; gap: 8px; padding: 8px 0; background: linear-gradient(0deg, var(--bg) 60%, transparent); }
.composer textarea { flex: 1; min-height: 44px; max-height: 140px; }
.typing::after { content: "▍"; animation: blink 1s steps(2) infinite; } @keyframes blink { 50% { opacity: 0; } }

/* overlay & toasts */
.overlay { position: fixed; inset: 0; background: rgba(3,4,10,.7); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--card); border: 1px solid var(--neon); box-shadow: var(--glow); border-radius: 16px; padding: 18px; width: min(420px, 100%); }
.toasts { position: fixed; inset-inline: 12px; top: 12px; z-index: 60; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { padding: 10px 14px; border-radius: 12px; background: var(--card2); border: 1px solid var(--line); box-shadow: 0 6px 24px rgba(0,0,0,.5); animation: pop .2s ease-out; }
.toast.ok { border-color: var(--ok); } .toast.err { border-color: var(--err); } @keyframes pop { from { transform: translateY(-8px); opacity: 0; } }

/* admin */
body.admin .shell { max-width: 1180px; padding-bottom: 24px; }
.admin-layout { display: grid; grid-template-columns: 210px 1fr; gap: 16px; align-items: start; }
.sidebar { position: sticky; top: 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar a { padding: 8px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; }
.sidebar a[aria-current="page"] { color: var(--neon); background: rgba(94,242,255,.08); box-shadow: var(--glow); }
@media (max-width: 760px) { .admin-layout { grid-template-columns: 1fr; } .sidebar { position: static; flex-direction: row; flex-wrap: wrap; } }
.login { max-width: 420px; margin: 18vh auto 0; text-align: center; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (forced-colors: active) { .btn, .card, .badge { border: 1px solid CanvasText; } }

/* programmatic focus after navigation (accessibility) must not draw a ring around the whole page */
main:focus { outline: none; }
