@font-face { font-family: Vazirmatn; src: url(/fonts/vazirmatn_regular.ttf) format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(/fonts/vazirmatn_medium.ttf) format('truetype'); font-weight: 500 600; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url(/fonts/vazirmatn_bold.ttf) format('truetype'); font-weight: 700; font-display: swap; }
/* colours come from tokens.css (light default, :root.dark optional) */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overscroll-behavior: none; }
body { font-family: Vazirmatn, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; font-size: 15px; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: var(--text); }
#app { height: 100%; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.av { position: relative; display: inline-block; flex: none; }
.av svg { display: block; }
.av .online { position: absolute; right: 1px; bottom: 1px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.av .online i { border-radius: 50%; background: #4CAF6A; display: block; }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.cbtn { width: 46px; height: 46px; border-radius: 50%; background: var(--surface); border: 1px solid var(--divider); display: flex; align-items: center; justify-content: center; flex: none; }
.cbtn.lg { width: 52px; height: 52px; }
.cbtn .ini { color: var(--dim); font-weight: 700; font-size: 17px; }

/* list */
.topbar { display: flex; align-items: center; padding: 12px 10px 4px; padding-top: calc(12px + env(safe-area-inset-top)); }
.topbar .sp { flex: 1; }
.row { display: flex; align-items: center; padding: 13px 18px; gap: 18px; user-select: none; }
.row:active { background: var(--hover); }
.row .mid { flex: 1; min-width: 0; }
.row .l1, .row .l2 { display: flex; align-items: center; gap: 8px; }
.row .name { text-align: left; flex: 1; min-width: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .time { color: var(--dim); font-size: 15px; direction: ltr; }
.row .l2 { margin-top: 4px; color: var(--dim); font-size: 16px; }
.row .prev { text-align: left; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--badge); flex: none; margin-left: 2px; }
.row .sent { width: 16px; height: 16px; flex: none; }
.empty { color: var(--dim); text-align: center; padding: 40px; }
.bottom { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: center; pointer-events: none; }
.bottom > * { pointer-events: auto; }
.pill { background: #316CCA; color: #fff; border-radius: 999px; padding: 8px 12px 8px 18px; font-size: 17px; font-weight: 500; display: flex; align-items: center; gap: 2px; margin-bottom: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.2); }
.searchbar { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--bg) 85%, transparent) 30%, var(--bg)); }
.search { flex: 1; height: 52px; border-radius: 26px; background: var(--surface); border: 1px solid var(--divider); display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 17px; }
.search input::placeholder { color: var(--dim); }

/* chat */
.chathead { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 6px; padding-top: calc(8px + env(safe-area-inset-top)); border-bottom: 1px solid var(--divider); }
.back { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 50%; }
.who { display: flex; align-items: center; gap: 10px; padding: 4px; border-radius: 10px; min-width: 0; }
.who .t { font-weight: 600; font-size: 16px; }
.who .s { color: var(--faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60vw; }
.msgs { padding: 14px 16px 10px; }
.msg { margin: 6px 0 18px; line-height: 1.75; font-size: 15.5px; word-wrap: break-word; overflow-wrap: anywhere; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble { background: var(--bubble); border-radius: 22px; padding: 10px 16px; max-width: 85%; white-space: pre-wrap; }
.msg .meta { color: var(--faint); font-size: 12px; margin-top: 4px; direction: ltr; display: flex; gap: 14px; align-items: center; }
.msg.user .meta { justify-content: flex-end; }
.msg.err .body { color: var(--danger); }
.retry { color: var(--dim); font-size: 13px; font-weight: 500; }
.think { color: var(--faint); font-size: 13px; display: inline-flex; align-items: center; gap: 2px; margin-bottom: 4px; }
.think svg { width: 14px; height: 14px; transition: transform .15s; }
.think.open svg { transform: rotate(180deg); }
.thinkbody { color: var(--dim); font-size: 13.5px; border-inline-start: 2px solid var(--divider); padding-inline-start: 10px; margin: 4px 0 8px; white-space: pre-wrap; max-height: 260px; overflow: auto; }
.body p { margin: 0 0 8px; } .body p:last-child { margin-bottom: 0; }
.body h3, .body h4, .body h5, .body h6 { margin: 10px 0 6px; font-size: 16px; }
.body ul, .body ol { margin: 4px 0 8px; padding-inline-start: 22px; }
.body code { background: var(--icode); border-radius: 5px; padding: 1px 5px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; direction: ltr; unicode-bidi: embed; }
.body .code { background: var(--code); border-radius: 12px; margin: 8px 0; overflow: hidden; border: 1px solid var(--divider); }
.body .code-h { display: flex; justify-content: space-between; padding: 6px 12px; color: var(--dim); font-size: 12px; direction: ltr; }
.body pre { margin: 0; padding: 4px 12px 12px; overflow-x: auto; }
.body pre code { background: none; padding: 0; font-size: 13px; line-height: 1.55; }
.body blockquote { margin: 6px 0; padding-inline-start: 12px; border-inline-start: 3px solid var(--divider); color: var(--dim); }
.body a { color: var(--link); }
.body .tbl { overflow-x: auto; } .body table { border-collapse: collapse; margin: 6px 0; font-size: 14px; }
.body th, .body td { border: 1px solid var(--divider); padding: 4px 8px; }
.body hr { border: 0; border-top: 1px solid var(--divider); }
.cursor::after { content: '▍'; animation: blink 1s steps(2) infinite; color: var(--dim); }
@keyframes blink { 50% { opacity: 0; } }
.dots span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--dim); margin: 0 2px; animation: dot 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: .2s; } .dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.composer { padding: 8px 12px 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.inputbox { display: flex; align-items: flex-end; background: var(--surface); border-radius: 28px; padding: 6px 6px 6px 18px; min-height: 56px; }
.inputbox textarea { flex: 1; border: 0; outline: 0; background: transparent; resize: none; font-size: 16px; line-height: 1.6; max-height: 140px; padding: 9px 0; }
.inputbox textarea::placeholder { color: var(--faint); }
.sendbtn { width: 44px; height: 44px; border-radius: 50%; background: var(--send); color: var(--onsend); display: flex; align-items: center; justify-content: center; flex: none; }
.sendbtn:disabled { background: var(--divider); color: var(--dim); }

/* create */
.create { background: var(--sheet); }
.create .hdr { display: flex; align-items: center; justify-content: center; position: relative; height: 56px; margin-top: calc(12px + env(safe-area-inset-top)); }
.create .hdr .x { position: absolute; left: 18px; width: 50px; height: 50px; border-radius: 50%; background: var(--surface); display: flex; align-items: center; justify-content: center; }
.create .hdr h1 { font-size: 19px; font-weight: 600; margin: 0; }
.preview { display: flex; justify-content: center; margin: 14px 0 26px; }
.namefield { margin: 0 22px; height: 64px; border-radius: 16px; background: var(--surface); display: flex; align-items: center; }
.namefield input { width: 100%; text-align: center; border: 0; outline: 0; background: transparent; font-size: 18px; }
.namefield input::placeholder { color: var(--dim); }
.shapes { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 6px; margin: 24px auto 0; max-width: 340px; padding: 0 4px; }
.shape { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2.5px solid transparent; }
.shape.sel { border-color: var(--purple); }
.colors { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px 10px; margin: 26px auto 0; max-width: 340px; padding: 0 4px; }
.color { width: 46px; height: 46px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2.5px solid transparent; }
.color.sel { border-color: var(--purple); }
.color i { width: 38px; height: 38px; border-radius: 50%; display: block; }
.createbtn { margin: 18px; margin-bottom: calc(14px + env(safe-area-inset-bottom)); height: 56px; border-radius: 28px; background: var(--purple); color: #fff; font-size: 18px; font-weight: 600; width: calc(100% - 36px); }
.createbtn:disabled { background: var(--surface); color: var(--faint); }

/* info / settings */
.plainhead { display: flex; align-items: center; gap: 6px; padding: 8px; padding-top: calc(8px + env(safe-area-inset-top)); }
.plainhead .t { font-weight: 600; font-size: 17px; }
.section { padding: 8px 20px 18px; }
.section label { display: block; color: var(--dim); font-size: 13px; margin: 14px 0 8px; }
.field { width: 100%; border: 1px solid var(--divider); background: var(--surface); border-radius: 14px; padding: 12px 14px; outline: 0; font-size: 15px; resize: vertical; }
.chip { display: inline-block; padding: 8px 16px; border-radius: 999px; background: var(--surface); margin-inline-end: 8px; border: 1.5px solid transparent; }
.chip.sel { border-color: var(--purple); color: var(--purple); background: var(--purple-soft); }
.card { background: var(--surface); border: 1px solid var(--divider); border-radius: 16px; padding: 12px 14px; line-height: 1.7; font-size: 14px; }
.mem { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-bottom: 1px solid var(--divider); }
.mem:last-child { border: 0; } .mem span { flex: 1; } .mem button { color: var(--dim); }
.action { display: block; width: 100%; text-align: start; padding: 14px 4px; font-size: 16px; border-bottom: 1px solid var(--divider); }
.action.danger { color: var(--danger); }
.infohead { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 6px 0 4px; }
.infohead .n { font-size: 22px; font-weight: 700; }
.infohead .e { color: var(--dim); font-size: 13px; }
.savebtn { margin-top: 12px; height: 46px; border-radius: 23px; background: var(--purple); color: #fff; width: 100%; font-weight: 600; }
.ver { color: var(--faint); font-size: 11px; margin-top: 20px; }

/* sheet / dialog / toast */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; z-index: 20; }
.scrim.center { align-items: center; justify-content: center; }
.sheet { width: 100%; background: var(--sheet); border-radius: 22px 22px 0 0; padding: 10px 0 calc(22px + env(safe-area-inset-bottom)); }
.sheet .grab { width: 36px; height: 4px; border-radius: 2px; background: var(--divider); margin: 4px auto 10px; }
.sheet h2 { font-size: 18px; margin: 4px 20px 8px; }
.sheet .opt { display: flex; align-items: center; gap: 14px; padding: 10px 20px; width: 100%; text-align: start; }
.sheet .opt .d { color: var(--dim); font-size: 13px; }
.dialog { background: var(--surface); border-radius: 20px; padding: 20px; width: min(340px, 88vw); }
.dialog h3 { margin: 0 0 10px; font-size: 18px; } .dialog p { color: var(--dim); margin: 0 0 18px; line-height: 1.7; }
.dialog .btns { display: flex; justify-content: flex-end; gap: 18px; font-weight: 600; }
.dialog .btns .danger { color: var(--danger); }
.menu { position: fixed; z-index: 30; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-float); min-width: 150px; padding: 6px 0; }
.menu button { display: block; width: 100%; text-align: start; padding: 10px 16px; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #333; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 40; font-size: 14px; max-width: 90vw; }
.gate { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 14px; text-align: center; padding: 30px; color: var(--dim); line-height: 1.8; }
