:root {
  --bg: #131313;
  --panel: #191919;
  --surface: #1e1e1e;
  --surface-2: #262626;
  --border: #2c2c2c;
  --border-2: #383838;
  --hover: rgba(255, 255, 255, 0.05);
  --text: #e4e4e4;
  --text-2: #b3b3b3;
  --muted: #7a7a7a;
  --faint: #545454;
  --danger: #e57373;
  --code-bg: #171717;
  --mono: ui-monospace, 'Cascadia Code', 'JetBrains Mono', Consolas, 'Courier New', monospace;
  --sans: Inter, 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.spacer { flex: 1; }
svg { display: block; }
[data-icon] { display: inline-grid; place-items: center; }

::-webkit-scrollbar { width: 10px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 6px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

/* ---------------- top bar with tabs ---------------- */
.topbar {
  height: 44px; flex-shrink: 0; display: flex; align-items: center; gap: 6px;
  padding: 0 8px; background: var(--bg);
}
.icon-btn {
  width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center;
  border: 0; border-radius: 7px; background: none; color: var(--muted);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.small { width: 26px; height: 26px; }
.icon-btn.small svg { width: 16px; height: 16px; }
.tabs { display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px 0 10px; max-width: 220px; flex-shrink: 0;
  border-radius: 7px; color: var(--muted); cursor: pointer; border: 1px solid transparent; user-select: none;
}
.tab:hover { background: var(--hover); color: var(--text-2); }
.tab.active { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.tab .tab-ico { width: 18px; height: 18px; border-radius: 5px; background: #2e2e2e; color: #cfcfcf; display: grid; place-items: center; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.tab .tab-ico svg { width: 12px; height: 12px; }
.tab .tab-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.tab .tab-x { width: 20px; height: 20px; border: 0; background: none; border-radius: 5px; color: var(--muted); display: grid; place-items: center; opacity: 0; }
.tab.active .tab-x, .tab:hover .tab-x { opacity: 1; }
.tab .tab-x:hover { background: var(--hover); color: var(--text); }
.tab .tab-x svg { width: 12px; height: 12px; }
.tab.busy .tab-ico { animation: pulse 1.2s ease-in-out infinite; }

/* ---------------- drawer ---------------- */
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 300px; max-width: 86vw; z-index: 40;
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; transform: translateX(-102%); transition: transform 0.18s ease;
}
.drawer.open { transform: none; }
.scrim { position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, 0.45); opacity: 0; pointer-events: none; transition: opacity 0.18s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; height: 44px; }
.drawer-title { font-weight: 600; letter-spacing: 0.2px; }
.drawer-new {
  margin: 4px 12px; display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--border); background: var(--surface); border-radius: 8px; color: var(--text);
}
.drawer-new:hover { background: var(--surface-2); }
.drawer-new svg { width: 15px; height: 15px; }
.drawer-search { margin: 8px 12px; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); color: var(--muted); }
.drawer-search svg { width: 15px; height: 15px; }
.drawer-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 0; }
.drawer-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.hist {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 7px; color: var(--text-2); cursor: pointer;
}
.hist:hover { background: var(--hover); color: var(--text); }
.hist.active { background: var(--surface-2); color: var(--text); }
.hist .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .del { border: 0; background: none; color: var(--muted); padding: 3px; border-radius: 5px; visibility: hidden; display: grid; place-items: center; }
.hist:hover .del { visibility: visible; }
.hist .del:hover { color: var(--text); background: var(--hover); }
.hist .del svg { width: 13px; height: 13px; }
.group-label { font-size: 11.5px; color: var(--faint); padding: 12px 10px 4px; }
.note { color: var(--muted); padding: 8px 10px; font-size: 13px; }

/* ---------------- main ---------------- */
.main {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  margin: 0 8px 8px; border: 1px solid var(--border); border-radius: 10px; background: #161616; overflow: hidden;
}
.messages { flex: 1; overflow-y: auto; padding: 28px 0 8px; }
.main.empty .messages { display: none; }
.dock { flex-shrink: 0; padding: 8px 20px 18px; }
.main.empty { justify-content: center; }
.main.empty .dock { padding-bottom: 14vh; }

/* pixel logo */
.logo { display: none; justify-content: center; margin: 0 auto 34px; max-width: 760px; }
.main.empty .logo { display: flex; }
.logo svg { width: min(580px, 92%); height: auto; }

/* composer */
.composer {
  position: relative; max-width: 880px; margin: 0 auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 12px 8px 16px;
}
.composer:focus-within { border-color: var(--border-2); }
.composer textarea {
  width: 100%; resize: none; border: 0; outline: 0; background: none; padding: 2px 0 10px;
  min-height: 24px; max-height: 260px; line-height: 1.55; font-size: 14.5px;
}
.composer textarea::placeholder { color: var(--muted); }
.composer-bar { display: flex; align-items: center; gap: 6px; margin-left: -6px; }
.model-btn {
  display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 4px 8px; border-radius: 7px; color: var(--text);
  font-size: 13.5px; max-width: 280px;
}
.model-btn:hover { background: var(--hover); }
.model-btn #modelName { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-ico { color: var(--muted); }
.model-ico svg { width: 14px; height: 14px; }
.model-btn [data-icon="chevron"] svg, .chip [data-icon="chevron"] svg { width: 12px; height: 12px; color: var(--muted); }
.send {
  width: 28px; height: 28px; border: 0; border-radius: 6px; background: #3a3a3a; color: #d6d6d6;
  display: grid; place-items: center;
}
.send:hover { background: #474747; }
.send.ready { background: #e4e4e4; color: #161616; }
.send.ready:hover { background: #fff; }
.send svg { width: 15px; height: 15px; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.files:empty { display: none; }
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 8px; border-radius: 6px;
  background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); font-family: var(--mono);
}
.file-chip button { border: 0; background: none; color: var(--muted); padding: 1px; border-radius: 4px; display: grid; place-items: center; }
.file-chip button:hover { color: var(--text); }
.file-chip svg { width: 12px; height: 12px; }

.chips { display: flex; justify-content: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.main:not(.empty) .chips { margin-top: 8px; }
.chip {
  display: flex; align-items: center; gap: 7px; padding: 4px 10px 4px 6px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 13px;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip-ico { width: 18px; height: 18px; border-radius: 5px; background: #2f2f2f; color: #d0d0d0; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.chip [data-icon="globe"] svg { width: 14px; height: 14px; color: var(--muted); }

/* menus */
.picker { position: relative; }
.menu {
  position: absolute; z-index: 30; min-width: 250px; max-width: 340px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.menu.up { bottom: calc(100% + 6px); left: 0; }
.menu.center { left: 50%; transform: translateX(-50%); }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 9px; border: 0; background: none;
  border-radius: 7px; text-align: left; color: var(--text-2);
}
.menu-item:hover, .menu-item.sel { background: var(--hover); color: var(--text); }
.menu-item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.menu-item .grow span:first-child { color: var(--text); }
.menu-item .sub { font-size: 12px; color: var(--muted); }
.menu-item .check { width: 16px; color: var(--text); }
.menu-item .check svg { width: 14px; height: 14px; }
.menu-item kbd { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 70px; }

.slash { position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); z-index: 30; padding: 5px; background: var(--surface); border: 1px solid var(--border-2); border-radius: 10px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5); }

/* messages */
.msg { max-width: 880px; margin: 0 auto 24px; padding: 0 24px; animation: msg-in 0.18s ease-out; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.msg.user .bubble {
  max-width: min(78%, 640px); background: #262626; border: 1px solid #313131; color: var(--text);
  padding: 9px 14px; border-radius: 18px 18px 5px 18px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.55;
}
.msg.user .files { margin: 6px 0 0; justify-content: flex-end; }
.file-chip [data-icon] svg { width: 12px; height: 12px; }
.msg.assistant { display: grid; grid-template-columns: 30px minmax(0, 1fr); column-gap: 12px; font-size: 14.5px; line-height: 1.7; }
.msg.assistant .who { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.avatar {
  width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
  background: #e4e4e4; color: #141414; font-weight: 800; font-size: 14px; font-family: var(--mono);
}
.who .name { font-weight: 600; color: var(--text); }
.who .tag { font-size: 11.5px; color: var(--muted); border: 1px solid var(--border-2); border-radius: 6px; padding: 0 7px; font-family: var(--mono); }
.msg.assistant .body { grid-column: 2; min-width: 0; }
.msg.assistant .body > * + * { margin-top: 10px; }
.actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity 0.15s; }
.msg:hover .actions, .msg:last-child .actions { opacity: 1; }
.act { width: 28px; height: 28px; border: 0; background: none; border-radius: 6px; color: var(--muted); display: grid; place-items: center; }
.act:hover { background: var(--hover); color: var(--text); }
.act svg { width: 15px; height: 15px; }
.act.done { color: #8fd18f; }
.time { font-size: 11.5px; color: var(--faint); padding: 0 6px; font-family: var(--mono); }
@media (hover: none) { .actions { opacity: 1; } }
.status { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; font-family: var(--mono); }
.status:empty { display: none; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 5px; height: 5px; background: var(--text-2); border-radius: 1px; animation: pulse 1.2s ease-in-out infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }
.notice { color: var(--muted); font-size: 13px; font-family: var(--mono); }
.error-box { border: 1px solid rgba(229, 115, 115, 0.35); background: rgba(229, 115, 115, 0.07); color: #f1b8b8; padding: 9px 13px; border-radius: 8px; font-size: 13.5px; }

.fold > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; font-family: var(--mono); user-select: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary:hover { color: var(--text-2); }
.fold > summary svg { width: 12px; height: 12px; transition: transform 0.12s; }
.fold[open] > summary svg { transform: rotate(90deg); }
.fold-body { margin-top: 6px; padding: 2px 0 2px 14px; border-left: 2px solid var(--border-2); max-height: 380px; overflow-y: auto; color: var(--text-2); font-size: 13.5px; }
.fold-body.plain { white-space: pre-wrap; color: var(--muted); }

/* markdown */
.md p { margin: 0 0 12px; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; line-height: 1.3; font-weight: 600; }
.md h1 { font-size: 1.35em; } .md h2 { font-size: 1.2em; } .md h3 { font-size: 1.06em; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 24px; }
.md li { margin: 4px 0; }
.md code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: #e8e8e8; }
.md a { color: #9ec3ff; text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md blockquote { margin: 0 0 12px; padding: 2px 14px; border-left: 2px solid var(--border-2); color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.table-wrap { overflow-x: auto; margin: 0 0 12px; }
.md table { border-collapse: collapse; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--border-2); padding: 6px 10px; }
.md th { background: var(--surface); }
.code { margin: 10px 0 14px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--code-bg); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); font-family: var(--mono); }
.copy-btn { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 2px 8px; border-radius: 5px; font-family: var(--sans); }
.copy-btn:hover { color: var(--text); background: var(--hover); }
.code pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.md code, .code code, pre code { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.code code, pre code { font-family: var(--mono); font-size: 13px; line-height: 1.55; background: none; padding: 0; color: #d8d8d8; }
.tok-k { color: #c6a0f6; } .tok-s { color: #a6d189; } .tok-c { color: #6c6c6c; font-style: italic; }
.tok-n { color: #ef9f76; } .tok-f { color: #8caaee; } .tok-t { color: #e5c890; }

/* modal & toasts */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, 0.55); display: grid; place-items: center; padding: 16px; }
.modal-box { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--border-2); border-radius: 12px; padding: 20px; }
.modal-box h3 { margin: 0 0 6px; font-size: 16px; }
.modal-box p { margin: 0 0 14px; color: var(--muted); }
.modal-box input[type="password"], .modal-box select {
  width: 100%; background: var(--bg); border: 1px solid var(--border-2); border-radius: 8px; padding: 8px 10px; outline: 0; color: var(--text);
}
.modal-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.modal-row:last-of-type { border-bottom: 0; }
.modal-row select { width: 180px; }
.modal-row input[type="checkbox"], .modal-row input[type="range"] { accent-color: #e4e4e4; }
.modal-row input[type="checkbox"] { width: 16px; height: 16px; }
.modal-row input[type="range"] { width: 180px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.btn { border: 1px solid var(--border-2); background: var(--surface-2); border-radius: 7px; padding: 6px 14px; color: var(--text); }
.btn:hover { background: #303030; }
.btn.primary { background: #e4e4e4; color: #141414; border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: #fff; }
.btn.danger { color: var(--danger); }
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--surface-2); border: 1px solid var(--border-2); padding: 8px 14px; border-radius: 8px; max-width: min(520px, 92vw); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); font-size: 13.5px; }
.toast.error { color: #f1b8b8; }

/* ---------------- accounts & plans ---------------- */
.plan-btn {
  display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 7px;
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text); font-size: 13px;
}
.plan-btn:hover { background: #303030; }
.plan-btn svg { width: 13px; height: 13px; color: #e8c37a; }
.account-btn { width: 30px; height: 30px; border: 0; background: none; padding: 0; border-radius: 50%; display: grid; place-items: center; }
.acc-avatar {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  background: #e4e4e4; color: #141414; font-weight: 700; font-size: 12.5px; font-family: var(--mono);
}
.acc-avatar.big { width: 36px; height: 36px; font-size: 15px; flex-shrink: 0; }
.account-btn:hover .acc-avatar { box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12); }
.menu.down { top: calc(100% + 6px); }
.menu.right { right: 0; left: auto; }
.acc-head { display: flex; align-items: center; gap: 10px; padding: 8px 9px 10px; }
.acc-head .grow { min-width: 0; }
.acc-login { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.acc-head .sub, .acc-usage .sub { font-size: 12px; color: var(--muted); }
.acc-usage { padding: 0 9px 8px; }
.acc-usage .bar { height: 4px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin-top: 5px; }
.acc-usage .bar > div { height: 100%; background: var(--text-2); }
.menu-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.menu-item [data-icon] svg { width: 15px; height: 15px; color: var(--muted); }
.menu-item.locked .grow span:first-child { color: var(--muted); }
.lock-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: #e8c37a; flex-shrink: 0; }
.lock-tag svg { width: 12px; height: 12px; }
.plan-tag { display: inline-block; font-size: 11px; padding: 0 7px; border-radius: 5px; border: 1px solid var(--border-2); color: var(--text-2); font-family: var(--mono); line-height: 18px; margin-right: 4px; }
.plan-tag.pro { color: #9ec3ff; border-color: rgba(158, 195, 255, 0.35); }
.plan-tag.max { color: #e8c37a; border-color: rgba(232, 195, 122, 0.4); }
.usage-chip { padding: 4px 10px; font-family: var(--mono); font-size: 12px; }
.usage-chip.warn { color: #f1b8b8; border-color: rgba(229, 115, 115, 0.4); }

.modal-box.wide { width: min(900px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.plan-card { border: 1px solid var(--border-2); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.plan-card.current { border-color: #4a4a4a; }
.plan-card.highlight { border-color: #e8c37a; box-shadow: 0 0 0 1px rgba(232, 195, 122, 0.35); }
.plan-name { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.plan-current { font-size: 11px; font-weight: 500; color: var(--muted); border: 1px solid var(--border-2); border-radius: 5px; padding: 0 6px; }
.plan-price { font-size: 26px; font-weight: 700; font-family: var(--mono); }
.plan-price span { font-size: 13px; font-weight: 400; color: var(--muted); }
.plan-card ul { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 13.5px; flex: 1; }
.plan-card li { margin: 3px 0; }
.btn.wide { width: 100%; }
.btn.small { padding: 3px 10px; font-size: 12.5px; }
.pay-info { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--border-2); border-radius: 10px; padding: 12px 14px; margin: 6px 0 12px; line-height: 1.6; }
.pay-login { margin-bottom: 10px; color: var(--text-2); }
.pay-login b { font-family: var(--mono); color: var(--text); }
.modal-box input[type="text"], .modal-box input[type="number"], .stack input {
  width: 100%; background: var(--bg); border: 1px solid var(--border-2); border-radius: 8px; padding: 8px 10px; outline: 0; color: var(--text);
}
.stack { display: flex; flex-direction: column; gap: 8px; }

/* login screen */
.auth { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.auth-inner { width: min(420px, 100%); display: flex; flex-direction: column; align-items: center; }
.auth-logo { display: flex; margin: 0 0 26px; width: 100%; }
.auth-logo svg { width: 100%; }
.auth-card { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 8px; padding: 3px; margin-bottom: 14px; }
.auth-tabs button { flex: 1; border: 0; background: none; color: var(--muted); border-radius: 6px; padding: 6px; }
.auth-tabs button.active { background: var(--surface-2); color: var(--text); }
.auth-card form { display: flex; flex-direction: column; gap: 10px; }
.auth-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.auth-card input { background: var(--bg); border: 1px solid var(--border-2); border-radius: 8px; padding: 9px 11px; outline: 0; color: var(--text); font-size: 14px; }
.auth-card input:focus { border-color: #555; }
.auth-card .btn.primary { margin-top: 4px; padding: 9px; }
.auth-error { color: #f1b8b8; font-size: 13px; background: rgba(229, 115, 115, 0.08); border: 1px solid rgba(229, 115, 115, 0.3); border-radius: 8px; padding: 7px 10px; margin-top: 8px; }
.auth-card form .auth-error { margin-top: 0; }
.auth-note { color: var(--muted); font-size: 12.5px; margin: 12px 0 0; text-align: center; }
.auth-lang { margin-top: 16px; }

/* admin */
.admin-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 6px 0 12px; }
.admin-tabs button { border: 0; background: none; color: var(--muted); padding: 7px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.admin-tabs button.active { color: var(--text); border-bottom-color: var(--text); }
.providers { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.prov { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 7px; border: 1px solid var(--border-2); color: var(--muted); }
.prov i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.prov b { color: var(--text-2); font-weight: 600; }
.prov.on i { background: #7fb685; }
.prov.wait i { background: #e8c37a; }
.admin-stats { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; color: var(--text-2); }
.admin-body > input[type="text"] { margin-bottom: 10px; }
.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--border); }
.admin-table td { padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.admin-table .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.admin-table code { font-family: var(--mono); }
.grant { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.modal-box .grant select { width: auto; }
.admin-table td .plan-tag { margin-left: 6px; }
.grant select, .promo-form select { background: var(--bg); border: 1px solid var(--border-2); border-radius: 7px; padding: 4px 6px; color: var(--text); }
.modal-box input.days { width: 64px; padding: 4px 6px; }
.promo-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.promo-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.promo-form label.grow { flex: 1; min-width: 150px; }

/* ---------------- photos ---------------- */
.photo-chip { position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border-2); flex-shrink: 0; }
.photo-chip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-chip button {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; border: 0; padding: 0;
  background: rgba(0, 0, 0, 0.7); color: #fff; display: grid; place-items: center;
}
.photo-chip button svg { width: 11px; height: 11px; }
.msg.user .photos { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; margin-bottom: 6px; max-width: min(78%, 640px); }
.msg.user .photos img { width: 132px; height: 132px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border-2); cursor: zoom-in; }
.modal-box.photo-box { width: auto; max-width: min(960px, 100%); padding: 12px; }
.photo-full { display: block; max-width: 100%; max-height: 74dvh; border-radius: 8px; margin: 0 auto; }

/* ---------------- install ---------------- */
.install-head { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.install-head img { width: 56px; height: 56px; border-radius: 13px; }
.install-head h3 { margin: 0 0 3px; }
.install-head p { margin: 0; }
.install-steps { margin: 0; padding: 0; list-style: none; counter-reset: step; display: flex; flex-direction: column; gap: 10px; }
.install-steps li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; }
.step-ico { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; flex-shrink: 0; color: #9ec3ff; }
.step-ico svg { width: 17px; height: 17px; }
#installBtn svg { color: var(--text-2); }

/* iPhone: notch / home indicator when opened from the home screen */
.topbar { padding-top: env(safe-area-inset-top); height: calc(44px + env(safe-area-inset-top)); padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
.dock { padding-bottom: max(18px, env(safe-area-inset-bottom)); }

@media (max-width: 640px) {
  /* 16px stops Safari from zooming in when the field gets focus */
  .composer textarea, .auth-card input, .modal-box input, .drawer-search input { font-size: 16px; }
  #installBtn span:last-child, #upgradeBtn span:last-child { display: none; }
  .msg.user .photos img { width: 104px; height: 104px; }
}

@media (max-width: 640px) {
  .main { margin: 0; border-radius: 0; border-left: 0; border-right: 0; border-bottom: 0; }
  .dock { padding: 8px 10px 12px; }
  .msg { padding: 0 14px; }
  .main.empty .dock { padding-bottom: 8vh; }
  .tab { max-width: 150px; }
  .model-btn { max-width: 180px; }
}
