/* Miqyas AI Sales — matte & glossy pastel theme
   Palette: 3 blacks, 2 milks, gray, silver — all muted / pastel, no saturated colors. */

@font-face { font-family: "Inter"; src: url("../fonts/Inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Vazirmatn"; src: url("../fonts/Vazirmatn.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --black-1: #131416;   /* ink */
  --black-2: #1c1d20;   /* charcoal */
  --black-3: #282a2e;   /* graphite */
  --gray: #74797f;      /* slate gray */
  --gray-soft: #9a9fa5;
  --silver: #c4c8cd;
  --silver-deep: #aeb3b9;
  --milk-1: #f1ece3;    /* milk */
  --milk-2: #ddd5c6;    /* ivory */

  /* muted pastel accents (status only) */
  --p-sage: #a8b8a3;
  --p-blue: #a6b4c2;
  --p-sand: #cfc0a2;
  --p-rose: #c9aaa6;
  --p-lilac: #b3adc2;

  --bg: var(--black-1);
  --surface: var(--black-2);
  --surface-2: var(--black-3);
  --text: var(--milk-1);
  --text-2: var(--milk-2);
  --muted: var(--gray-soft);
  --line: rgba(196, 200, 205, 0.12);
  --sheen: linear-gradient(160deg, rgba(241, 236, 227, 0.09) 0%, rgba(241, 236, 227, 0.02) 38%, rgba(0, 0, 0, 0) 60%);
  --matte-noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 .05 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 1px 0 rgba(241, 236, 227, 0.06) inset, 0 10px 30px rgba(0, 0, 0, 0.35);
  --en: "Inter", -apple-system, "SF Pro Text", Roboto, "Segoe UI", sans-serif;
  --fa: "Vazirmatn", "Inter", sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root[data-tone="milk"] {
  --bg: var(--milk-1);
  --surface: #f7f4ee;
  --surface-2: var(--milk-2);
  --text: var(--black-2);
  --text-2: var(--black-3);
  --muted: var(--gray);
  --line: rgba(40, 42, 46, 0.12);
  --sheen: linear-gradient(160deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.15) 40%, rgba(255, 255, 255, 0) 62%);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 8px 24px rgba(40, 42, 46, 0.12);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none; }
body { font-family: var(--en); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; user-select: none; -webkit-user-select: none; }

/* No visible scrollbars anywhere — touch scrolling only */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { display: none; width: 0; height: 0; }

button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
a.btn { text-decoration: none; }

/* ---------- Bilingual labels: English with small Persian beneath ---------- */
.bi { display: inline-flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.bi > .en { font-family: var(--en); }
.bi > .fa { font-family: var(--fa); direction: rtl; font-size: 0.68em; color: var(--muted); margin-top: 3px; font-weight: 400; letter-spacing: 0; }
.bi.center { align-items: center; text-align: center; }
.bi.center > .fa { text-align: center; }
.fa-text { font-family: var(--fa); direction: rtl; text-align: right; }
.fa-sub { font-family: var(--fa); direction: rtl; text-align: right; font-size: 0.8em; color: var(--muted); }

/* ---------- Stage and pages ---------- */
#stage { position: fixed; inset: 0; overflow: hidden; background: var(--bg); background-image: var(--matte-noise); }
.page { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: calc(var(--safe-top) + 12px) 16px calc(var(--safe-bottom) + 110px); background: var(--bg); background-image: var(--matte-noise); will-change: transform, opacity; }
.page.hidden { display: none; }

.topbar { display: flex; align-items: center; gap: 12px; margin: 4px 0 18px; min-height: 48px; }
.topbar .title { flex: 1; min-width: 0; }
.topbar .title .en { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; }
.topbar .title .fa { font-size: 13px; }
.icon-btn { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); background-image: var(--sheen); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; }
.icon-btn svg { width: 20px; height: 20px; stroke: var(--text); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Surfaces: matte body + glossy sheen ---------- */
.card { position: relative; background: var(--surface); background-image: var(--sheen); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; overflow: hidden; }
.card.matte { background-image: none; }
.card.tap { cursor: pointer; transition: transform 0.15s ease; }
.card.tap:active { transform: scale(0.98); }
.card h3 { margin: 0 0 6px; font-size: 16px; font-weight: 620; }
.glass-edge::after { content: ""; position: absolute; left: 12%; right: 12%; top: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(241, 236, 227, 0.35), transparent); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid .card { margin: 0; }
.tile { min-height: 128px; display: flex; flex-direction: column; justify-content: space-between; }
.tile.wide { grid-column: span 2; min-height: 150px; }
.tile .ico { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--line); }
.tile .ico svg { width: 22px; height: 22px; stroke: var(--silver); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tile .bi > .en { font-size: 16px; font-weight: 620; }
.tile .meta { font-size: 12px; color: var(--muted); }
.tile.silver { background-color: var(--silver-deep); color: var(--black-1); }
.tile.silver .bi > .fa, .tile.silver .meta { color: var(--black-3); }
.tile.silver .ico { background: rgba(19, 20, 22, 0.08); border-color: rgba(19, 20, 22, 0.1); }
.tile.silver .ico svg { stroke: var(--black-2); }
.tile.milk { background-color: var(--milk-2); color: var(--black-1); }
.tile.milk .bi > .fa, .tile.milk .meta { color: var(--black-3); }
.tile.milk .ico { background: rgba(19, 20, 22, 0.06); border-color: rgba(19, 20, 22, 0.08); }
.tile.milk .ico svg { stroke: var(--black-2); }

.section-label { margin: 22px 4px 10px; display: flex; align-items: flex-end; justify-content: space-between; }
.section-label .bi > .en { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--silver); }

/* ---------- Date header ---------- */
.dateblock { padding: 18px; }
.dateblock .day { font-size: 30px; font-weight: 680; letter-spacing: -0.02em; }
.dateblock .full { color: var(--text-2); margin-top: 2px; }
.dateblock .jalali { font-family: var(--fa); direction: rtl; text-align: right; color: var(--muted); font-size: 14px; margin-top: 8px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--gray); }
.pill.on .dot { background: var(--p-sage); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 8px 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface-2); background-image: var(--sheen); box-shadow: var(--shadow); cursor: pointer; text-align: center; }
.btn:active { transform: scale(0.97); }
.btn .bi > .en { font-weight: 600; font-size: 14px; }
.btn.primary { background-color: var(--silver); color: var(--black-1); border-color: transparent; }
.btn.primary .bi > .fa { color: var(--black-3); }
.btn.milk { background-color: var(--milk-1); color: var(--black-1); border-color: transparent; }
.btn.milk .bi > .fa { color: var(--black-3); }
.btn.small { min-height: 38px; padding: 6px 12px; border-radius: 12px; }
.btn.small .bi > .en { font-size: 13px; }
.btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 18px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 auto; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chip { flex: 0 0 auto; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 13px; }
.chip .bi > .fa { font-size: 10px; }
.chip.active { background: var(--silver); color: var(--black-1); border-color: transparent; }
.chip.active .bi > .fa { color: var(--black-3); }

/* ---------- Lists ---------- */
.list-item { display: flex; align-items: center; gap: 12px; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 14px; display: grid; place-items: center; font-weight: 700; color: var(--black-1); background: var(--silver); background-image: var(--sheen); }
.chev { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; }

.status { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--black-1); background: var(--silver); white-space: nowrap; }
.status.new { background: var(--silver); }
.status.researching { background: var(--p-lilac); }
.status.contacted { background: var(--p-blue); }
.status.meeting { background: var(--p-sand); }
.status.proposal { background: var(--milk-2); }
.status.negotiation { background: var(--p-rose); }
.status.won { background: var(--p-sage); }
.status.lost { background: var(--gray); color: var(--milk-1); }
.badge-ai { font-size: 10px; padding: 2px 7px; border-radius: 999px; border: 1px dashed var(--silver-deep); color: var(--silver); }

/* ---------- Fields ---------- */
.field { display: flex; align-items: flex-start; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: 0; }
.field .k { width: 104px; flex: 0 0 104px; }
.field .k .bi > .en { font-size: 12px; color: var(--muted); }
.field .v { flex: 1; min-width: 0; word-break: break-word; user-select: text; -webkit-user-select: text; }
.field .copy { flex: 0 0 auto; opacity: 0.7; }
.field .v a { color: var(--silver); text-decoration: none; border-bottom: 1px solid var(--line); }

input.inp, textarea.inp, select.inp { width: 100%; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); outline: none; user-select: text; -webkit-user-select: text; }
textarea.inp { min-height: 96px; resize: vertical; }
input.inp:focus, textarea.inp:focus, select.inp:focus { border-color: var(--silver-deep); }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; margin: 0 4px 6px; }
.form-row label .bi > .en { font-size: 12px; color: var(--muted); }
.search { position: relative; margin-bottom: 12px; }
.search input { padding-left: 42px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; }

/* ---------- Reading ---------- */
.prose { user-select: text; -webkit-user-select: text; font-size: 16px; line-height: 1.7; }
.prose p { margin: 0 0 10px; }
.prose .pair { margin-bottom: 18px; position: relative; }
.prose .pair .fa-p { font-family: var(--fa); direction: rtl; text-align: right; color: var(--muted); font-size: 14px; line-height: 1.9; margin-top: 4px; }
.prose.mode-fa .pair .en-p { display: none; }
.prose.mode-fa .pair .fa-p { color: var(--text); font-size: 16px; }
.prose.mode-en .pair .fa-p { display: none; }
.prose .pair-tools { display: flex; gap: 6px; margin-top: 4px; opacity: 0.65; }
.prose .pair-tools button { border: 1px solid var(--line); background: transparent; border-radius: 10px; padding: 3px 8px; font-size: 11px; cursor: pointer; }
.prose h4 { margin: 18px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--silver); }
.prose ul { padding-left: 18px; margin: 0 0 12px; }
.ai-out { white-space: pre-wrap; user-select: text; -webkit-user-select: text; line-height: 1.6; }
.ai-out.rtl { direction: rtl; text-align: right; font-family: var(--fa); }

.book-cover { width: 100%; aspect-ratio: 3 / 4; border-radius: 16px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; color: var(--black-1); background-image: var(--sheen), linear-gradient(160deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.12)); box-shadow: var(--shadow); }
.book-cover .t { font-weight: 720; font-size: 15px; line-height: 1.15; }
.book-cover .a { font-size: 11px; opacity: 0.75; }
.shelf { display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 4px 16px 14px; }
.shelf > * { flex: 0 0 132px; cursor: pointer; }
.stars { color: var(--p-sand); font-size: 12px; letter-spacing: 1px; }

.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--silver-deep), var(--milk-1)); border-radius: 999px; }
.ring { width: 76px; height: 76px; }

/* ---------- Floating assistant orb & dock ---------- */
#orb { position: fixed; right: 18px; bottom: calc(var(--safe-bottom) + 18px); width: 62px; height: 62px; border-radius: 50%; z-index: 40; border: 1px solid rgba(241, 236, 227, 0.25); background: radial-gradient(circle at 32% 28%, #f6f2ea 0%, #c9ccd1 38%, #8f949a 75%, #6f747a 100%); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.5) inset; display: grid; place-items: center; cursor: pointer; }
#orb svg { width: 26px; height: 26px; stroke: var(--black-1); fill: none; stroke-width: 1.8; }
#orb.offline { filter: grayscale(1) brightness(0.75); }
#homebtn { position: fixed; left: 18px; bottom: calc(var(--safe-bottom) + 24px); z-index: 40; }

/* ---------- Bottom sheet ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 60; opacity: 0; transition: opacity 0.25s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 88vh; z-index: 61; background: var(--surface); background-image: var(--sheen); border-radius: 26px 26px 0 0; border-top: 1px solid var(--line); padding: 10px 16px calc(var(--safe-bottom) + 18px); overflow-y: auto; transform: translateY(100%); transition: transform 0.32s cubic-bezier(0.2, 0.8, 0.2, 1); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--gray); margin: 4px auto 14px; }
.sheet.open { transform: translateY(0); }
.sheet-back.open { opacity: 1; }

/* ---------- Chat ---------- */
.msg { max-width: 88%; padding: 11px 14px; border-radius: 18px; margin-bottom: 10px; white-space: pre-wrap; user-select: text; -webkit-user-select: text; line-height: 1.55; }
.msg.user { margin-left: auto; background: var(--silver); color: var(--black-1); border-bottom-right-radius: 6px; }
.msg.ai { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.ai[dir="rtl"] { font-family: var(--fa); }
.msg .msg-tools { display: flex; gap: 6px; margin-top: 8px; }
.composer { position: sticky; bottom: 0; display: flex; gap: 8px; padding-top: 10px; background: linear-gradient(0deg, var(--bg) 70%, transparent); }
.composer textarea { min-height: 48px; max-height: 140px; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 96px); transform: translateX(-50%) translateY(20px); background: var(--milk-1); color: var(--black-1); padding: 10px 16px; border-radius: 14px; font-size: 13px; z-index: 80; opacity: 0; pointer-events: none; transition: all 0.25s; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast .fa { display: block; font-family: var(--fa); font-size: 11px; color: var(--black-3); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.mt { margin-top: 12px; }
.mb { margin-bottom: 12px; }
.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.kpi { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--gray); border-top-color: var(--milk-1); animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.update-bar { position: fixed; top: calc(var(--safe-top) + 8px); left: 16px; right: 16px; z-index: 70; }
iframe.tool-frame { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 18px; background: #fff; }
.quiz-opt { display: block; width: 100%; text-align: left; margin-bottom: 8px; }
.quiz-opt.right { background-color: var(--p-sage); color: var(--black-1); }
.quiz-opt.wrong { background-color: var(--p-rose); color: var(--black-1); }
details.card summary { list-style: none; cursor: pointer; }
details.card summary::-webkit-details-marker { display: none; }

/* Lite mode inside the Android client: drop the noise texture to keep older phones (Galaxy S8) smooth. */
.android #stage, .android .page { background-image: none; }
