/* Trixie Talker - the colour variables and themes are the same as Trixie Messenger's and Trixie Editor's, so theme
   files work in all three. */
:root {
  --accent: #d946ef;
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --accent-strong: color-mix(in srgb, var(--accent) 80%, #fff);
  --danger: #f43f5e; --warn: #f59e0b; --ok: #22c55e;
  --radius: 12px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", Cambria, serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, ui-monospace, monospace;
  --side-w: 330px; --drawer-w: 380px;
  font-size: 15px;
}
:root.fs-small { font-size: 13.5px; }
:root.fs-large { font-size: 17px; }
[data-theme="dark"] {
  --bg-0: #0f1117; --bg-1: #151821; --bg-2: #1b1f2a; --bg-3: #242938; --bg-hover: #2a3042;
  --line: #2b3142; --text: #e6e8ef; --text-2: #a3a9bb; --text-3: #6f768a; --shadow: 0 12px 40px rgba(0,0,0,.45);
  color-scheme: dark;
}
[data-theme="midnight"] {
  --bg-0: #000; --bg-1: #07080c; --bg-2: #0c0e14; --bg-3: #141722; --bg-hover: #1a1e2b;
  --line: #1c2030; --text: #e9ebf3; --text-2: #9aa1b5; --text-3: #616881; --shadow: 0 12px 40px rgba(0,0,0,.7);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg-0: #e9ebf1; --bg-1: #f2f3f7; --bg-2: #ffffff; --bg-3: #eef0f5; --bg-hover: #e6e8ef;
  --line: #dcdfe8; --text: #1b1e27; --text-2: #4e5568; --text-3: #8a90a2; --shadow: 0 12px 40px rgba(20,24,40,.18);
  color-scheme: light;
}
:root.reduce-motion *, :root.reduce-motion *::before, :root.reduce-motion *::after { animation: none !important; transition: none !important; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg-0); color: var(--text); font-family: var(--font); line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-strong); }
::selection { background: var(--accent-soft); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
.boot { display: grid; place-items: center; align-content: center; gap: 12px; height: 100vh; color: var(--text-3); }
.boot img { width: 72px; height: 72px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; transform: scale(.96); } }
.boot-error { max-width: 520px; margin: 15vh auto; padding: 20px; text-align: center; }
.hidden { display: none !important; }
.faint { color: var(--text-3); }
.small { font-size: .86em; }
.center { text-align: center; }
.pad { padding: 16px; }
.pre { white-space: pre-line; }
.block { display: block; }
.grow1 { flex: 1; min-width: 0; }
.row { display: flex; gap: .6em; align-items: center; }
.row.wrap, .wrap { flex-wrap: wrap; }
.gap6 { gap: 6px; } .gap8 { gap: 8px; }
.spacer { flex: 1; }
.ic { flex: none; vertical-align: -3px; }
.danger-text { color: var(--danger) !important; }
.warn-text { color: var(--warn); }
.err { color: var(--danger); }
code, .mono { font-family: var(--mono); font-size: .9em; }
.mono { word-break: break-all; }
h1, h2, h3, h4 { margin: 0 0 .6em; line-height: 1.25; }
h4 { margin-top: 1.3em; font-size: 1em; }
h4:first-child { margin-top: 0; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); }
.ticket-ref { font-size: .74em; color: var(--text-3); margin-left: 5px; letter-spacing: .02em; font-variant-numeric: tabular-nums; white-space: nowrap; opacity: .85; font-weight: 400; }

/* ---------- controls ---------- */
.btn { border: 0; border-radius: 9px; padding: .5em .95em; background: var(--bg-3); cursor: pointer; font-weight: 600; transition: background .12s, transform .05s; white-space: nowrap; display: inline-flex; align-items: center; gap: .35em; justify-content: center; }
.btn:hover { background: var(--bg-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 85%, #000); }
.btn.danger { background: color-mix(in srgb, var(--danger) 85%, #000); color: #fff; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--bg-hover); }
.btn.sm { padding: .28em .65em; font-size: .86em; }
.btn.big { padding: .7em 1em; font-size: 1.05em; }
.icon-btn { border: 0; background: transparent; color: var(--text-2); width: 34px; height: 34px; border-radius: 9px; cursor: pointer; display: inline-grid; place-items: center; flex: none; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; background: transparent; }
.icon-btn.sm { width: 26px; height: 26px; border-radius: 7px; }
.linkish { border: 0; background: none; color: var(--accent-strong); cursor: pointer; padding: 0; display: inline-flex; align-items: center; gap: 4px; }
.linkish:hover { text-decoration: underline; }
.input, select.input, textarea.input { width: 100%; padding: .55em .75em; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-1); outline: none; transition: border-color .12s, box-shadow .12s; min-width: 0; }
textarea.input { resize: vertical; line-height: 1.45; }
.input.sm { padding: .3em .5em; width: auto; max-width: 160px; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: block; margin-bottom: 1em; flex: 1; min-width: 0; }
.field > .lbl, .lbl { display: block; font-size: .74em; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); margin-bottom: .4em; }
.field > .hint { display: block; font-size: .82em; color: var(--text-3); margin-top: .35em; }
.check { display: flex; align-items: center; gap: .6em; cursor: pointer; margin: .5em 0; }
input[type="checkbox"], input[type="radio"], input[type="range"] { accent-color: var(--accent); }
input[type="range"] { width: 100%; }
input[type="color"] { width: 36px; height: 30px; border: 1px solid var(--line); border-radius: 7px; padding: 2px; background: var(--bg-1); cursor: pointer; }
.switch { position: relative; display: inline-block; width: 40px; height: 23px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch .slider { position: absolute; inset: 0; background: var(--bg-3); border-radius: 23px; cursor: pointer; transition: background .15s; border: 1px solid var(--line); }
.switch .slider::before { content: ""; position: absolute; width: 17px; height: 17px; left: 2px; top: 2px; background: var(--text-2); border-radius: 50%; transition: transform .15s, background .15s; }
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(17px); background: #fff; }
.seg { display: inline-flex; background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; margin-bottom: 12px; }
.seg button { border: 0; background: transparent; border-radius: 8px; padding: .35em .85em; cursor: pointer; color: var(--text-2); font-weight: 600; display: inline-flex; gap: .35em; align-items: center; }
.seg button:hover { color: var(--text); background: var(--bg-hover); }
.seg button.on { background: var(--accent); color: #fff; }
.chip { display: inline-flex; align-items: center; gap: .3em; padding: .2em .65em; border-radius: 99px; background: var(--bg-3); font-size: .82em; font-weight: 600; color: var(--text-2); border: 0; cursor: default; white-space: nowrap; }
button.chip { cursor: pointer; }
button.chip:hover { background: var(--bg-hover); color: var(--text); }
.chip.add { border: 1px dashed var(--line); background: transparent; }
.chip .x { border: 0; background: none; cursor: pointer; color: var(--text-3); padding: 0 0 0 2px; font-size: 1.1em; line-height: 1; }
.chip.warn { color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.count { font-style: normal; font-size: .72em; background: var(--bg-3); border-radius: 99px; padding: 0 .5em; color: var(--text-3); font-weight: 700; }
.notice { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); background: var(--bg-1); padding: 12px 14px; border-radius: 12px; margin: 12px 0; flex-wrap: wrap; }
.notice > div { flex: 1; min-width: 200px; }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 60%, var(--line)); background: color-mix(in srgb, var(--warn) 10%, var(--bg-1)); }
.notice.soft { background: var(--accent-soft); border-color: transparent; }
.av { border-radius: 50%; object-fit: cover; flex: none; display: inline-grid; place-items: center; color: #fff; font-weight: 700; }
.loading, .empty-view { padding: 40px; color: var(--text-3); text-align: center; }

/* ---------- toasts, menus, modals ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 300; align-items: flex-end; pointer-events: none; }
.toast { pointer-events: auto; background: var(--bg-3); border: 1px solid var(--line); box-shadow: var(--shadow); padding: 10px 14px; border-radius: 10px; max-width: min(460px, 90vw); animation: toast-in .18s ease-out; }
.toast.ok { border-left: 4px solid var(--ok); } .toast.err { border-left: 4px solid var(--danger); }
.toast.out { opacity: 0; transform: translateY(6px); transition: .3s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.pop-menu { position: fixed; z-index: 250; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; min-width: 200px; }
.menu-item { display: flex; gap: 10px; align-items: center; width: 100%; border: 0; background: none; padding: 8px 10px; border-radius: 7px; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--bg-hover); }
.menu-item:disabled { opacity: .45; cursor: default; }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200; display: grid; place-items: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--bg-2); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); width: min(560px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; }
.modal.wide { width: min(1000px, 100%); }
.modal-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px 20px; }
.modal-head h3 { margin: 0; flex: 1; }
.modal-body { padding: 4px 20px 16px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); }

/* ---------- sign in ---------- */
.signin-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; overflow: auto; height: 100vh;
  background: radial-gradient(1100px 600px at 10% -10%, var(--accent-soft), transparent 60%), radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent) 12%, transparent), transparent 60%), var(--bg-0); }
.signin { width: min(420px, 100%); padding: 26px; display: flex; flex-direction: column; gap: 12px; }
.signin-logo { display: flex; gap: 14px; align-items: center; }
.signin-logo img { width: 58px; height: 58px; }
.signin-logo h1 { font-size: 1.5em; margin: 0; }
.signin .seg { align-self: flex-start; margin: 0; }
.signin-msg { padding: 10px 12px; border-radius: 9px; background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--text); font-size: .92em; }
.signin-msg.pending, .signin-msg:not(.err):first-letter { }
.signin-msg.pending { background: color-mix(in srgb, var(--warn) 16%, transparent); }
.welcome { margin: 0; color: var(--text-2); }

/* ---------- the shell ---------- */
#app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }
.side { background: var(--bg-1); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 12px 10px 8px 14px; padding-top: max(12px, env(safe-area-inset-top)); }
.side-head .logo { width: 34px; height: 34px; }
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 2px; padding: 4px 8px; }
.tab { border: 0; background: transparent; padding: 7px 2px 6px; border-radius: 9px; cursor: pointer; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .74em; font-weight: 600; position: relative; }
.tab:hover { background: var(--bg-hover); color: var(--text); }
.tab.on { background: var(--accent-soft); color: var(--accent-strong); }
.tab .count { position: absolute; top: 3px; right: 8px; }
.side-tools { display: flex; gap: 6px; padding: 6px 10px; }
.side-tools .search { flex: 1; }
.new-btn { flex: none; }
.side-list { flex: 1; overflow: auto; padding: 4px 6px 10px; }
.side-foot { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.li { min-width: 0; overflow: hidden; display: flex; gap: 10px; align-items: center; width: 100%; border: 0; background: transparent; padding: 8px; border-radius: 11px; cursor: pointer; text-align: left; }
.li:hover { background: var(--bg-hover); }
.li.on { background: var(--accent-soft); }
.li-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.li-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-title .pin { color: var(--accent-strong); margin-right: 4px; }
.li-sub { font-size: .84em; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-time { font-size: .74em; align-self: flex-start; margin-top: 2px; white-space: nowrap; }
.empty { padding: 20px 14px; font-size: .92em; }
#sync-chip .chip { margin: 0; }
.sync-syncing { color: var(--accent-strong) !important; }
.sync-offline, .sync-error { color: var(--warn) !important; }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg-2); }
.view-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 58px; padding-top: max(10px, env(safe-area-inset-top)); }
.view-head h2 { margin: 0; font-size: 1.2em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { display: none; }
.mobile-only { display: none; }
.home-back { margin: -12px 0 6px -8px; }

/* ---------- home ---------- */
.home { overflow: auto; padding: 32px clamp(16px, 4vw, 48px); }
.home-hero { display: flex; gap: 18px; align-items: center; margin-bottom: 12px; }
.home-hero img { width: 76px; height: 76px; }
.home-hero h1 { margin: 0; font-size: 2em; }
.home-hero p { margin: 4px 0 0; }
.home-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin: 18px 0 24px; }
.home-card { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; text-align: left; padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg-1); cursor: pointer; transition: transform .1s, border-color .1s, box-shadow .1s; }
.home-card .ic { color: var(--accent-strong); }
.home-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 6px 24px var(--accent-soft); }
.recent { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px; }

/* ---------- editors ---------- */
.editor { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.editor-body { display: grid; grid-template-columns: 240px 1fr; gap: 26px; padding: 22px clamp(14px, 3vw, 36px); overflow: auto; align-items: start; }
.editor-main { max-width: 820px; }
.pic { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; }
.pic img { width: 100%; aspect-ratio: 1 / 1.15; object-fit: cover; border-radius: 16px; border: 1px solid var(--line); }
.pic-empty { aspect-ratio: 1 / 1.15; border: 2px dashed var(--line); border-radius: 16px; display: grid; place-items: center; align-content: center; gap: 6px; color: var(--text-3); }
.pic-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.files { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--bg-1); margin: 6px 0 14px; }
.files-head { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.files p { margin: 6px 0 8px; }
.file-row { display: flex; gap: 8px; align-items: center; padding: 5px 4px; border-top: 1px solid var(--line); }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.trash { padding: 20px clamp(14px, 3vw, 36px); overflow: auto; }
.trash-row { display: flex; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }

/* ---------- pickers, new chat ---------- */
.pick-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow: auto; }
.pick { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 10px; cursor: pointer; }
.pick:hover { background: var(--bg-hover); } .pick.on { background: var(--accent-soft); }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; max-height: 260px; overflow: auto; padding: 2px; }
.pick-card { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-1); cursor: pointer; font-size: .88em; font-weight: 600; text-align: center; }
.pick-card.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ---------- the chat ---------- */
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-title { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.chat-title b { cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-title span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-chip { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.chat-body { flex: 1; display: flex; min-height: 0; }
.msgs { flex: 1; overflow: auto; padding: 20px clamp(10px, 3vw, 40px) 10px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: auto; }
.chat-empty { text-align: center; margin: auto; }
.msg { display: flex; gap: 10px; max-width: 900px; width: 100%; margin: 0 auto; }
.msg .av { width: 36px; height: 36px; margin-top: 2px; }
.msg-main { flex: 1; min-width: 0; }
.msg-name { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; margin-bottom: 3px; }
.msg-name .stat { margin-left: auto; }
.bubble { background: var(--bg-1); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 10px 14px; overflow-wrap: anywhere; font-family: var(--serif); font-size: 1.04em; line-height: 1.6; }
.msg.me .bubble { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--line)); }
[data-bubbles="flat"] .bubble { background: transparent; border: 0; padding: 2px 0; }
.bubble p { margin: 0 0 .7em; } .bubble p:last-child { margin-bottom: 0; }
.bubble .act { color: var(--text-2); }
.bubble .say { color: var(--text); }
.msg.ai .bubble .say { color: color-mix(in srgb, var(--accent-strong) 55%, var(--text)); }
.bubble pre { white-space: pre-wrap; font-family: var(--mono); font-size: .85em; background: var(--bg-3); padding: 8px; border-radius: 8px; }
.bubble textarea { font-family: var(--serif); min-height: 120px; }
.msg-tools { display: flex; gap: 2px; align-items: center; opacity: 0; transition: opacity .12s; margin-top: 2px; min-height: 26px; }
.msg:hover .msg-tools, .msg:focus-within .msg-tools { opacity: 1; }
@media (pointer: coarse) { .msg-tools { opacity: .75; } }
.alts { display: inline-flex; align-items: center; gap: 2px; margin-right: 6px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: dot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dot { 30% { transform: translateY(-4px); opacity: 1; } 0%, 60%, 100% { opacity: .4; } }
.composer { border-top: 1px solid var(--line); padding: 8px clamp(10px, 3vw, 40px) 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.composer-row { display: flex; gap: 8px; align-items: flex-end; max-width: 900px; margin: 0 auto; }
.composer textarea { resize: none; max-height: 220px; border-radius: 14px; padding: .7em .9em; }
.composer .send { height: 44px; width: 48px; border-radius: 14px; padding: 0; }
.gen-status { max-width: 900px; margin: 0 auto 4px; min-height: 1.2em; }
.drawer { width: 0; overflow: hidden; border-left: 1px solid transparent; background: var(--bg-1); transition: width .18s; display: flex; flex-direction: column; }
.drawer-open .drawer { width: var(--drawer-w); border-left-color: var(--line); }
.drawer-head { display: flex; align-items: center; padding: 10px 10px 6px 16px; min-width: var(--drawer-w); }
.drawer-body { overflow: auto; padding: 4px 16px 30px; min-width: var(--drawer-w); }
.drawer section { border-bottom: 1px solid var(--line); padding: 12px 0; }
.drawer section h4 { margin: 0 0 8px; }
.params summary { cursor: pointer; margin: 10px 0 6px; color: var(--text-2); font-weight: 600; }
.slider-field { margin-bottom: .6em; }
.usage { margin-top: 10px; }
.usage .bar { display: flex; height: 8px; border-radius: 8px; background: var(--bg-3); overflow: hidden; margin-bottom: 6px; }
.usage .sys { background: var(--accent); } .usage .hist { background: color-mix(in srgb, var(--accent) 45%, var(--bg-3)); } .usage .out { background: var(--ok); opacity: .6; }
.update-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: 16px; z-index: 150; display: flex; gap: 10px; align-items: center; background: var(--bg-3); border: 1px solid var(--accent); border-radius: 12px; padding: 8px 10px 8px 14px; box-shadow: var(--shadow); width: min(560px, calc(100vw - 24px)); }

/* ---------- settings ---------- */
.settings-modal .modal-body { padding: 0; display: flex; min-height: 0; }
.settings { display: grid; grid-template-columns: 210px 1fr; min-height: min(640px, 80vh); width: 100%; }
.set-nav { border-right: 1px solid var(--line); padding: 8px; display: flex; flex-direction: column; gap: 2px; overflow: auto; }
.set-tab { display: flex; gap: 10px; align-items: center; border: 0; background: none; padding: 9px 10px; border-radius: 9px; cursor: pointer; text-align: left; color: var(--text-2); font-weight: 600; }
.set-tab:hover { background: var(--bg-hover); color: var(--text); }
.set-tab.on { background: var(--accent-soft); color: var(--accent-strong); }
.set-tab .count { margin-left: auto; background: var(--danger); color: #fff; }
.set-body { padding: 6px 22px 24px; overflow: auto; max-height: calc(100vh - 110px); max-height: calc(100dvh - 110px); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.prompt-view { white-space: pre-wrap; background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-family: var(--font); font-size: .88em; max-height: 300px; overflow: auto; }
.model-row, .user-row { display: flex; gap: 10px; align-items: center; padding: 10px 6px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.model-row.off { opacity: .6; }
.user-row.st-disabled, .user-row.st-rejected { opacity: .6; }
.pending-row { background: color-mix(in srgb, var(--warn) 9%, transparent); border-radius: 10px; border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); margin-bottom: 6px; }
.note { color: var(--text-2); font-style: italic; margin-top: 3px; }
.ep-row { display: grid; grid-template-columns: 1fr 1.4fr 1fr 1.2fr auto auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.about-head { display: flex; gap: 14px; align-items: center; }
.about-head img { width: 64px; height: 64px; }

/* ---------- themes (as Trixie Messenger / Editor) ---------- */
.theme-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin: 10px 0; }
.theme-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--bg-1); }
.theme-card.in-use { border-color: var(--accent); }
.theme-card-name { display: flex; justify-content: space-between; align-items: center; }
.theme-swatch { display: flex; height: 26px; border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.theme-swatch i { flex: 1; }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.theme-part { display: flex; flex-direction: column; gap: 3px; padding: 6px; border-radius: 8px; background: var(--bg-1); }
.theme-part-main { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.theme-part-text { display: flex; flex-direction: column; min-width: 0; }
.theme-part-hex { display: flex; gap: 6px; flex-wrap: wrap; }
.theme-grad-toggle { display: flex; align-items: center; gap: 4px; margin-left: 2px; cursor: pointer; }

/* ---------- what's new (as Trixie Messenger / Editor) ---------- */
.whats-new details { border: 1px solid var(--line); border-radius: 10px; margin: 8px 0; background: var(--bg-1); }
.whats-new summary { display: flex; align-items: center; gap: 6px; padding: 9px 12px; cursor: pointer; list-style: none; }
.whats-new summary::-webkit-details-marker { display: none; }
.whats-new summary::before { content: "▸"; color: var(--text-3); font-size: .8em; transition: transform .12s; }
.whats-new details[open] > summary::before { transform: rotate(90deg); }
.whats-new .wn-intro { margin: 0 12px 6px; }
.wn-group { padding: 0 12px 8px; }
.wn-group-title { font-weight: 800; font-size: .8em; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin: 6px 0 2px; }
.wn-group ul { margin: 2px 0; padding-left: 18px; }
.wn-group li { margin: 3px 0; font-size: .92em; }
.wn-item { display: flex; align-items: flex-start; gap: 6px; }
.wn-text { flex: 1; min-width: 0; }
.wn-eye { flex: none; color: var(--text-3); }
.wn-eye.off { color: var(--danger); }
.wn-hidden > .wn-item .wn-text, details.wn-hidden > summary b { opacity: .45; text-decoration: line-through; }
.wn-tag { font-size: .7em; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--danger); border: 1px solid currentColor; border-radius: 5px; padding: 0 4px; flex: none; }
.wn-current { font-size: .72em; }
.wn-search-row { gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.wn-search { flex: 1 1 220px; min-width: 0; }
.wn-results { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.wn-result { text-align: left; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg-1); color: inherit; font: inherit; font-size: .92em; cursor: pointer; }
.wn-result:hover { border-color: var(--accent); }
.wn-result ul { margin: 4px 0 0; padding-left: 18px; }
.wn-result-meta { font-size: .85em; margin-bottom: 2px; }
.wn-mark { background: color-mix(in srgb, var(--accent) 35%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.wn-flash { animation: wnflash 1.8s ease-out; border-radius: 6px; }
@keyframes wnflash { 0% { background: var(--accent-soft); } 100% { background: transparent; } }
.wn-audit-list { margin: 0; padding: 4px 14px 10px 30px; font-size: .88em; display: grid; gap: 4px; }

/* ---------- smaller screens (phones) ---------- */
@media (max-width: 1100px) { .drawer-open .drawer { position: absolute; right: 0; top: 0; bottom: 0; z-index: 60; box-shadow: var(--shadow); } .chat-body { position: relative; } }
@media (max-width: 820px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  .side { border-right: 0; }
  .main { display: none; }
  body.in-view .side { display: none; }
  body.in-view .main { display: flex; }
  .back, .mobile-only { display: inline-grid; }
  .editor-body { grid-template-columns: 1fr; padding-top: 14px; }
  .pic { position: static; flex-direction: row; align-items: center; }
  .pic img, .pic-empty { width: 120px; }
  .settings { grid-template-columns: 1fr; }
  .set-nav { flex-direction: row; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .set-tab { white-space: nowrap; }
  .modal-back { padding: 0; align-items: end; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; max-height: 92dvh; }
  .set-body { max-height: none; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .ep-row { grid-template-columns: 1fr 1fr; }
  :root { --drawer-w: min(100vw, 380px); }
  .drawer-open .drawer { width: 100%; }
  .drawer-head, .drawer-body { min-width: 0; }
  .model-chip { max-width: 120px; }
  .msg .av { width: 30px; height: 30px; }
  .msgs { padding-left: 8px; padding-right: 8px; }
  .theme-grid { grid-template-columns: 1fr; }
  .home { padding-top: 20px; }
}

/* TM-349: tucked-away options (e.g. a new chat's own context prompt) */
.subtle-details { margin-top: 10px; }
.subtle-details > summary { cursor: pointer; color: var(--text-2); font-size: .9em; padding: 4px 0; user-select: none; }
.subtle-details > summary:hover { color: var(--text); }
.subtle-details[open] > summary { margin-bottom: 6px; }
.subtle-details textarea { width: 100%; font-size: .9em; }

/* TM-358: the "new version" pop-up; TM-359: the Android download */
.update-pop { position: fixed; right: 16px; bottom: 16px; z-index: 250; width: min(380px, calc(100vw - 24px)); background: var(--bg-3); border: 1px solid var(--accent); border-radius: 14px; box-shadow: var(--shadow); padding: 12px 14px; animation: pop-in .2s ease-out; }
.update-pop.out { opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.update-pop-head { display: flex; align-items: center; gap: 8px; }
.update-pop-head b { flex: 1; }
.update-pop-icon { display: inline-flex; color: var(--accent); }
.update-pop p { margin: 8px 0 10px; font-size: .92em; color: var(--text-2); line-height: 1.45; }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.progress { height: 8px; background: var(--bg-2, rgba(127,127,127,.15)); border-radius: 99px; overflow: hidden; margin: 10px 0; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.android-upd[data-state="saved"] .progress > i { background: var(--ok); }
.android-upd[data-state="error"] .progress > i { background: var(--danger); }

/* TM-357: what's happening, in the reply that's waiting to be written */
.gen-wait { display: flex; align-items: center; gap: 10px; padding: 2px 0; }
.gen-wait b { font-weight: 700; color: var(--text); }
.spinner { width: 18px; height: 18px; flex: none; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: tt-spin .8s linear infinite; }
@keyframes tt-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
/* TM-361 */
.cut-note { margin: 4px 0 0 4px; }
/* toasts with a button (TM-360: Restore) */
.toast.has-action { display: flex; align-items: center; gap: 12px; }
.toast-action { flex: none; }

/* TM-363: auditing (Administration ▸ Auditing), like Trixie Messenger's */
.audit-banner { border: 1px solid var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); border-radius: 10px; padding: 10px 14px; margin: 10px 0 14px; line-height: 1.45; }
.audit-setting { display: flex; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.audit-title { font-weight: 500; margin-bottom: 2px; }
.audit-lines { margin-top: 8px; display: grid; gap: 4px; }
.audit-law { color: var(--danger); font-size: .9em; margin-top: 8px; line-height: 1.4; }
.audit-foot { align-items: center; margin: 12px 0; }
.audit-view { margin-top: 12px; }
.audit-filters { margin-bottom: 10px; }
.audit-filters .input:first-child { flex: 1; min-width: 180px; }
.audit-entry { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; background: var(--bg-1); }
.audit-entry.ev-deleted, .audit-entry.ev-chat_deleted, .audit-entry.ev-chat_purged { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.audit-entry.ev-viewed, .audit-entry.ev-setting { opacity: .85; }
.audit-body { margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 9em; overflow: auto; }
.audit-conv { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 6px; background: var(--bg-1); color: var(--text); cursor: pointer; font: inherit; }
.audit-conv:hover { background: var(--bg-hover); }
.audit-chat-head { align-items: center; margin-bottom: 8px; }
.audit-msg { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; background: var(--bg-1); }
.audit-msg.assistant { background: var(--bg-2); }
.audit-msg .avatar-letter { width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .8em; font-weight: 700; }
.audit-speaker { color: var(--accent); }
.audit-text { margin-top: 6px; overflow-wrap: anywhere; }
.audit-notice { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: var(--bg-2); color: var(--text-2); }
/* TM-365 */
.account-pick { display: grid; gap: 8px; }
.account-pick .btn { justify-content: flex-start; }
.setting-row { display: flex; gap: 14px; align-items: center; padding: 8px 0; }
.messenger-status { margin-top: 6px; display: grid; gap: 6px; }
.mono { font-family: ui-monospace, Consolas, monospace; overflow-wrap: anywhere; }

/* v1.0.5 */
/* TM-370: "Newest" when there's more of the conversation below */
.chat-body { position: relative; }
.jump-latest { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 5; border: 1px solid var(--line); background: var(--bg-2, var(--bg-1)); color: var(--text); border-radius: 99px; padding: .35em .9em; font-weight: 600; font-size: .85em; display: inline-flex; gap: .3em; align-items: center; cursor: pointer; box-shadow: var(--shadow); }
.jump-latest[hidden] { display: none; }
.drawer-open .jump-latest { left: calc(50% - 170px); }
@media (max-width: 1100px) { .drawer-open .jump-latest { left: 50%; } }
/* TM-367: sharing */
.share-box { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 14px; }
.share-box .seg { margin-bottom: 6px; }
.share-link .row { display: flex; gap: 6px; align-items: center; }
.share-link .input { flex: 1; min-width: 0; font-size: .85em; }
.share-link .lbl { display: block; margin: 6px 0 4px; }
.li-badge { display: inline-flex; vertical-align: -1px; margin-right: 4px; color: var(--accent-strong); }
.live-chip { color: var(--accent-strong); background: var(--accent-soft); }
.live-note .row { display: flex; gap: 6px; flex-wrap: wrap; }
.ro-field { margin: 0 0 14px; }
.ro-field .lbl { display: block; margin-bottom: 4px; }
.ro-text { white-space: pre-wrap; line-height: 1.5; background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.btn.icon-only { padding: 0 .7em; }
.side-tools { display: flex; gap: 6px; align-items: center; }
.side-sub { padding: 10px 10px 4px; text-transform: none; }
.pad { padding: 18px clamp(14px, 3vw, 36px); }
.row.wrap { flex-wrap: wrap; }
/* TM-368: the Workshop */
.ws-body { padding: 16px clamp(14px, 3vw, 36px) 28px; overflow: auto; }
.ws-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ws-tools .seg { margin: 0; }
.ws-tools .search { flex: 1; min-width: 200px; }
.ws-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0 6px; }
.ws-tags .lbl { margin-right: 4px; }
.chip.tick { cursor: pointer; user-select: none; }
.chip.tick input { display: none; }
.chip.tick.on { background: var(--accent); color: #fff; }
.chip.tick.on i { color: inherit; opacity: .8; }
.ws-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 10px; }
.ws-card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-1); }
.ws-open { display: flex; gap: 12px; align-items: flex-start; text-align: left; border: 0; background: none; padding: 0; color: inherit; cursor: pointer; font: inherit; }
.ws-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ws-sum { color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ws-actions { display: flex; align-items: center; gap: 6px; margin-top: auto; flex-wrap: wrap; justify-content: flex-end; }
.ws-actions .faint { margin-right: auto; }
.editor-main > .chips { margin: 4px 0 14px; }
.side-tools .search { min-width: 0; }
/* TM-366 */
.twin-chip { margin-left: 6px; color: var(--accent-strong); }
/* v1.0.6 */
/* TM-371: the app icon choice (as Trixie Messenger) */
.app-icon-section h4 { margin: 24px 0 4px; }
.icon-choices { display: flex; gap: 12px; flex-wrap: wrap; }
.icon-choice { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg-1); color: var(--text); cursor: pointer; font: inherit; }
.icon-choice img { width: 64px; height: 64px; border-radius: 50%; }
.icon-choice.sel { border-color: var(--accent); }
/* TM-372: shown / hidden from other people, per part */
.field-vis { position: relative; }
.vis-toggle { position: absolute; right: 0; top: -2px; z-index: 1; display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--line); background: var(--bg-1); color: var(--text-2); border-radius: 99px; padding: 1px 8px; font: inherit; font-size: .75em; cursor: pointer; }
.vis-toggle.off { color: var(--accent-strong); border-color: var(--accent); background: var(--accent-soft); }
.field-vis > .files .files-head { padding-right: 84px; }
.hidden-note svg { vertical-align: -2px; margin-right: 2px; }
.ro-text.hidden-part { color: var(--text-2); font-style: italic; display: flex; gap: 6px; align-items: center; }
/* TM-373: first start */
.first-run-modal { max-width: 560px; }
.first-run-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 10px; }
.first-run-head img { width: 64px; height: 64px; border-radius: 50%; flex: none; }
.first-run-head p { margin: 0 0 6px; }
.send-slot { display: contents; }
