/* ============================================================
   MirzaKateb — Design System
   Japanese minimalism meets Persian elegance.
   No glow, no glass, no neon. Warm paper, calm ink.
   ============================================================ */

:root {
  /* Core palette */
  --paper: #FAF8F4;
  --paper-raised: #FFFDF9;
  --ink: #2C2C2C;
  --ink-soft: #5b5750;
  --ink-faint: #8f897e;
  --olive: #556052;
  --olive-soft: #6d7a68;
  --gold: #B89C5A;
  --gold-soft: #cbb784;
  --line: #e7e1d6;
  --line-strong: #d8d1c2;

  /* Semantic */
  --bg: var(--paper);
  --surface: var(--paper-raised);
  --text: var(--ink);
  --text-soft: var(--ink-soft);
  --text-faint: var(--ink-faint);
  --accent: var(--olive);
  --accent-2: var(--gold);
  --border: var(--line);

  /* Type — Vazirmatn: a calm, warm humanist sans with superb Latin & Persian */
  --display: "Vazirmatn", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --body: "Vazirmatn", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;

  /* Shape & depth (soft, never glowing) */
  --radius-s: 8px;
  --radius: 14px;
  --radius-l: 22px;
  --shadow-1: 0 1px 2px rgba(44, 44, 44, 0.04), 0 2px 8px rgba(44, 44, 44, 0.05);
  --shadow-2: 0 6px 24px rgba(44, 44, 44, 0.08);
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --maxw: 1180px;
}

:root[data-theme="dark"] {
  --paper: #22211d;
  --paper-raised: #2a2925;
  --ink: #ece7dc;
  --ink-soft: #c3bdaf;
  --ink-faint: #8d887c;
  --olive: #8ea083;
  --olive-soft: #9caf90;
  --gold: #cdb679;
  --gold-soft: #ddca9a;
  --line: #38362f;
  --line-strong: #45433a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.25), 0 2px 8px rgba(0, 0, 0, 0.28);
  --shadow-2: 0 8px 30px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--body);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.4s var(--ease), color 0.3s var(--ease);
}

h1, h2, h3, h4 { font-family: var(--display); font-weight: 700; line-height: 1.2; margin: 0; letter-spacing: -0.015em; }
h1 { font-size: 2.05rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p { margin: 0 0 0.9em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--gold-soft); color: var(--ink); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 1.15rem;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.22s var(--ease);
  white-space: nowrap;
}
.btn:hover { border-color: var(--olive); transform: translateY(-1px); box-shadow: var(--shadow-1); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--olive); color: #faf8f4; border-color: var(--olive); }
:root[data-theme="dark"] .btn-primary { color: #22211d; }
.btn-primary:hover { background: var(--olive-soft); border-color: var(--olive-soft); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #2c2c2c; }
.btn-gold:hover { background: var(--gold-soft); border-color: var(--gold-soft); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: rgba(85, 96, 82, 0.08); border-color: transparent; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-danger:hover { border-color: #a6543f; color: #a6543f; }

.icon-btn {
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; border: 1px solid transparent; background: transparent; cursor: pointer;
  transition: all 0.2s var(--ease); color: var(--text-soft);
}
.icon-btn:hover { background: rgba(85, 96, 82, 0.1); color: var(--text); }

/* ---------- Inputs ---------- */
.field { display: block; margin-bottom: 1rem; }
.field label { display: block; font-size: 0.82rem; color: var(--text-soft); margin-bottom: 0.35rem; letter-spacing: 0.3px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
textarea, select {
  width: 100%;
  padding: 0.7rem 0.9rem;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--olive); box-shadow: 0 0 0 3px rgba(85, 96, 82, 0.12); }
textarea { resize: vertical; line-height: 1.6; }

/* ---------- Layout shells ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 264px; flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 1.6rem 1.1rem;
  display: flex; flex-direction: column; gap: 0.4rem;
  position: sticky; top: 0; height: 100vh;
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 0.7rem; padding: 0.3rem 0.6rem 1.4rem; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; background: var(--olive);
  color: #faf8f4; display: grid; place-items: center; font-family: var(--display);
  font-size: 1.5rem; font-weight: 600; flex-shrink: 0;
}
:root[data-theme="dark"] .brand-mark { color: #22211d; }
.brand-name { font-family: var(--display); font-size: 1.35rem; font-weight: 600; line-height: 1; }
.brand-sub { font-size: 0.7rem; color: var(--text-faint); letter-spacing: 2px; text-transform: uppercase; }

.nav-section-label { font-size: 0.68rem; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-faint); padding: 0.9rem 0.7rem 0.35rem; }
.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.75rem; border-radius: var(--radius-s);
  color: var(--text-soft); cursor: pointer; transition: all 0.18s var(--ease);
  font-size: 0.96rem; border: 1px solid transparent;
}
.nav-item:hover { background: rgba(85, 96, 82, 0.07); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-1); }
.nav-item .ico { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.8; }
.nav-item .count { margin-left: auto; font-size: 0.75rem; color: var(--text-faint); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 1.1rem 2rem; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px); z-index: 5;
}
.content { padding: 2rem; max-width: var(--maxw); width: 100%; margin: 0 auto; }

.sidebar-foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.profile-chip { display: flex; align-items: center; gap: 0.7rem; padding: 0.5rem 0.6rem; border-radius: var(--radius-s); cursor: pointer; }
.profile-chip:hover { background: rgba(85,96,82,0.07); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #2c2c2c; display: grid; place-items: center; font-weight: 600; font-family: var(--display); flex-shrink: 0; }

/* ---------- Search ---------- */
.search-box { display: flex; align-items: center; gap: 0.6rem; flex: 1; max-width: 520px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 999px; padding: 0.5rem 1rem; }
.search-box input { border: none; background: transparent; padding: 0; box-shadow: none; }
.search-box input:focus { box-shadow: none; }

/* ---------- Cards & grids ---------- */
.grid { display: grid; gap: 1.1rem; }
.grid-sessions { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.3rem; transition: all 0.24s var(--ease); position: relative;
}
.card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); border-color: var(--line-strong); }
.card.clickable { cursor: pointer; }

.session-card .sc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.5rem; margin-bottom: 0.6rem; }
.session-card h3 { font-size: 1.22rem; margin-bottom: 0.15rem; }
.session-meta { display: flex; flex-wrap: wrap; gap: 0.9rem; color: var(--text-faint); font-size: 0.82rem; margin: 0.5rem 0 0.9rem; }
.session-meta span { display: inline-flex; align-items: center; gap: 0.3rem; }
.excerpt { color: var(--text-soft); font-size: 0.92rem; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.9rem; }
.tag { font-size: 0.74rem; padding: 0.18rem 0.6rem; border-radius: 999px; background: rgba(85,96,82,0.09); color: var(--olive); letter-spacing: 0.3px; }
.tag.gold { background: rgba(184,156,90,0.14); color: #8a7333; }
:root[data-theme="dark"] .tag.gold { color: var(--gold); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-ready { background: var(--olive); }
.status-processing { background: var(--gold); animation: pulse 1.4s var(--ease) infinite; }
.status-draft { background: var(--line-strong); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.35} }

.fav { color: var(--line-strong); cursor: pointer; transition: all 0.2s var(--ease); background:none;border:none;padding:0.2rem; }
.fav:hover { color: var(--gold); transform: scale(1.15); }
.fav.on { color: var(--gold); }

/* ---------- Chips / prompt suggestions ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 0.55rem; }
.chip {
  padding: 0.5rem 0.95rem; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); cursor: pointer; font-size: 0.9rem; transition: all 0.2s var(--ease);
}
.chip:hover { border-color: var(--olive); background: rgba(85,96,82,0.06); }
.chip.active { background: var(--olive); color: #faf8f4; border-color: var(--olive); }
:root[data-theme="dark"] .chip.active { color: #22211d; }

/* ---------- Section heads ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.6rem; flex-wrap: wrap; }
.page-head .sub { color: var(--text-faint); font-size: 0.95rem; margin-top: 0.2rem; }
.eyebrow { font-size: 0.72rem; letter-spacing: 2px; text-transform: uppercase; color: var(--gold); font-family: var(--body); font-weight: 500; }
.divider { height: 1px; background: var(--border); border: none; margin: 1.8rem 0; }

/* ---------- Auth ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-art { background: var(--olive); color: #faf8f4; padding: 4rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-art .qmark { font-family: var(--display); font-size: 13rem; line-height: 0.8; opacity: 0.12; position: absolute; bottom: -2rem; right: 1rem; }
.auth-art h1 { color: #faf8f4; font-size: 2.6rem; max-width: 14ch; line-height: 1.15; }
.auth-art p { color: rgba(250,248,244,0.82); max-width: 42ch; }
.auth-panel { display: grid; place-items: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 380px; }
.oauth-btn { width: 100%; justify-content: center; margin-bottom: 0.8rem; }
.auth-sep { display: flex; align-items: center; gap: 0.9rem; color: var(--text-faint); font-size: 0.8rem; margin: 1.2rem 0; }
.auth-sep::before, .auth-sep::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- Recorder / waveform ---------- */
.recorder { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: 2rem; text-align: center; }
.wave-wrap { height: 120px; margin: 1.4rem 0; display: flex; align-items: center; justify-content: center; }
.wave-canvas { width: 100%; height: 120px; }
.rec-controls { display: flex; gap: 0.8rem; justify-content: center; align-items: center; }
.rec-timer { font-family: var(--display); font-size: 2.6rem; font-weight: 500; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #b5533f; display: inline-block; margin-right: 0.5rem; }
.rec-dot.live { animation: pulse 1.2s infinite; }

.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--radius-l); padding: 2.4rem; text-align: center; transition: all 0.24s var(--ease); cursor: pointer; }
.dropzone:hover, .dropzone.drag { border-color: var(--olive); background: rgba(85,96,82,0.04); }

/* ---------- Output / editor ---------- */
.output-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.2rem 2.4rem; }
.output-doc h1,.output-doc h2,.output-doc h3 { margin: 1.2em 0 0.5em; }
.output-doc h1:first-child,.output-doc h2:first-child { margin-top: 0; }
.output-doc ul,.output-doc ol { padding-left: 1.3rem; }
.output-doc li { margin: 0.3em 0; }
.output-doc code { background: rgba(85,96,82,0.09); padding: 0.1rem 0.35rem; border-radius: 5px; font-size: 0.9em; }
.output-doc blockquote { border-left: 3px solid var(--gold); margin: 1em 0; padding-left: 1rem; color: var(--text-soft); font-style: italic; }
.toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; align-items: center; }

.version-list { display: flex; flex-direction: column; gap: 0.5rem; }
.version-item { display: flex; align-items: center; gap: 0.7rem; padding: 0.6rem 0.8rem; border: 1px solid var(--border); border-radius: var(--radius-s); font-size: 0.88rem; cursor: pointer; }
.version-item:hover { border-color: var(--olive); }
.version-item.current { border-color: var(--gold); background: rgba(184,156,90,0.06); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 0.3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; }
.tab { padding: 0.7rem 1rem; cursor: pointer; color: var(--text-soft); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: all 0.2s var(--ease); }
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--olive); }

/* ---------- Action items table ---------- */
.ai-table { width: 100%; border-collapse: collapse; }
.ai-table th { text-align: left; font-size: 0.72rem; letter-spacing: 1px; text-transform: uppercase; color: var(--text-faint); padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); font-weight: 500; }
.ai-table td { padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.ai-table input, .ai-table select { padding: 0.4rem 0.5rem; font-size: 0.9rem; }
.pill { font-size: 0.74rem; padding: 0.15rem 0.6rem; border-radius: 999px; }
.pill.high { background: rgba(166,84,63,0.14); color: #a6543f; }
.pill.medium { background: rgba(184,156,90,0.16); color: #8a7333; }
.pill.low { background: rgba(85,96,82,0.12); color: var(--olive); }
:root[data-theme="dark"] .pill.medium { color: var(--gold); }

/* ---------- Chat ---------- */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 62px); }
.chat-stream { flex: 1; overflow-y: auto; padding: 2rem; max-width: 820px; margin: 0 auto; width: 100%; }
.msg { margin-bottom: 1.5rem; display: flex; gap: 0.9rem; }
.msg .bubble { padding: 0.9rem 1.2rem; border-radius: var(--radius); max-width: 78%; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--olive); color: #faf8f4; }
:root[data-theme="dark"] .msg.user .bubble { color: #22211d; }
.msg.ai .bubble { background: var(--surface); border: 1px solid var(--border); }
.msg .cite { font-size: 0.78rem; color: var(--text-faint); margin-top: 0.5rem; border-top: 1px dashed var(--border); padding-top: 0.45rem; }
.chat-input-bar { border-top: 1px solid var(--border); padding: 1rem 2rem; }
.chat-input-inner { max-width: 820px; margin: 0 auto; display: flex; gap: 0.7rem; align-items: flex-end; }
.chat-input-inner textarea { border-radius: var(--radius); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 4rem 2rem; color: var(--text-faint); }
.empty .em-mark { font-family: var(--display); font-size: 4rem; color: var(--line-strong); margin-bottom: 0.5rem; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper); padding: 0.75rem 1.3rem; border-radius: 999px;
  font-size: 0.9rem; box-shadow: var(--shadow-2); opacity: 0; pointer-events: none; transition: all 0.3s var(--ease); z-index: 100; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(30,29,25,0.42); display: grid; place-items: center; z-index: 90; padding: 1.5rem; }
.modal { background: var(--surface); border-radius: var(--radius-l); padding: 2rem; max-width: 460px; width: 100%; box-shadow: var(--shadow-2); }
.modal h2 { margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.7rem; justify-content: flex-end; margin-top: 1.4rem; }

/* ---------- Misc ---------- */
.row { display: flex; gap: 1rem; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--text-faint); }
.center { text-align: center; }
.mt { margin-top: 1rem; } .mt2 { margin-top: 2rem; } .mb { margin-bottom: 1rem; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 1rem; margin-bottom: 1.8rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.3rem; }
.stat .n { font-family: var(--display); font-size: 2rem; font-weight: 600; line-height: 1; }
.stat .l { color: var(--text-faint); font-size: 0.82rem; margin-top: 0.3rem; }

.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-tr { position: absolute; inset: 0; background: var(--line-strong); border-radius: 999px; transition: 0.3s var(--ease); cursor: pointer; }
.slider-tr::before { content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px; background: var(--paper-raised); border-radius: 50%; transition: 0.3s var(--ease); box-shadow: var(--shadow-1); }
.switch input:checked + .slider-tr { background: var(--olive); }
.switch input:checked + .slider-tr::before { transform: translateX(20px); }

.list-clean { list-style: none; padding: 0; margin: 0; }

.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 0; border-bottom: 1px solid var(--border); }
.setting-row:last-child { border-bottom: none; }
.setting-row .label { font-weight: 500; }
.setting-row .desc { color: var(--text-faint); font-size: 0.85rem; margin-top: 0.15rem; }
.setting-row .control { flex-shrink: 0; min-width: 180px; }
.setting-row .control select { min-width: 180px; }

.banner { background: rgba(184,156,90,0.1); border: 1px solid rgba(184,156,90,0.3); border-radius: var(--radius); padding: 0.9rem 1.1rem; font-size: 0.9rem; color: var(--text-soft); display: flex; gap: 0.7rem; align-items: flex-start; }

.spinner { width: 34px; height: 34px; border: 3px solid var(--border); border-top-color: var(--olive); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 1rem auto; }
@keyframes spin { to { transform: rotate(360deg); } }

.mobile-nav { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .sidebar { display: none; }
  .mobile-nav { display: flex; position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border); padding: 0.7rem 1rem; align-items: center; gap: 0.6rem; overflow-x: auto; }
  .mobile-nav .nav-item { padding: 0.45rem 0.7rem; font-size: 0.85rem; white-space: nowrap; }
  .content, .topbar { padding: 1.2rem; }
  .topbar { flex-wrap: wrap; }
}
@media (max-width: 560px) {
  body { font-size: 16px; }
  h1 { font-size: 1.9rem; }
  .output-doc { padding: 1.4rem; }
  .setting-row { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
