@font-face {
  font-family: Vazirmatn;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/vazirmatn-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Vazirmatn;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/vazirmatn.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0898-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC, U+0660-0669, U+06F0-06F9;
}

:root {
  --bg: #e9edef;
  --surface: #ffffff;
  --ink: #111b21;
  --muted: #54656f;
  --faint: #8696a0;
  --line: #e4e8eb;
  --wa: #00a884;
  --wa-deep: #008069;
  --out: #d9fdd3;
  --chat: #efeae2;
  --ok: #027a48;
  --err: #b42318;
  --shadow: 0 8px 28px rgba(17, 27, 33, .08);
  --sidebar: 280px;
  color-scheme: light;
  font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { color: var(--ink); background: #d8e0e4; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
::selection { background: #b7e6d8; }

.brand-mark { display: inline-grid; place-items: center; color: var(--wa-deep); width: 26px; height: 26px; }
.brand-mark svg { width: 100%; height: 100%; }
.brand-mark.lg { width: 42px; height: 42px; }
.ico { width: 18px; height: 18px; flex: none; }

.boot { min-height: 100vh; display: grid; place-items: center; align-content: center; justify-items: center; gap: .6rem; background: var(--chat); }
.boot p { margin: 0; color: var(--muted); }

.app {
  display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr);
  height: calc(100vh - 24px); width: min(1280px, calc(100% - 24px)); margin: 12px auto;
  background: var(--surface); border-radius: 16px; overflow: hidden;
  box-shadow: 0 12px 40px rgba(17, 27, 33, .12);
}
.sidebar {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-inline-end: 1px solid var(--line);
}
.brand-lockup { display: flex; gap: .7rem; align-items: center; padding: 1rem 1rem .8rem; background: #f0f2f5; }
.brand-lockup strong { display: block; font-size: 1.05rem; }
.brand-lockup span { display: block; color: var(--faint); font-size: .72rem; line-height: 1.4; }
.side-label { margin: .7rem 1rem .25rem; color: var(--faint); font-size: .72rem; }
.side-nav, .side-mods { display: grid; padding: 0 .45rem; }
.side-mods { overflow: auto; min-height: 0; }
.nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .7rem .7rem; border-radius: 10px; color: var(--ink); font-size: .92rem;
}
.nav-item:hover { background: #f5f6f6; }
.nav-item.active { background: #f0f2f5; }
.side-user {
  margin-top: auto; display: flex; align-items: center; gap: .65rem;
  padding: .75rem .9rem; background: #f0f2f5;
}
.avatar, .peer-ava {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--wa); color: #fff; font-weight: 700; flex: none;
}
.peer-ava { width: 42px; height: 42px; }
.side-user .who { min-width: 0; flex: 1; }
.side-user strong, .side-user span { display: block; }
.side-user strong { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user span { color: var(--faint); font-size: .75rem; }
.icon-btn, .ghost, .btn { border: 0; background: transparent; color: var(--ink); }
.icon-btn { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.icon-btn:hover { background: rgba(0,0,0,.05); }
.workspace { min-width: 0; min-height: 0; height: 100%; display: flex; flex-direction: column; background: var(--bg); }
.mobile-bar, .tabbar, .sheet { display: none; }
.scrim { display: none; }

.page { flex: 1; overflow: auto; padding: 1.4rem 1.25rem 1.6rem; }
.page-head { text-align: center; margin: .2rem auto 1.1rem; max-width: 36rem; }
.page-head h1, .hello { margin: 0; font-size: 1.45rem; font-weight: 750; }
.page-head p { margin: .35rem auto 0; color: var(--muted); line-height: 1.7; }
.kicker { margin: 0 0 .2rem; color: var(--wa-deep); font-size: .78rem; }
.subhead { margin: 1.3rem auto .55rem; max-width: 960px; text-align: center; color: var(--muted); font-size: .9rem; font-weight: 650; }

.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .75rem; max-width: 960px; margin: 0 auto; }
.module-tile {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem;
  min-height: 168px; padding: 1.1rem .9rem;
  border-radius: 16px; background: var(--surface); box-shadow: var(--shadow);
}
.module-tile:hover { transform: translateY(-2px); }
.tile-ico {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: #e7f8f4; color: var(--wa-deep);
}
.module-tile strong { font-size: 1rem; }
.module-tile p { margin: 0; color: var(--muted); line-height: 1.65; font-size: .86rem; }
.module-tile em { margin-top: auto; font-style: normal; color: var(--wa-deep); font-size: .8rem; font-weight: 650; }
.future-row { display: flex; flex-wrap: wrap; justify-content: center; gap: .45rem; max-width: 960px; margin: 0 auto; }
.future-chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .45rem .75rem; border-radius: 999px; background: var(--surface);
  box-shadow: var(--shadow); color: var(--muted); font-size: .82rem;
}
.future-chip b { color: var(--faint); font-weight: 500; }

.chat {
  flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  background-color: var(--chat);
  background-image: radial-gradient(rgba(17, 27, 33, .055) 1.1px, transparent 1.2px);
  background-size: 22px 22px;
}
.chat-top {
  display: flex; align-items: center; justify-content: space-between; gap: .7rem;
  padding: .55rem .8rem; background: #f0f2f5; border-bottom: 1px solid #d8dee0;
}
.chat-peer { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.chat-top h1 { margin: 0; font-size: 1rem; font-weight: 700; }
.chat-top p { margin: 0; color: var(--wa-deep); font-size: .75rem; }
.ghost { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.ghost:hover { background: rgba(0,0,0,.05); }
.ghost:disabled { opacity: .4; }

.transcript { overflow: auto; }
.thread {
  width: min(860px, calc(100% - 1.2rem)); margin: 0 auto;
  min-height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: .35rem;
  padding: .9rem .15rem 1rem;
}
.empty {
  margin: auto; width: min(440px, 100%); text-align: center;
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow);
  padding: 1.4rem 1.1rem 1.15rem;
}
.empty h2 { margin: .35rem 0 .2rem; font-size: 1.2rem; }
.empty p { margin: 0; color: var(--muted); line-height: 1.7; font-size: .9rem; }
.chips { display: grid; gap: .4rem; margin-top: .9rem; }
.chips button {
  width: 100%; text-align: center; border: 0; background: #f0f2f5;
  color: var(--wa-deep); border-radius: 12px; padding: .65rem .7rem; line-height: 1.6; font-size: .88rem;
}
.chips button:hover { background: #e7f8f4; }

.msg { display: flex; max-width: min(78%, 520px); }
.msg.user { align-self: flex-end; }
.msg.assistant { align-self: flex-start; }
.bubble {
  position: relative; padding: .42rem .7rem .28rem;
  box-shadow: 0 1px .5px rgba(17, 27, 33, .13);
  line-height: 1.7;
}
.msg.user .bubble::after,
.msg.assistant .bubble::after {
  content: ""; position: absolute; bottom: 0; width: 10px; height: 12px;
}
.msg.user .bubble::after {
  inset-inline-end: -7px;
  background: var(--out);
  clip-path: polygon(0 0, 0 100%, 100% 100%);
}
.msg.assistant .bubble::after {
  inset-inline-start: -7px;
  background: var(--surface);
  clip-path: polygon(100% 0, 0 100%, 100% 100%);
}
.msg.user .bubble { background: var(--out); border-radius: 12px 12px 12px 4px; }
.msg.assistant .bubble { background: var(--surface); border-radius: 12px 12px 4px 12px; }
.bubble-text, .prose { white-space: pre-wrap; }
.prose { white-space: normal; font-size: .96rem; }
.prose > *:first-child { margin-top: 0; }
.prose > *:last-child { margin-bottom: 0; }
.prose p { margin: .3rem 0; }
.prose ul, .prose ol { margin: .25rem 0; padding-inline-start: 1.1rem; }
.prose code { font-family: ui-monospace, Consolas, monospace; font-size: .84em; background: rgba(0,0,0,.05); border-radius: 4px; padding: .05em .28em; }
.prose pre { position: relative; direction: ltr; text-align: left; margin: .45rem 0; border-radius: 8px; overflow: auto; background: #111b21 !important; }
.prose pre code, .prose pre code.hljs { display: block; background: transparent !important; padding: .7rem .75rem; color: #e9edef; }
.code-copy { position: absolute; top: .3rem; right: .3rem; border: 0; background: transparent; color: #d1d7db; font-size: .72rem; }
.bubble-foot { display: flex; align-items: center; justify-content: flex-end; gap: .25rem; margin-top: .05rem; }
.bubble-foot time, .bubble-foot span { color: #667781; font-size: .68rem; }
.bubble-foot .icon-btn { width: 22px; height: 22px; }
.bubble-foot .ico { width: 14px; height: 14px; }
.typing { display: flex; flex-direction: column; min-width: 74px; padding: .55rem .7rem .4rem; }
.dots { display: inline-flex; gap: .22rem; height: 14px; align-items: center; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: #8696a0; animation: blink 1.1s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

.dock { background: #f0f2f5; padding: .45rem .6rem .55rem; }
.dock-inner { width: min(860px, 100%); margin: 0 auto; }
.alert {
  margin: 0 auto .4rem; width: min(860px, 100%);
  padding: .5rem .7rem; border-radius: 12px; background: #fff4f2; color: var(--err);
  display: flex; justify-content: space-between; gap: .5rem; align-items: center; font-size: .88rem;
}
.composer {
  display: grid; grid-template-columns: 1fr auto; gap: .45rem; align-items: end;
}
.composer textarea {
  width: 100%; resize: none; border: 0; outline: none; background: var(--surface);
  border-radius: 22px; min-height: 44px; max-height: 140px;
  padding: .65rem .9rem; line-height: 1.6; box-shadow: 0 1px 1px rgba(17,27,33,.06);
}
.send {
  width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--wa); color: #fff;
}
.send .ico { width: 20px; height: 20px; }
.send:disabled { background: #c5ced4; cursor: not-allowed; }
.hint { margin: .3rem 0 0; text-align: center; color: var(--faint); font-size: .72rem; }

.auth {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  background: #d8e0e4;
}
.auth-story, .pill, .story-list { display: none; }
.auth-form { width: min(420px, 100%); }
.auth-card {
  background: var(--surface); border-radius: 20px; box-shadow: var(--shadow);
  padding: 1.8rem 1.5rem 1.5rem; text-align: center;
}
.auth-card h1 { margin: .55rem 0 .25rem; font-size: 1.4rem; }
.lead { margin: 0 0 1.2rem; color: var(--muted); line-height: 1.7; font-size: .9rem; }
.field { display: grid; gap: .3rem; margin: 0 0 .8rem; text-align: start; }
.field label { color: var(--muted); font-size: .78rem; }
.field input, .side-form input, .side-form select {
  width: 100%; height: 46px; border-radius: 12px; border: 1px solid #d8dee0;
  background: #f8f9fa; padding: 0 .85rem; outline: none;
}
.field input:focus, .side-form input:focus, .side-form select:focus { border-color: var(--wa); background: #fff; }
.field input:-webkit-autofill { -webkit-text-fill-color: var(--ink); box-shadow: 0 0 0 1000px #f8f9fa inset; }
.field-note { margin: .1rem 0 0; color: var(--faint); font-size: .74rem; }
.segment { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.segment button { border: 1px solid #d8dee0; background: #f8f9fa; border-radius: 12px; padding: .55rem; color: var(--muted); }
.segment button.on { background: #e7f8f4; border-color: var(--wa); color: var(--wa-deep); font-weight: 700; }
.switch { display: flex; align-items: center; justify-content: space-between; margin: .2rem 0 .9rem; }
.switch input {
  appearance: none; width: 42px; height: 24px; border-radius: 99px; margin: 0; border: 0;
  background: #d8dee0; position: relative; cursor: pointer;
}
.switch input::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .16s ease;
}
.switch input:checked { background: var(--wa); }
.switch input:checked::after { transform: translateX(-18px); }
.form-actions { display: flex; justify-content: center; gap: .5rem; }
.btn { border: 0; border-radius: 12px; padding: .7rem 1.1rem; font-weight: 700; background: var(--wa); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; height: 46px; margin-top: .3rem; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; max-width: 1040px; margin: 0 auto; }
.side-form { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 1rem 1rem 1.1rem; }
.side-form h2 { margin: 0 0 .9rem; text-align: center; font-size: 1.05rem; }
.people { display: none; list-style: none; margin: 0; padding: 0; }
.table-wrap { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .75rem .85rem; text-align: center; border-bottom: 1px solid var(--line); }
.table th { color: var(--faint); font-size: .75rem; font-weight: 650; }
.table tr:last-child td { border-bottom: 0; }
.muted { color: var(--muted); }
.error { color: var(--err); font-size: .86rem; }
.ok { color: var(--ok); font-size: .86rem; }
.badge { display: inline-flex; border-radius: 999px; padding: .1rem .5rem; font-size: .75rem; background: #f0f2f5; color: var(--muted); }
.badge.ok { background: #e7f8f4; color: var(--ok); }
.badge.warn { background: #fff6df; color: #8a6116; }
.badge.bad { background: #fff1f0; color: var(--err); }
.chips-inline { display: flex; flex-wrap: wrap; justify-content: center; gap: .25rem; }
.chips-inline span { border-radius: 999px; padding: .05rem .4rem; background: #f0f2f5; color: var(--muted); font-size: .72rem; }
.linkish { background: none; border: 0; color: var(--wa-deep); font-weight: 650; }
.gate, .unavailable { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 2rem; }
.skeleton { display: grid; gap: .55rem; width: min(280px, 70%); margin: 2rem auto; }
.skeleton span { height: 12px; border-radius: 99px; background: #e4ddd4; }

@media (max-width: 980px) {
  body { background: var(--chat); }
  .app { width: 100%; height: 100dvh; margin: 0; border-radius: 0; box-shadow: none; grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .workspace { height: 100dvh; padding-bottom: calc(58px + env(safe-area-inset-bottom)); background: var(--chat); }
  .mobile-bar {
    display: flex; align-items: center; gap: .65rem;
    padding: .7rem .85rem; background: #008069; color: #fff;
  }
  .workspace:has(.chat) .mobile-bar { display: none; }
  .mobile-bar .brand-mark, .mobile-bar .icon-btn { color: #fff; }
  .mobile-bar div { flex: 1; min-width: 0; }
  .mobile-bar strong, .mobile-bar span { display: block; }
  .mobile-bar span { color: rgba(255,255,255,.8); font-size: .72rem; }
  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; inset: auto 0 0 0; z-index: 40;
    height: calc(56px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tab { display: grid; justify-items: center; align-content: center; gap: .1rem; border: 0; background: transparent; color: var(--faint); font-size: .68rem; }
  .tab.active { color: var(--wa-deep); }
  .scrim.show { display: block; position: fixed; inset: 0; z-index: 45; border: 0; background: rgba(17,27,33,.35); }
  .sheet {
    display: grid; position: fixed; z-index: 50;
    inset: auto .5rem calc(64px + env(safe-area-inset-bottom)) .5rem;
    max-height: 60dvh; overflow: auto; padding: .45rem;
    background: var(--surface); border-radius: 16px; box-shadow: var(--shadow);
  }
  .page { padding: .8rem .75rem 1rem; }
  .module-grid { grid-template-columns: 1fr 1fr; gap: .55rem; }
  .module-tile { min-height: 132px; padding: .85rem .6rem; }
  .module-tile p { display: none; }
  .split { grid-template-columns: 1fr; }
  .table-wrap { display: none; }
  .people { display: grid; gap: .5rem; }
  .people li {
    display: grid; grid-template-columns: 1fr auto; justify-items: center; text-align: center; gap: .25rem .5rem;
    background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: .8rem;
  }
  .people li div { display: grid; }
  .people li div span { color: var(--faint); font-size: .78rem; }
  .people .linkish { grid-column: 1 / -1; }
  .jobs .table-wrap { display: block; }
  .jobs .table thead { display: none; }
  .jobs .table, .jobs .table tbody, .jobs .table tr, .jobs .table td { display: block; }
  .jobs .table tr { padding: .7rem 0; border-bottom: 1px solid var(--line); }
  .jobs .table td { border: 0; padding: .1rem .7rem; }
  .auth { background: #008069; align-content: center; }
  .auth-card { border-radius: 18px; }
  .thread { width: calc(100% - .7rem); }
  .msg { max-width: 86%; }
  .hint { display: none; }
  .chat-top { background: #008069; color: #fff; }
  .chat-top p, .ghost { color: rgba(255,255,255,.85); }
  .peer-ava { background: #fff; color: #008069; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
