/* CodelyTeam design system. One stylesheet for the landing page, sign-in, the app and the admin panel.
   Tokens first; every color, radius and shadow below comes from them. Light and dark are both first-class. */
:root, [data-theme="dark"] {
  --bg: #0c0d10; --bg-2: #111318; --surface: #15171d; --raised: #1c1f27; --hover: #222631;
  --line: #262a34; --line-2: #343946;
  --text: #eceae4; --muted: #9a9ca6; --faint: #6d707b;
  --accent: #9d4edd; --accent-2: #c084fc; --accent-ink: #ffffff; --accent-soft: rgba(157, 78, 221, .18);
  --ok: #4cc38a; --ok-soft: rgba(76, 195, 138, .14); --warn: #f0b429; --warn-soft: rgba(240, 180, 41, .14);
  --err: #ff6b6b; --err-soft: rgba(255, 107, 107, .14); --info: #6cb6ff; --info-soft: rgba(108, 182, 255, .14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 10px 30px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, .75);
  --code-bg: #0f1116; color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f6f4ee; --bg-2: #efece4; --surface: #ffffff; --raised: #faf8f3; --hover: #f0ede5;
  --line: #e4e0d5; --line-2: #d3cebf;
  --text: #1b1a17; --muted: #6a675e; --faint: #98948a;
  --accent: #8b2fd0; --accent-2: #7e22ce; --accent-ink: #ffffff; --accent-soft: rgba(139, 47, 208, .1);
  --ok: #17874f; --ok-soft: rgba(23, 135, 79, .1); --warn: #a8710a; --warn-soft: rgba(168, 113, 10, .1);
  --err: #c93636; --err-soft: rgba(201, 54, 54, .09); --info: #1f6fb8; --info-soft: rgba(31, 111, 184, .09);
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 10px 30px -14px rgba(40, 30, 10, .18);
  --shadow-lg: 0 24px 60px -24px rgba(40, 30, 10, .3);
  --code-bg: #f3f0e8; color-scheme: light;
}
:root {
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-sm: 8px; --r: 12px; --r-lg: 18px; --r-xl: 26px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --read: 760px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 16px/1.55 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); text-underline-offset: 3px; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--accent-soft); }
.ico { display: inline-flex; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- buttons and fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); color: var(--text); font-weight: 600; font-size: .94rem; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, transform .08s, opacity .15s; }
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { background: var(--err-soft); border-color: transparent; color: var(--err); }
.btn.danger:hover { background: var(--err); color: #fff; }
.btn.sm { min-height: 32px; padding: 0 11px; font-size: .86rem; border-radius: var(--r-sm); }
.btn.icon { width: 40px; padding: 0; } .btn.icon.sm { width: 32px; }
.btn.block { width: 100%; }

.input, .field input, .field textarea, .field select { width: 100%; min-height: 42px; padding: 9px 13px; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--bg-2); outline: none; transition: border-color .15s, box-shadow .15s; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field .hint { font-size: .8rem; color: var(--faint); }
.input-ico { position: relative; } .input-ico .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); } .input-ico input { padding-left: 40px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; letter-spacing: .02em; background: var(--raised); color: var(--muted); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; } .badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; } .badge.err { background: var(--err-soft); color: var(--err); border-color: transparent; } .badge.accent { background: var(--accent-soft); color: var(--accent-2); border-color: transparent; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--accent); animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; justify-content: center; gap: 12px; height: 100%; color: var(--muted); }

/* brand */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.08rem; letter-spacing: -.01em; color: var(--text); text-decoration: none; }
.brand-mark { width: 32px; height: 32px; background: url("/logo.png") center / contain no-repeat; flex: none; filter: drop-shadow(0 2px 6px rgba(157, 78, 221, .35)); }

/* toasts and modal */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: var(--r); background: var(--raised); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); animation: rise .25s var(--ease); }
.toast.err { border-color: var(--err); } .toast.err .ico { color: var(--err); } .toast .ico { color: var(--ok); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.modal-back { position: fixed; inset: 0; z-index: 80; background: rgba(5, 6, 8, .6); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(440px, 100%); padding: 24px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); animation: rise .2s var(--ease); }
.modal h3 { margin: 0 0 8px; font-size: 1.15rem; } .modal p { margin: 0 0 16px; color: var(--muted); }
.modal .input { margin-bottom: 16px; } .modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ================= app shell ================= */
.shell { display: grid; grid-template-columns: 280px minmax(0, 1fr); height: 100dvh; overflow: hidden; }
.shell.has-work { grid-template-columns: 280px minmax(340px, 5fr) minmax(0, 7fr); }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--bg-2); border-right: 1px solid var(--line); }
.sb-top { padding: 14px 12px 8px; display: grid; gap: 10px; }
.sb-brand { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px; }
.new-chat { justify-content: flex-start; padding: 0 14px; }
.sb-search { position: relative; } .sb-search input { min-height: 38px; font-size: .9rem; padding-left: 36px; border-radius: 10px; } .sb-search .ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; display: grid; align-content: start; gap: 1px; }
.chat-list .group { padding: 16px 10px 6px; font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); }
.chat-item { position: relative; display: flex; align-items: center; border-radius: 10px; transition: background .12s; }
.chat-item a { flex: 1; min-width: 0; padding: 9px 36px 9px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: .92rem; }
.chat-item .ct { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item:hover { background: var(--hover); } .chat-item:hover a { color: var(--text); }
.chat-item[aria-current="true"] { background: var(--raised); } .chat-item[aria-current="true"] a { color: var(--text); font-weight: 600; }
.chat-item[aria-current="true"]::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px; background: var(--accent); }
.chat-item .row-btn { position: absolute; right: 3px; top: 50%; transform: translateY(-50%); opacity: 0; }
.chat-item:hover .row-btn, .chat-item:focus-within .row-btn, .chat-item .row-btn[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .chat-item .row-btn { opacity: 1; } }
.sb-empty { padding: 22px 12px; color: var(--faint); font-size: .9rem; text-align: center; }
.sb-foot { padding: 10px 10px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); display: flex; align-items: center; gap: 6px; }
.user-btn { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; border-radius: 12px; background: transparent; text-align: left; } .user-btn:hover { background: var(--hover); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent-2); font-weight: 700; }
.user-btn .who { flex: 1; min-width: 0; display: grid; line-height: 1.2; } .user-btn b { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .user-btn small { color: var(--faint); font-size: .76rem; }
.scrim { display: none; }
/* collapsed rail (desktop) */
.shell.rail { grid-template-columns: 68px minmax(0, 1fr); } .shell.rail.has-work { grid-template-columns: 68px minmax(340px, 5fr) minmax(0, 7fr); }
.shell.rail .sb-brand { flex-direction: column; } .shell.rail .brand-name, .shell.rail .new-chat .lbl, .shell.rail .sb-search, .shell.rail .chat-list, .shell.rail .user-btn .who, .shell.rail .user-btn > .ico { display: none; }
.shell.rail .new-chat { justify-content: center; padding: 0; } .shell.rail .sb-foot { flex-direction: column; } .shell.rail .user-btn { flex: none; padding: 4px; }
.pop { position: fixed; z-index: 95; min-width: 210px; max-width: 280px; padding: 6px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); animation: rise .15s var(--ease); }
.pop-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: 9px; text-align: left; color: var(--text); text-decoration: none; font-size: .92rem; } .pop-item:hover, .pop-item:focus-visible { background: var(--hover); } .pop-item.danger { color: var(--err); }
.pop-sep { height: 1px; background: var(--line); margin: 5px 4px; } .pop-text { padding: 8px 12px; font-size: .82rem; color: var(--faint); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.topbar { flex: none; display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 14px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
.topbar .ttl { flex: 1; min-width: 0; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#menu-btn { display: none; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* messages */
.messages { flex: 1; overflow-y: auto; padding: 24px 16px 8px; scroll-behavior: smooth; overscroll-behavior: contain; }
.msg { max-width: var(--read); margin: 0 auto 22px; display: grid; gap: 6px; animation: rise .25s var(--ease); }
.msg.user { justify-items: end; }
.bubble { max-width: 88%; padding: 11px 16px; border-radius: 18px 18px 6px 18px; background: var(--raised); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.model .out { width: 100%; }
.msg-tools { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; } .msg:hover .msg-tools, .msg:focus-within .msg-tools { opacity: 1; }
@media (hover: none) { .msg-tools { opacity: 1; } }
.att-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--raised); border: 1px solid var(--line); font-size: .82rem; color: var(--muted); max-width: 220px; } .chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-line { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: .92rem; }
.dots { display: inline-flex; gap: 4px; } .dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: bob 1.1s ease-in-out infinite; } .dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }
.notice { max-width: var(--read); margin: 0 auto 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-radius: var(--r); background: var(--warn-soft); color: var(--text); border: 1px solid transparent; font-size: .92rem; }
.notice.err { background: var(--err-soft); } .notice .grow { flex: 1; min-width: 200px; }
.continue-bar { max-width: var(--read); margin: -8px auto 22px; display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .9rem; }

/* markdown */
.md { overflow-wrap: anywhere; } .md > :first-child { margin-top: 0; } .md > :last-child { margin-bottom: 0; }
.md p { margin: .7em 0; } .md h1, .md h2, .md h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; line-height: 1.25; margin: 1.3em 0 .5em; } .md h1 { font-size: 1.6rem; } .md h2 { font-size: 1.35rem; } .md h3 { font-size: 1.15rem; }
.md ul, .md ol { padding-left: 1.4em; } .md li { margin: .25em 0; } .md a { color: var(--accent-2); }
.md code { font-family: var(--mono); font-size: .88em; padding: .12em .4em; border-radius: 6px; background: var(--code-bg); border: 1px solid var(--line); }
.md blockquote { margin: .8em 0; padding: .1em 1em; border-left: 3px solid var(--accent); color: var(--muted); }
.md table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; } .md th, .md td { padding: 8px 12px; border: 1px solid var(--line); text-align: left; }
.codebox { margin: .9em 0; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--code-bg); }
.codebox .bar { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px 6px 14px; font: 600 .74rem var(--mono); color: var(--faint); border-bottom: 1px solid var(--line); text-transform: lowercase; }
.codebox .copy { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); font: inherit; padding: 4px 8px; border-radius: 6px; } .codebox .copy:hover { background: var(--hover); color: var(--text); }
.codebox pre, .fc-code { margin: 0; padding: 14px; overflow: auto; font: .84rem/1.6 var(--mono); max-height: 460px; } .md pre code { background: none; border: 0; padding: 0; font-size: inherit; }

/* file cards and zip bar (from ai-files.js) */
.ai-out { display: grid; gap: 12px; }
.file-card, .zip-bar { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.file-card.partial { border-color: var(--warn); }
.fc-head { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
.fc-ico { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-2); flex: none; }
.fc-meta { flex: 1; min-width: 0; } .fc-name { font: 600 .9rem var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .fc-sub { font-size: .78rem; color: var(--faint); }
.fc-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.fc-body { border-top: 1px solid var(--line); background: var(--code-bg); }
.fc-warn { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; background: var(--warn-soft); font-size: .86rem; border-top: 1px solid var(--line); }
.zip-bar { display: flex; align-items: center; gap: 14px; padding: 12px 14px; background: linear-gradient(135deg, var(--accent-soft), transparent 70%), var(--surface); }
.zb-ico { color: var(--accent-2); } .zb-meta { flex: 1; min-width: 0; } .zb-name { font-weight: 700; } .zb-sub { font-size: .8rem; color: var(--faint); }
.zb-tree summary { cursor: pointer; font-size: .8rem; color: var(--muted); margin-top: 4px; } .zb-tree pre { margin: 6px 0 0; font: .78rem var(--mono); color: var(--muted); }

/* composer, queue */
.dock { flex: none; padding: 8px 16px calc(14px + var(--safe-b)); }
.queue { max-width: var(--read); margin: 0 auto 10px; display: grid; gap: 6px; }
.q-head { display: flex; align-items: center; gap: 8px; font-size: .76rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--faint); }
.q-item { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border: 1px dashed var(--line-2); border-radius: 14px; background: var(--bg-2); font-size: .92rem; }
.q-item .n { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-2); display: grid; place-items: center; font-size: .75rem; font-weight: 700; }
.q-item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.q-paused { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-radius: 14px; background: var(--warn-soft); font-size: .88rem; }
.composer { max-width: var(--read); margin: 0 auto; display: flex; flex-direction: column; gap: 4px; padding: 12px 12px 10px 18px; border: 1px solid var(--line-2); border-radius: 26px; background: var(--surface); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s, background .15s; }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.composer.drag { border-color: var(--accent); background: var(--accent-soft); border-style: dashed; }
.composer.uploading { opacity: .8; }
.composer textarea { width: 100%; min-height: 30px; max-height: 200px; padding: 5px 0; border: 0; outline: 0; resize: none; background: transparent; line-height: 1.55; font-size: 1rem; }
.composer textarea::placeholder { color: var(--faint); }
.c-bar { display: flex; align-items: center; gap: 8px; }
.c-btn { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-2); background: transparent; color: var(--muted); display: grid; place-items: center; transition: background .15s, color .15s; } .c-btn:hover { background: var(--hover); color: var(--text); }
.c-send { flex: none; width: 38px; height: 38px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); transition: transform .1s, background .15s, opacity .15s; }
.c-send:hover { background: var(--accent-2); } .c-send:active { transform: scale(.93); } .c-send:disabled { opacity: .3; cursor: not-allowed; }
.c-stop { background: var(--text); color: var(--bg); } .c-stop:hover { background: var(--muted); } .c-stop.stopping { opacity: .5; pointer-events: none; }
.c-files { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0 6px; }
.att { display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-2); max-width: 250px; }
.att.img { padding-left: 6px; } .att img { width: 40px; height: 40px; object-fit: cover; border-radius: 8px; }
.att .meta { display: grid; min-width: 0; line-height: 1.25; } .att .n { font-size: .84rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .att .s { font-size: .74rem; color: var(--faint); }
.att button { border: 0; background: none; color: var(--faint); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; } .att button:hover { background: var(--err-soft); color: var(--err); }
.c-foot { max-width: var(--read); margin: 8px auto 0; display: flex; justify-content: space-between; gap: 12px; font-size: .78rem; color: var(--faint); padding: 0 10px; }
.c-hint kbd { font: inherit; padding: 0 5px; border: 1px solid var(--line-2); border-radius: 5px; }
/* file chips in the chat: files are not shown or downloaded here, only in the Code tab */
.fchips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.fchip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px 7px 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font: 500 .83rem var(--mono); color: var(--text); transition: border-color .15s, transform .1s; }
.fchip:hover { border-color: var(--accent); transform: translateY(-1px); } .fchip .ico { color: var(--ok); } .fchip .ln { font: 500 .76rem var(--sans); color: var(--faint); }
.fchip.writing { border-color: var(--accent); background: var(--accent-soft); } .fchip.cut .ico { color: var(--warn); } .fchip .spinner { width: 14px; height: 14px; }
.mem-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; margin-top: 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); font-size: .8rem; font-weight: 600; text-decoration: none; } .mem-chip .sub { color: var(--muted); font-weight: 500; }

/* empty state */
.empty { margin: auto; max-width: 640px; padding: 24px 20px 12px; text-align: center; }
.empty h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.1; letter-spacing: -.02em; margin: 0 0 12px; } .empty h1 em { color: var(--accent); font-style: italic; }
.empty p { color: var(--muted); margin: 0 0 26px; }
.ideas { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; text-align: left; }
.idea { padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); text-align: left; transition: border-color .15s, transform .15s, background .15s; }
.idea:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--raised); } .idea b { display: block; margin-bottom: 2px; } .idea span { font-size: .86rem; color: var(--muted); }

/* ================= workspace (like an AI studio) ================= */
.work { display: none; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg-2); border-left: 1px solid var(--line); }
.shell.has-work .work { display: flex; }
.w-bar { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface); flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; color: var(--muted); font-weight: 600; font-size: .85rem; display: inline-flex; align-items: center; gap: 6px; }
.seg button[aria-pressed="true"] { background: var(--raised); color: var(--text); box-shadow: var(--shadow); }
.w-title { flex: 1; min-width: 0; font: 600 .8rem var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 700; color: var(--accent-2); } .live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; transform: scale(.7); } }
.w-stage { flex: 1; min-height: 0; overflow: auto; display: flex; justify-content: center; padding: 14px; background: radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0) 0 0 / 18px 18px; }
.w-stage iframe { width: 100%; height: 100%; border: 1px solid var(--line-2); border-radius: var(--r); background: #fff; box-shadow: var(--shadow); transition: width .25s var(--ease); }
.w-stage[data-device="tablet"] iframe { width: 768px; max-width: 100%; } .w-stage[data-device="phone"] iframe { width: 390px; max-width: 100%; }
.w-code { flex: 1; min-height: 0; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.w-tree { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.w-tree-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 6px 12px; } .w-tree-head b { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.w-tree-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px 10px; border-bottom: 1px solid var(--line); }
.w-tree-list { flex: 1; overflow-y: auto; padding: 6px; display: grid; align-content: start; gap: 1px; }
.w-row { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 8px; border-radius: 9px; cursor: pointer; color: var(--muted); font: 500 .82rem var(--mono); } .w-row:hover { background: var(--hover); color: var(--text); }
.w-row[aria-current="true"] { background: var(--raised); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.w-row .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .w-row input { margin: 0; accent-color: var(--accent); flex: none; }
.w-row .row-act { display: none; gap: 0; } .w-row:hover .row-act, .w-row:focus-within .row-act { display: flex; }
.w-edit { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--code-bg); }
.ed-head { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 14px; border-bottom: 1px solid var(--line); background: var(--surface); } .ed-name { flex: 1; min-width: 0; font: 600 .82rem var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .ed-state { font-size: .76rem; color: var(--faint); }
.ed-lock { padding: 7px 14px; background: var(--warn-soft); font-size: .84rem; }
.ed { flex: 1; min-height: 0; display: grid; grid-template-columns: auto minmax(0, 1fr); }
.ed-gutter, .ed-area { font: 400 .82rem/1.6 var(--mono); margin: 0; }
.ed-gutter { padding: 14px 10px 14px 14px; text-align: right; color: var(--faint); white-space: pre; overflow: hidden; user-select: none; border-right: 1px solid var(--line); }
.ed-area { padding: 14px; border: 0; outline: 0; resize: none; background: transparent; color: var(--text); white-space: pre; overflow: auto; tab-size: 2; min-width: 0; }
.w-console { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--code-bg); } .w-console-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.w-console-list { flex: 1; overflow: auto; }
.log { display: flex; align-items: flex-start; gap: 10px; padding: 8px 14px; border-bottom: 1px solid var(--line); } .log pre { flex: 1; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: .8rem/1.5 var(--mono); }
.log.error { background: var(--err-soft); } .log.warn { background: var(--warn-soft); }
.w-empty { margin: auto; display: grid; gap: 6px; justify-items: center; text-align: center; max-width: 320px; padding: 24px; color: var(--faint); } .w-empty b { color: var(--text); } .w-empty .ico { color: var(--accent); }
.m-tabs { display: none; }
.modal.wide { width: min(640px, 100%); max-height: 88dvh; overflow: auto; }
.modal-list { display: grid; gap: 8px; max-height: 50vh; overflow: auto; margin-bottom: 14px; }
.ver { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.gh .field { margin-bottom: 12px; } .gh-files { margin: 4px 0 14px; color: var(--muted); font-size: .88rem; } .gh-files pre { max-height: 140px; overflow: auto; font: .78rem var(--mono); } .gh-out { margin-top: 12px; }
/* Memory and Storage pages */
.page { max-width: 760px; margin: 0 auto; } .page h1 { font-family: var(--serif); font-weight: 500; font-size: 2rem; letter-spacing: -.02em; margin: 0 0 4px; } .page .sub { color: var(--muted); margin: 0 0 20px; }
.mem-list { display: grid; gap: 8px; } .mem { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); } .mem-text { overflow-wrap: anywhere; }
.mem input[type="checkbox"] { accent-color: var(--accent); }
.bar-track { height: 8px; border-radius: 99px; background: var(--bg-2); margin-top: 10px; overflow: hidden; } .bar-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width .3s var(--ease); } .bar-fill.warn { background: var(--warn); } .bar-fill.err { background: var(--err); }

/* ---------- small screens ---------- */
@media (max-width: 1100px) { .shell.has-work, .shell.rail.has-work { grid-template-columns: 270px minmax(0, 1fr); } .shell.has-work .work { position: fixed; inset: 0; z-index: 40; } .shell.has-work:not(.show-work) .work { display: none; } .m-tabs { display: inline-flex; } }
@media (max-width: 820px) {
  .shell, .shell.has-work, .shell.rail, .shell.rail.has-work { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(86vw, 320px); transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; } .shell.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(5, 6, 8, .55); }
  .shell.rail .brand-name, .shell.rail .new-chat .lbl, .shell.rail .sb-search, .shell.rail .chat-list, .shell.rail .user-btn .who, .shell.rail .user-btn > .ico { display: revert; } .shell.rail .sb-brand { flex-direction: row; } .rail-btn { display: none; }
  #menu-btn { display: inline-flex; }
  .messages { padding: 16px 12px 4px; } .dock { padding: 6px 10px calc(10px + var(--safe-b)); } .bubble { max-width: 94%; }
  .w-code { grid-template-columns: 1fr; grid-template-rows: minmax(120px, 34%) minmax(0, 1fr); } .w-tree { border-right: 0; border-bottom: 1px solid var(--line); }
  .c-hint { display: none; }
}

/* ================= landing, sign-in, legal-like pages ================= */
.site-nav { position: sticky; top: 0; z-index: 20; backdrop-filter: blur(12px); background: color-mix(in srgb, var(--bg) 82%, transparent); border-bottom: 1px solid var(--line); }
.site-nav .in { max-width: 1120px; margin: 0 auto; padding: 12px 20px; display: flex; align-items: center; gap: 16px; } .site-nav .grow { flex: 1; }
.site-nav nav { display: flex; gap: 4px; } .site-nav nav a { padding: 8px 12px; border-radius: var(--r-sm); color: var(--muted); text-decoration: none; font-weight: 500; font-size: .94rem; } .site-nav nav a:hover { color: var(--text); background: var(--hover); }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.hero { padding: clamp(48px, 9vw, 110px) 0 40px; text-align: center; }
.hero .eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); font-size: .84rem; font-weight: 600; color: var(--muted); margin-bottom: 22px; } .hero .eyebrow .ico { color: var(--accent); }
.hero h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(2.5rem, 7.5vw, 5rem); line-height: 1.02; letter-spacing: -.03em; margin: 0 auto 20px; max-width: 14ch; } .hero h1 em { font-style: italic; color: var(--accent); }
.hero p.lead { max-width: 56ch; margin: 0 auto 30px; color: var(--muted); font-size: clamp(1.02rem, 2vw, 1.2rem); }
.cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; } .cta-row .btn { min-height: 50px; padding: 0 26px; font-size: 1rem; border-radius: 14px; }
.mock { margin: 54px auto 0; max-width: 980px; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-lg); overflow: hidden; text-align: left; }
.mock-bar { display: flex; gap: 7px; align-items: center; padding: 11px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); } .mock-bar i { width: 11px; height: 11px; border-radius: 50%; background: var(--line-2); } .mock-bar span { margin-left: 10px; font: 600 .76rem var(--mono); color: var(--faint); }
.mock-body { display: grid; grid-template-columns: 5fr 7fr; min-height: 300px; } .mock-chat { padding: 18px; display: grid; gap: 12px; align-content: start; border-right: 1px solid var(--line); font-size: .92rem; }
.mock-chat .b { padding: 10px 14px; border-radius: 14px; background: var(--raised); border: 1px solid var(--line); } .mock-chat .b.me { justify-self: end; background: var(--accent-soft); border-color: transparent; }
.mock-prev { padding: 22px; display: grid; gap: 12px; align-content: center; background: radial-gradient(circle at 1px 1px, var(--line) 1px, transparent 0) 0 0 / 18px 18px; } .mock-prev .card { padding: 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow); } .mock-prev .l { height: 10px; border-radius: 6px; background: var(--line-2); margin-bottom: 10px; } .mock-prev .l.a { width: 55%; background: var(--accent); } .mock-prev .l.s { width: 80%; }
.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; padding: 70px 0 20px; }
.feat { padding: 24px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); } .feat .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent-2); align-items: center; justify-content: center; margin-bottom: 14px; } .feat h3 { margin: 0 0 6px; font-size: 1.1rem; } .feat p { margin: 0; color: var(--muted); font-size: .95rem; }
.sec-title { text-align: center; font-family: var(--serif); font-weight: 500; font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -.02em; margin: 70px 0 30px; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; counter-reset: s; } .step { padding: 22px; border-left: 2px solid var(--accent); background: var(--surface); border-radius: 0 var(--r) var(--r) 0; counter-increment: s; } .step::before { content: "0" counter(s); font: 700 .8rem var(--mono); color: var(--accent-2); } .step h3 { margin: 4px 0 4px; } .step p { margin: 0; color: var(--muted); font-size: .94rem; }
.faq { max-width: 760px; margin: 0 auto; display: grid; gap: 8px; } .faq details { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 4px 18px; } .faq summary { cursor: pointer; padding: 14px 0; font-weight: 600; } .faq p { margin: 0 0 14px; color: var(--muted); }
.final { margin: 80px 0 60px; padding: clamp(32px, 6vw, 60px); border-radius: var(--r-xl); text-align: center; background: linear-gradient(135deg, var(--accent-soft), transparent), var(--surface); border: 1px solid var(--line-2); } .final h2 { font-family: var(--serif); font-weight: 500; font-size: clamp(1.8rem, 4vw, 2.8rem); margin: 0 0 18px; letter-spacing: -.02em; }
.site-foot { border-top: 1px solid var(--line); padding: 26px 20px calc(30px + var(--safe-b)); display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: center; color: var(--muted); font-size: .9rem; } .site-foot a { color: var(--muted); text-decoration: none; } .site-foot a:hover { color: var(--text); text-decoration: underline; }
@media (max-width: 720px) { .mock-body { grid-template-columns: 1fr; } .mock-chat { border-right: 0; border-bottom: 1px solid var(--line); } .site-nav nav { display: none; } }

.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-art { padding: 40px; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; background: radial-gradient(900px 500px at 10% 0%, var(--accent-soft), transparent 60%), var(--bg-2); border-right: 1px solid var(--line); }
.auth-art h1 { font-family: var(--serif); font-weight: 500; font-size: clamp(2.2rem, 4.4vw, 3.4rem); line-height: 1.05; letter-spacing: -.025em; margin: 0 0 14px; } .auth-art h1 em { color: var(--accent); }
.auth-art p { color: var(--muted); max-width: 42ch; margin: 0 0 22px; }
.auth-feats { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; } .auth-feats li { display: flex; align-items: center; gap: 12px; font-weight: 500; } .auth-feats .ico { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-2); align-items: center; justify-content: center; }
.auth-form-wrap { display: grid; place-items: center; padding: 28px 20px; position: relative; }
.auth-card { width: min(430px, 100%); } .auth-card h2 { font-family: var(--serif); font-weight: 500; font-size: 2rem; letter-spacing: -.02em; margin: 0 0 4px; } .auth-card .sub { margin: 0 0 22px; color: var(--muted); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: var(--r); background: var(--bg-2); border: 1px solid var(--line); margin-bottom: 18px; } .tabs button { border: 0; background: none; padding: 9px; border-radius: 9px; font-weight: 600; color: var(--muted); } .tabs button[aria-selected="true"] { background: var(--raised); color: var(--text); box-shadow: var(--shadow); }
.divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--faint); font-size: .85rem; } .divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-msg { min-height: 1.3em; margin: 0 0 10px; font-size: .9rem; color: var(--err); } .auth-msg.ok { color: var(--ok); }
.auth-hint { margin: 10px 0 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--info-soft); color: var(--info); font-size: .88rem; }
.theme-float { position: fixed; top: 14px; right: 14px; z-index: 5; }
@media (max-width: 880px) { .auth { grid-template-columns: 1fr; } .auth-art { display: none; } }

/* ================= admin ================= */
.adm { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100dvh; }
.adm-side { padding: 18px 12px; border-right: 1px solid var(--line); background: var(--bg-2); display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100dvh; }
.adm-side .brand { padding: 4px 8px 14px; }
.adm-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-sm); color: var(--muted); text-decoration: none; font-weight: 600; font-size: .94rem; cursor: pointer; } .adm-nav a:hover { background: var(--hover); color: var(--text); } .adm-nav a[aria-current="page"] { background: var(--raised); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.adm-main { padding: 28px clamp(16px, 4vw, 40px) 80px; min-width: 0; max-width: 1100px; }
.adm-main h1 { font-family: var(--serif); font-weight: 500; font-size: 2rem; letter-spacing: -.02em; margin: 0 0 4px; } .adm-main .sub { color: var(--muted); margin: 0 0 24px; max-width: 70ch; }
.card { padding: 20px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); margin-bottom: 16px; } .card h2 { margin: 0 0 12px; font-size: 1.05rem; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; } .row.end { justify-content: flex-end; } .grow { flex: 1; }
.rule { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; padding: 16px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); margin-bottom: 10px; } .rule.off { opacity: .55; }
.rule h3 { margin: 0 0 4px; font-size: 1rem; } .rule p { margin: 0; color: var(--muted); font-size: .92rem; white-space: pre-wrap; } .rule .ex { margin-top: 8px; font-size: .84rem; display: grid; gap: 3px; } .rule .ex b.bad { color: var(--err); } .rule .ex b.good { color: var(--ok); }
.pri { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-2); font-weight: 800; }
.switch { position: relative; width: 42px; height: 24px; flex: none; } .switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; z-index: 1; } .switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--line-2); transition: background .2s; } .switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s var(--ease); } .switch input:checked + i { background: var(--ok); } .switch input:checked + i::after { transform: translateX(18px); } .switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.test-out { min-height: 220px; max-height: 520px; overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-2); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; } .tbl th, .tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; } .tbl th { font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); } .tbl td.mono, .mono { font-family: var(--mono); font-size: .82rem; } .tbl-wrap { overflow-x: auto; }
.detail { font: .78rem/1.5 var(--mono); color: var(--muted); white-space: pre-wrap; word-break: break-word; max-height: 140px; overflow: auto; }
@media (max-width: 820px) { .adm { grid-template-columns: 1fr; } .adm-side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); } .adm-side .brand { padding: 0 8px; } .adm-nav { display: flex; gap: 2px; overflow-x: auto; } .rule { grid-template-columns: 1fr; } }

/* topbar "Preview" button: only when there is something to preview and the workspace is a full-screen sheet */
.topbar .m-tabs { display: none !important; }
@media (max-width: 1100px) { .shell.has-work .topbar .m-tabs { display: inline-flex !important; } }
.view-pad { overflow-y: auto; padding: 24px 16px; }

/* Admin: Secrets form */
.sec-group { margin-bottom: 22px; } .sec-group h2 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin: 0 0 10px; }
.sec-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) auto; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); margin-bottom: 8px; }
.sec-row .lbl b { display: block; } .sec-row .lbl span { font-size: .82rem; color: var(--muted); }
@media (max-width: 820px) { .sec-row { grid-template-columns: 1fr; } }

.w-bar { flex-wrap: nowrap; } .w-title { flex: 1 1 30px; }
@media (max-width: 1500px) { .w-bar .gh-label { display: none; } }
@media (max-width: 1100px) { .w-bar { flex-wrap: wrap; } .w-bar .gh-label { display: inline; } }
