/* ============================================================
   Kratt — "circuit-tech, refined". Green node/trace brand,
   geometric display type + mono accents, full light + dark.
   Self-hosted fonts (CSP-safe, private, offline-ready).
   ============================================================ */
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/hanken-400.woff2') format('woff2'); }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/hanken-500.woff2') format('woff2'); }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 600; font-display: swap; src: url('/fonts/hanken-600.woff2') format('woff2'); }
@font-face { font-family: 'Hanken Grotesk'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/hanken-700.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 700; font-display: swap; src: url('/fonts/sora-700.woff2') format('woff2'); }
@font-face { font-family: 'Sora'; font-style: normal; font-weight: 800; font-display: swap; src: url('/fonts/sora-800.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 400; font-display: swap; src: url('/fonts/jbmono-400.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-style: normal; font-weight: 500; font-display: swap; src: url('/fonts/jbmono-500.woff2') format('woff2'); }

:root {
  --font-sans: 'Hanken Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Sora', var(--font-sans);
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* Dark (default) — green-tinted near-black */
  --bg: #070b08;
  --bg-2: #0c120e;
  --bg-3: #111a14;
  --bg-4: #19251c;
  --border: #1b291f;
  --border-2: #294234;
  --text: #e7f0e9;
  --muted: #84978a;
  --accent: #38c66c;
  --accent-2: #1f9e4c;
  --grad: linear-gradient(135deg, #43d473 0%, #20a24e 58%, #0f7d3c 118%);
  --grad-soft: linear-gradient(135deg, rgba(67,212,115,.16), rgba(31,158,76,.09));
  --ring: rgba(56,198,108,.22);
  --glow: rgba(31,158,76,.5);
  --glow-a: rgba(31,158,76,.13);
  --glow-b: rgba(67,212,115,.07);
  --dot: rgba(67,212,115,.05);
  --code-bg: #060a07;
  --inline-code: rgba(120,220,160,.12);
  --link: #4bd581;

  --danger: #f0616d;
  --pin: #f5b942;
  --rec: #ff5067;
  --radius: 14px;
  --shadow: 0 20px 55px -20px rgba(0,0,0,.72);
}

/* Light — soft green-tinted paper */
html[data-theme="light"] {
  --bg: #eef3ec;
  --bg-2: #ffffff;
  --bg-3: #e8f0e7;
  --bg-4: #dce8db;
  --border: #dde8db;
  --border-2: #c6d8c5;
  --text: #14231a;
  --muted: #5c6e60;
  --accent: #15873b;
  --accent-2: #0f7d3c;
  --grad: linear-gradient(135deg, #2cb54e, #0f8239);
  --grad-soft: linear-gradient(135deg, rgba(44,181,78,.14), rgba(15,130,57,.08));
  --ring: rgba(21,135,59,.18);
  --glow: rgba(20,140,62,.32);
  --glow-a: rgba(44,181,78,.12);
  --glow-b: rgba(15,130,57,.06);
  --dot: rgba(15,130,57,.06);
  --code-bg: #0c120e;
  --inline-code: rgba(15,130,57,.10);
  --link: #0f7d3c;
  --shadow: 0 20px 55px -22px rgba(20,60,35,.28);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
/* Atmosphere: green corner glows + faint circuit-node grid, behind everything. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(58% 44% at 100% -2%, var(--glow-a), transparent 60%),
    radial-gradient(46% 40% at -5% 102%, var(--glow-b), transparent 60%),
    radial-gradient(circle at 1px 1px, var(--dot) 1px, transparent 1.7px);
  background-size: 100% 100%, 100% 100%, 26px 26px;
}
.app, .auth { position: relative; z-index: 1; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 18px; font-size: 13px; margin: 8px 0 0; }
.ic { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

button { font: inherit; cursor: pointer; border: none; border-radius: 10px; color: var(--text); background: var(--bg-3); transition: all .16s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--grad); color: #fff; padding: 10px 16px; font-weight: 600; box-shadow: 0 6px 18px -6px var(--glow); }
.primary:hover:not(:disabled) { filter: brightness(1.07); transform: translateY(-1px); }
.glow { box-shadow: 0 8px 28px -6px var(--glow); }
.ghost { background: transparent; color: var(--muted); padding: 8px 12px; }
.ghost:hover { background: var(--bg-3); color: var(--text); }
.icon-btn { background: transparent; color: var(--muted); width: 38px; height: 38px; border-radius: 10px; }
.icon-btn:hover { background: var(--bg-4); color: var(--text); }

input, textarea {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 11px; padding: 12px 14px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
::placeholder { color: var(--muted); opacity: .6; }

h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.02em; }

.brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-weight: 800; font-size: 20px; letter-spacing: -.02em; }
.brand .ic { width: 24px; height: 24px; fill: var(--accent); stroke: none; }
.brand span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Auth ---------- */
.auth { display: flex; align-items: center; justify-content: center; height: 100vh; position: relative; overflow: hidden; }
.auth-bg { position: absolute; inset: 0; z-index: 0; background:
  radial-gradient(54% 48% at 18% 8%, rgba(67,212,115,.20), transparent 58%),
  radial-gradient(50% 50% at 86% 92%, rgba(31,158,76,.18), transparent 60%),
  radial-gradient(40% 40% at 72% 18%, rgba(20,180,90,.14), transparent 60%),
  radial-gradient(circle at 1px 1px, var(--dot) 1px, transparent 1.7px);
  background-size: 100% 100%, 100% 100%, 100% 100%, 24px 24px; }
.auth-card { position: relative; z-index: 1; width: 364px; background: color-mix(in srgb, var(--bg-2) 82%, transparent); backdrop-filter: blur(18px); border: 1px solid var(--border-2); border-radius: 22px; padding: 34px; box-shadow: var(--shadow); }
.auth-card .brand { font-size: 26px; margin-bottom: 6px; }
.auth-card form { display: flex; flex-direction: column; gap: 11px; margin-top: 22px; }
.auth-card .primary { padding: 12px; }

/* ---------- App layout ---------- */
.app { display: grid; grid-template-columns: 290px 1fr; grid-template-rows: auto 1fr; height: 100vh; overflow: hidden; }
.app > .appbar { grid-column: 1 / -1; }
.app > .sidebar { grid-row: 2; }
.app > .main { grid-row: 2; }

.sidebar { background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; gap: 12px; min-height: 0; overflow: hidden; }
.sidebar-brand { padding: 6px 4px 4px; justify-content: center; }
.new-chat { width: 100%; padding: 12px; border-radius: 12px; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -4px; padding: 0 4px; display: flex; flex-direction: column; gap: 3px; }
.chat-list::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 8px; }
.chat-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 8px; }
.chat-list::-webkit-scrollbar-thumb:hover, .messages::-webkit-scrollbar-thumb:hover { background: var(--border-2); }
.list-section { font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); padding: 14px 10px 5px; display: flex; align-items: center; gap: 6px; }
.list-section .ic { width: 12px; height: 12px; }

.chat-item { display: flex; align-items: center; gap: 8px; padding: 10px 11px; border-radius: 11px; cursor: pointer; position: relative; border: 1px solid transparent; transition: background .14s, border-color .14s; }
.chat-item:hover { background: var(--bg-3); }
.chat-item.active { background: var(--grad-soft); border-color: var(--border-2); }
.chat-item.active::before { content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 3px; height: 17px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.live-usage { align-self: center; max-width: none; width: 100%; margin: 0 auto 6px; text-align: right; font-family: var(--font-mono); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.live-usage b { color: var(--accent); font-weight: 600; }
.gen-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; box-shadow: 0 0 8px var(--accent); animation: genpulse 1.1s ease-in-out infinite; }
@keyframes genpulse { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }
.chat-item .pin-ic { width: 13px; height: 13px; color: var(--pin); }
.chat-item .title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.chat-item .actions { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); display: none; gap: 1px; }
.chat-item:hover .actions { display: flex; }
.chat-item:hover .title { padding-right: 92px; }
.chat-item .rename-input { width: 100%; padding: 3px 6px; font-size: 14px; border-radius: 7px; }
.chat-item .actions button { width: 27px; height: 27px; padding: 0; background: transparent; color: var(--muted); border-radius: 8px; }
.chat-item .actions button:hover { background: var(--bg-4); color: var(--text); }
.chat-item .actions .ic { width: 15px; height: 15px; }
.chat-item .actions .pinned { color: var(--pin); }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.row-btn { justify-content: flex-start; background: transparent; color: var(--muted); padding: 10px 11px; width: 100%; }
.row-btn:hover { background: var(--bg-3); color: var(--text); }
.user-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px; }
.user-chip { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; min-width: 0; }
.mini-avatar { width: 28px; height: 28px; border-radius: 8px; background: var(--grad); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0; }

/* Brand logos */
.brand-logo { height: 30px; width: auto; display: block; }
.sidebar-brand .brand-logo { height: 50px; width: auto; max-width: 100%; }
.sidebar-brand { cursor: pointer; }
.sidebar-brand .brand-mark { height: 44px; width: auto; transition: transform .15s ease; }
.sidebar-brand:hover .brand-mark { transform: scale(1.05); }
.auth-brand { justify-content: center; margin-bottom: 16px; }
.auth-brand .brand-logo { height: 56px; width: auto; }

/* ---------- Main / topbar ---------- */
.main { display: flex; flex-direction: column; min-height: 0; min-width: 0; position: relative; }
.scroll-bottom {
  position: absolute; left: 50%; transform: translateX(-50%) translateY(8px);
  bottom: 104px; z-index: 20; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border-2);
  box-shadow: 0 8px 24px -8px rgba(0,0,0,.4); opacity: 0; pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.scroll-bottom.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.scroll-bottom:hover { border-color: var(--accent); color: var(--accent); }
.scroll-bottom .ic { width: 18px; height: 18px; }
.topbar { height: 58px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 72%, transparent); backdrop-filter: blur(10px); }
.topbar-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; font-size: 18px; }
.route-pill { display: flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); background: var(--grad-soft); border: 1px solid var(--border-2); padding: 6px 12px; border-radius: 20px; font-weight: 500; }
.route-pill .ic { width: 14px; height: 14px; fill: currentColor; stroke: none; }
.route-pill .pill-logo { height: 16px; width: auto; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ---------- Messages ---------- */
.messages { flex: 1; overflow-y: auto; padding: 28px 0 12px; position: relative; z-index: 1; }
.msg { max-width: 880px; margin: 0 auto 24px; padding: 0 24px; display: flex; gap: 14px; animation: rise .35s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.msg.user { flex-direction: row-reverse; }
.avatar { width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.msg.user .avatar { background: var(--grad); color: #fff; }
.msg.assistant .avatar { background: var(--bg-3); border: 1px solid var(--border-2); }
.msg.assistant .avatar img { width: 23px; height: 23px; object-fit: contain; }
.msg .body { min-width: 0; max-width: calc(100% - 48px); display: flex; flex-direction: column; }
.msg.user .body { align-items: flex-end; }

.meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.meta .arrow { color: var(--border-2); }
.content { line-height: 1.68; word-wrap: break-word; padding: 13px 16px; border-radius: 16px; }
.msg.assistant .content { background: color-mix(in srgb, var(--bg-2) 90%, transparent); border: 1px solid var(--border); border-top-left-radius: 5px; }
.msg.user .content { background: var(--grad); color: #fff; border-top-right-radius: 5px; box-shadow: 0 6px 20px -8px var(--glow); }
.content p { margin: 0 0 10px; } .content p:last-child { margin-bottom: 0; }
.content pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 13px; overflow-x: auto; margin: 10px 0; }
.content code { background: var(--inline-code); padding: 2px 6px; border-radius: 5px; font-size: 13px; font-family: var(--font-mono); }
.msg.user .content code { background: rgba(0,0,0,.2); }
.content pre code { background: none; padding: 0; }
.content ul, .content ol { margin: 0 0 10px; padding-left: 22px; }
.content a { color: var(--link); }
.msg.user .content a { color: #fff; text-decoration: underline; }

.badge { font-size: 11px; padding: 3px 9px; border-radius: 20px; background: var(--bg-3); border: 1px solid var(--border); white-space: nowrap; }
.badge.model { color: var(--accent); background: var(--grad-soft); border-color: var(--border-2); font-family: var(--font-mono); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { font-size: 12px; padding: 5px 11px; border-radius: 16px; background: var(--bg-3); border: 1px solid var(--border-2); display: inline-flex; align-items: center; gap: 5px; }
.chip-x { background: transparent; border: none; color: var(--muted); padding: 0 0 0 3px; font-size: 12px; }
.chip-x:hover { color: var(--danger); }
.thumb-chip { padding: 0; overflow: hidden; border: 1px solid var(--border-2); }
.chips .thumb { width: 140px; height: 105px; max-width: 46vw; object-fit: cover; border-radius: 11px; display: block; }
.chip-audio { height: 38px; max-width: 260px; }

.sources { margin-top: 12px; font-size: 13px; padding: 11px 14px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px; }
.sources > summary.src-head { color: var(--muted); font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; cursor: pointer; list-style: none; user-select: none; display: flex; align-items: center; gap: 6px; }
.sources > summary.src-head::-webkit-details-marker { display: none; }
.sources > summary.src-head::before { content: '▸'; font-size: 9px; transition: transform .15s ease; color: var(--accent); }
.sources[open] > summary.src-head { margin-bottom: 6px; }
.sources[open] > summary.src-head::before { transform: rotate(90deg); }
.sources a { display: block; color: var(--muted); margin: 3px 0; text-decoration: none; }
.sources a:hover { color: var(--accent); }

.empty { text-align: center; color: var(--muted); margin-top: 15vh; padding: 0 24px; animation: rise .4s ease both; }
.empty .orb { width: 78px; height: 78px; border-radius: 22px; background: var(--bg-3); border: 1px solid var(--border-2); margin: 0 auto 22px; display: flex; align-items: center; justify-content: center; box-shadow: 0 16px 44px -10px var(--glow); position: relative; }
.empty .orb::after { content: ""; position: absolute; inset: -1px; border-radius: 22px; padding: 1px; background: var(--grad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; opacity: .5; }
.empty .orb img { width: 62%; height: 62%; object-fit: contain; }
.empty h2 { color: var(--text); font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -.025em; margin: 0 0 8px; }
.empty p { line-height: 1.6; }

/* ---------- Composer ---------- */
.composer { padding: 8px 24px 18px; position: relative; z-index: 1; }
.route-badge { max-width: 880px; margin: 0 auto 8px; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 9px; padding: 0 6px; }
.route-badge b, .route-badge .label { color: var(--text); font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); animation: pulse 1.1s infinite; }
@keyframes pulse { 0%,100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1.1); } }

.pending { max-width: 880px; margin: 0 auto 8px; display: flex; flex-wrap: wrap; gap: 7px; }
.pending .thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border-2); }

.composer-box { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; background: color-mix(in srgb, var(--bg-2) 92%, transparent); border: 1px solid var(--border-2); border-radius: 20px; padding: 10px 12px; box-shadow: 0 10px 34px -18px rgba(0,0,0,.5); transition: border-color .15s, box-shadow .15s; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer-actions { display: flex; gap: 2px; }
.composer-actions .icon-btn { width: 36px; height: 36px; }
.composer textarea { resize: none; max-height: 240px; min-height: 24px; width: 100%; border: none; background: transparent; padding: 5px 6px; box-shadow: none !important; }
.composer textarea:focus { border: none; }
.send-btn { width: 40px; height: 40px; border-radius: 13px; background: var(--grad); color: #fff; flex-shrink: 0; box-shadow: 0 6px 16px -5px var(--glow); }
.send-btn:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px) scale(1.03); }
.send-btn .ic { width: 19px; height: 19px; }
.composer-hint { max-width: 880px; margin: 9px auto 0; text-align: center; font-size: 11.5px; }

/* Recorder */
.recorder { max-width: 880px; margin: 0 auto 8px; display: flex; align-items: center; gap: 12px; background: var(--bg-2); border: 1px solid var(--rec); border-radius: 16px; padding: 12px 16px; }
.rec-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--rec); box-shadow: 0 0 12px var(--rec); animation: pulse 1s infinite; }
.rec-label { font-weight: 600; color: var(--rec); }
.rec-time { font-family: var(--font-mono); color: var(--text); font-size: 15px; }
.rec-actions { margin-left: auto; display: flex; gap: 8px; }
.rec-actions .primary { padding: 8px 14px; background: var(--rec); box-shadow: none; }
.rec-actions .ic { width: 15px; height: 15px; fill: #fff; stroke: none; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 64%, transparent); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 50; animation: rise .2s ease; }
.modal-card { width: 540px; max-width: 92vw; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 20px; padding: 24px; max-height: 82vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-head h2 { margin: 0; font-size: 20px; font-family: var(--font-display); }
.add-user { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.add-user input { flex: 1 1 140px; width: auto; }
.add-user .check { display: flex; align-items: center; gap: 6px; white-space: nowrap; color: var(--muted); font-size: 13px; }
.add-user .check input { width: auto; flex: 0 0 auto; }
.add-user .primary { margin-left: auto; }
.plan-badge { display: inline-block; font-family: var(--font-mono); font-size: 11.5px; color: var(--accent); background: var(--grad-soft); border: 1px solid var(--border-2); padding: 5px 12px; border-radius: 20px; margin-bottom: 12px; font-weight: 500; }
.plan-select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  width: auto; padding: 8px 30px 8px 11px; font-size: 13px; border-radius: 9px; cursor: pointer;
  color: var(--text); background-color: var(--bg-2); border: 1px solid var(--border-2);
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="%2384978a" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>');
  background-repeat: no-repeat; background-position: right 10px center;
}
.plan-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.plan-select option { background: var(--bg-2); color: var(--text); }
.user-list { margin-top: 8px; display: flex; flex-direction: column; gap: 7px; }
.user-list .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 11px; }
.user-list .row > span:first-child { font-size: 14px; font-weight: 500; display: flex; align-items: center; min-width: 0; }
.user-list .row-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.user-list .row-right .ghost { color: var(--danger); padding: 6px 10px; font-size: 13px; }
.user-list .row-right .ghost:hover { background: rgba(240,97,109,.12); }
.user-list .row .tag { font-size: 10px; color: #fff; background: var(--grad); margin-left: 9px; padding: 2px 8px; border-radius: 12px; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Mobile ---------- */
.nav-overlay { display: none; }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 84vw; max-width: 320px; z-index: 66; transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow); padding-top: calc(16px + env(safe-area-inset-top)); background: var(--bg-2); }
  .app.nav-open .sidebar { transform: none; }
  .nav-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 65; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .app.nav-open .nav-overlay { display: block; opacity: 1; pointer-events: auto; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: env(safe-area-inset-top) 14px 0; height: calc(56px + env(safe-area-inset-top)); }
  .route-pill { display: none; }
  .msg, .composer-box, .route-badge, .pending, .recorder, .composer-hint { padding-left: 14px; padding-right: 14px; }
  .msg { padding: 0 14px; }
  .composer { padding: 8px 10px calc(12px + env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .composer-actions .icon-btn { width: 34px; height: 34px; }
  input, textarea { font-size: 16px; }
  .modal { align-items: flex-end; }
  .modal-card { width: 100%; max-width: 100%; max-height: 90vh; border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
}

body { position: fixed; inset: 0; width: 100%; }
.app, .auth { height: 100vh; height: var(--app-h, 100dvh); }
.main { height: 100%; min-height: 0; }
.topbar { position: sticky; top: 0; z-index: 5; }
* { -webkit-tap-highlight-color: transparent; }

.svg-sprite { position: absolute; width: 0; height: 0; }

/* Light theme: keep code blocks legible (dark surfaces stay dark) */
html[data-theme="light"] .auth-bg { opacity: .9; }
html[data-theme="light"] .toast { box-shadow: 0 10px 30px -12px rgba(20,60,35,.35); }

/* Custom confirm dialog */
#confirm-modal { z-index: 60; }
.confirm-card { width: 380px; max-width: 92vw; }
.confirm-title { font-size: 18px; font-family: var(--font-display); font-weight: 700; margin: 0 0 8px; }
.confirm-msg { font-size: 14.5px; line-height: 1.55; color: var(--muted); margin: 0 0 22px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }
.primary.danger { background: var(--danger); box-shadow: 0 6px 18px -6px rgba(240,97,109,.5); }

/* Toasts */
.toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--bg-3); border: 1px solid var(--border-2); color: var(--text); padding: 10px 16px; border-radius: 12px; font-size: 13.5px; box-shadow: var(--shadow); opacity: 0; transform: translateY(-8px); transition: all .25s ease; }
.toast.show { opacity: 1; transform: none; }

/* Search box */
.search-box { display: flex; align-items: center; gap: 8px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 11px; padding: 0 10px; transition: border-color .15s; }
.search-box:focus-within { border-color: var(--accent); }
.search-box .ic { width: 15px; height: 15px; color: var(--muted); }
.search-box input { border: none; background: transparent; padding: 9px 0; }
.search-box input:focus { box-shadow: none; }

/* Code blocks + highlighting */
.codeblock { margin: 10px 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--code-bg); }
.cb-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; background: rgba(127,200,150,.06); border-bottom: 1px solid var(--border); }
.cb-lang { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.cb-copy { background: transparent; color: var(--muted); font-size: 12px; padding: 3px 8px; gap: 5px; }
.cb-copy:hover { color: var(--accent); background: rgba(56,198,108,.12); }
.cb-copy .ic { width: 13px; height: 13px; }
.codeblock pre { margin: 0; border: none; border-radius: 0; background: transparent; }
.codeblock pre, .content pre { font-family: var(--font-mono); font-size: 13px; color: #d6e4da; }
.tok-c { color: #5f7568; font-style: italic; }
.tok-s { color: #7ee0a0; }
.tok-n { color: #f0a35e; }
.tok-k { color: #5fd0c0; font-weight: 600; }

/* Message hover actions */
.msg-actions { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions { opacity: 1; }
.msg.user .msg-actions { justify-content: flex-end; }
.msg-actions button { width: 30px; height: 30px; border-radius: 8px; background: transparent; color: var(--muted); }
.msg-actions button:hover { background: var(--bg-3); color: var(--text); }
.msg-actions .ic { width: 15px; height: 15px; }

/* Edit */
.edit-area { min-height: 80px; resize: vertical; }
.edit-row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* Generated images */
.gen-images { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.gen-img { max-width: 320px; max-height: 320px; border-radius: 12px; border: 1px solid var(--border); display: block; }

/* Send stop state */
.send-btn.stopping { background: var(--danger); box-shadow: 0 6px 16px -5px rgba(240,97,109,.6); }

/* Settings / usage fields */
.field-label { display: block; font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin: 14px 0 6px; }
.modal-card textarea { resize: vertical; }
.modal-card .primary { margin-top: 12px; }
.sep { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.mem-add { display: flex; gap: 8px; }
.mem-add input { flex: 1; }
.mem-add .primary { margin-top: 0; }
.memory-list { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.mem-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; background: var(--bg-3); border-radius: 10px; font-size: 14px; }
.mem-row .icon-btn { width: 30px; height: 30px; }
.mem-row .ic { width: 15px; height: 15px; }

/* Usage dashboard */
.usage-summary { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 6px; }
.stat { background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 3px; }
.stat b { font-family: var(--font-display); font-size: 24px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat span { font-size: 12px; color: var(--muted); }
.usage-models { display: flex; flex-direction: column; gap: 6px; }
.usage-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 10px 13px; background: var(--bg-3); border-radius: 10px; font-size: 13.5px; }
.um-model { font-family: var(--font-mono); color: var(--accent); }
.um-calls { color: var(--muted); font-size: 12px; }
.um-cost { font-weight: 600; }
.row-btn .ic { width: 17px; height: 17px; }

/* Budget bars */
.usage-budget { display: flex; flex-direction: column; gap: 12px; margin-bottom: 4px; }
.budget-note { font-size: 12px; line-height: 1.5; margin-top: 14px; }
.set-hint { font-size: 12.5px; margin: 4px 0 11px; line-height: 1.45; }
.mem-add .primary { flex-shrink: 0; padding: 10px 18px; }
.mem-list { margin-top: 12px; display: flex; flex-direction: column; gap: 7px; }
.mem-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 11px; }
.mem-text { flex: 1; font-size: 13.5px; line-height: 1.4; word-break: break-word; }
.mem-del { width: 30px; height: 30px; background: transparent; color: var(--muted); flex-shrink: 0; }
.mem-del:hover { background: var(--bg-4); color: var(--danger); }
.mem-del .ic { width: 15px; height: 15px; }
.mem-empty { font-size: 13px; padding: 6px 2px; }
.budget-row { display: flex; flex-direction: column; gap: 5px; }
.budget-top { display: flex; justify-content: space-between; font-size: 13px; }
.budget-top span:first-child { color: var(--muted); text-transform: capitalize; }
.budget-bar { height: 8px; border-radius: 6px; background: var(--bg-4); overflow: hidden; }
.budget-fill { height: 100%; border-radius: 6px; background: var(--grad); transition: width .3s; }
.budget-fill.warn { background: linear-gradient(90deg, #f5a623, #f5b942); }
.budget-fill.danger { background: linear-gradient(90deg, #e5484d, #f0616d); }

/* Mic listening state */
.icon-btn.listening { color: var(--rec); background: rgba(255,80,103,.12); }
.icon-btn.listening .ic { animation: pulse 1.1s infinite; }

/* Install button */
.install-btn { color: var(--accent); }
.install-btn:hover { color: var(--accent); background: var(--grad-soft); }

/* In-bubble "thinking" indicator */
.thinking { display: flex; align-items: center; flex-wrap: wrap; gap: 11px; padding: 3px 2px; }
.think-dots { display: inline-flex; gap: 5px; }
.think-dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: tdot 1.2s infinite ease-in-out both; }
.think-dots i:nth-child(1) { animation-delay: -0.24s; }
.think-dots i:nth-child(2) { animation-delay: -0.12s; }
@keyframes tdot { 0%, 80%, 100% { transform: scale(.5); opacity: .35; } 40% { transform: scale(1); opacity: 1; } }
.think-label { font-size: 14px; font-weight: 500; background: linear-gradient(90deg, var(--muted) 30%, var(--text) 50%, var(--muted) 70%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 2.2s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.think-live { flex-basis: 100%; width: 100%; margin-top: 4px; max-height: 130px; overflow: hidden;
  font-size: 12.5px; line-height: 1.5; color: var(--muted); white-space: pre-wrap; word-break: break-word;
  border-left: 2px solid var(--accent-2); padding: 2px 0 2px 11px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 22px); mask-image: linear-gradient(to bottom, transparent, #000 22px); }
.thoughts { margin: 0 0 10px; }
.thoughts > summary { cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 6px; user-select: none; }
.thoughts > summary::before { content: '💭'; }
.thoughts > summary:hover { color: var(--text); }
.thoughts[open] > summary { margin-bottom: 6px; }
.thoughts-body { padding: 9px 12px; background: var(--bg-3); border-left: 2px solid var(--accent-2); border-radius: 8px;
  color: var(--muted); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow-y: auto; }

/* Code runner */
.cb-btns { display: flex; gap: 4px; }
.cb-run { background: transparent; color: var(--muted); font-size: 12px; padding: 3px 8px; gap: 5px; }
.cb-run:hover { color: var(--accent); background: rgba(56,198,108,.12); }
.cb-run .ic { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.run-result { margin: 8px 0 4px; border: 1px solid var(--border-2); border-radius: 10px; overflow: hidden; background: var(--bg-2); }
.run-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 12px; background: var(--bg-3); border-bottom: 1px solid var(--border); font-family: var(--font-mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.run-head button { background: transparent; color: var(--muted); padding: 2px 7px; font-size: 13px; border-radius: 6px; }
.run-head button:hover { background: var(--bg-4); color: var(--text); }
.run-frame { width: 100%; height: 440px; max-height: 70vh; border: 0; background: #fff; display: block; }
.run-output { margin: 0; padding: 13px 14px; font-family: var(--font-mono); font-size: 13px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; color: var(--text); }
.run-output.err { color: var(--danger); }

.edit-hint { font-size: 12px; margin: 6px 0 0; }
.edit-area { min-height: 90px; }

/* Notifications */
#notif-btn { position: relative; }
.notif-badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--grad); color: #fff; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; line-height: 1; box-shadow: 0 0 10px -1px var(--glow); }
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-empty { padding: 18px 4px; text-align: center; }
.notif-item { padding: 11px 13px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: border-color .12s, background .12s; }
.notif-item:hover { border-color: var(--accent); background: var(--bg-4); }
.notif-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.notif-from { font-weight: 600; font-size: 14px; }
.notif-time { color: var(--muted); font-family: var(--font-mono); font-size: 11px; white-space: nowrap; }
.notif-subj { font-size: 13px; margin-top: 2px; }
.notif-prev { font-size: 12px; margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-detail .notif-back { margin-bottom: 12px; }
.notif-d-from { color: var(--muted); font-size: 13px; }
.notif-d-subject { font-weight: 600; font-size: 16px; margin: 4px 0 12px; font-family: var(--font-display); }
.notif-d-body { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.55; background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px; padding: 13px 15px; max-height: 46vh; overflow-y: auto; }
.notif-detail-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.notif-hint { font-size: 12px; }
/* ============================================================
   Unified Kratt app bar — shared across chat / calendar / budget.
   One consistent top bar to jump between the apps fast.
   ============================================================ */
.appbar {
  display: flex; align-items: center; gap: 14px;
  padding: 9px 18px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-1, var(--bg, #0b0f10)) 82%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 60;
}
.appbar-brand { display: flex; align-items: center; flex-shrink: 0; }
.appbar-logo { height: 30px; width: auto; display: block; transition: transform .15s ease; }
.appbar-brand:hover .appbar-logo { transform: scale(1.06); }
.app-switch {
  display: flex; align-items: center; gap: 3px; padding: 3px; border-radius: 13px;
  background: color-mix(in srgb, var(--text) 7%, transparent);
  border: 1px solid var(--border);
}
.app-switch a {
  display: flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: 13.5px; line-height: 1; white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.app-switch a:hover { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
.app-switch a.active {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 32%, transparent);
}
.app-switch a.active .sw-ic { color: var(--accent); }
.app-switch .sw-ic { width: 17px; height: 17px; flex: none; }
.appbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.appbar .icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px; color: var(--muted);
  background: transparent; border: 1px solid transparent; cursor: pointer;
  transition: background .15s, color .15s;
}
.appbar .icon-btn:hover { color: var(--text); background: color-mix(in srgb, var(--text) 8%, transparent); }
.appbar .icon-btn .ic { width: 18px; height: 18px; }
@media (max-width: 600px) {
  .appbar { padding: calc(7px + env(safe-area-inset-top)) 10px 7px; gap: 8px; }
  /* 7 apps can't fit a phone width: shrink the switcher and let it scroll (swipeable icons). */
  .app-switch { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .app-switch::-webkit-scrollbar { display: none; }
  .app-switch .sw-l { display: none; }
  .app-switch a { padding: 8px 10px; flex: 0 0 auto; }
  .appbar-logo { height: 24px; }
}
.app-switch a, .appbar-brand, a.brand { text-decoration: none; color: inherit; }

/* Chat top bar: hamburger only on mobile (overrides the shared .appbar .icon-btn display) */
.appbar .menu-btn { display: none; }
@media (max-width: 760px) { .appbar .menu-btn { display: inline-flex; font-size: 18px; } }

/* Markdown tables in chat messages */
.content .md-table-wrap { overflow-x: auto; margin: 12px 0; border: 1px solid var(--border); border-radius: 10px; -webkit-overflow-scrolling: touch; }
.content .md-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.content .md-table th, .content .md-table td { padding: 8px 13px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); text-align: left; vertical-align: top; }
.content .md-table th:last-child, .content .md-table td:last-child { border-right: none; }
.content .md-table tbody tr:last-child td { border-bottom: none; }
.content .md-table thead th { background: var(--bg-3); font-weight: 700; font-family: var(--font-display); white-space: nowrap; }
.content .md-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--text) 3%, transparent); }
.content .md-table td .tok-n, .content .md-table code { white-space: nowrap; }
.content .md-table .ta-c { text-align: center; }
.content .md-table .ta-r { text-align: right; }
.content .md-table .ta-l { text-align: left; }

/* ---------- Hands-free voice mode ---------- */
.voice-overlay { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 90% at 50% 16%, color-mix(in srgb, var(--accent) 13%, var(--bg)) 0%, var(--bg) 62%);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.voice-exit { position: absolute; top: calc(16px + env(safe-area-inset-top)); right: 18px; width: 42px; height: 42px; border-radius: 50%;
  background: var(--bg-3); color: var(--muted); font-size: 17px; display: inline-flex; align-items: center; justify-content: center; }
.voice-exit:hover { color: var(--text); background: var(--bg-4); }
.voice-stage { display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; padding: 24px; }
.voice-orb { position: relative; width: 210px; height: 210px; border-radius: 50%; background: none; cursor: pointer; display: grid; place-items: center; --amp: 0; }
.orb-core { position: relative; z-index: 2; width: 142px; height: 142px; border-radius: 50%; display: grid; place-items: center; color: #05231b;
  background: var(--grad); box-shadow: 0 20px 60px -12px var(--glow), inset 0 0 30px rgba(255,255,255,.16);
  transform: scale(calc(1 + var(--amp) * 0.12)); transition: transform .08s ease-out, background .2s, color .2s; }
.orb-core .ic { width: 46px; height: 46px; stroke-width: 1.8; }
.orb-glow { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 45%, transparent), transparent 70%);
  transform: scale(calc(1 + var(--amp) * 0.55)); opacity: calc(.3 + var(--amp) * .55); transition: transform .1s, opacity .1s; }
.voice-overlay[data-state="listening"] .orb-core { animation: orbBreathe 3s ease-in-out infinite; }
.voice-overlay[data-state="thinking"] .orb-core { background: var(--bg-3); color: var(--accent); box-shadow: 0 16px 50px -16px var(--glow); animation: orbThink 1.1s ease-in-out infinite; }
.voice-overlay[data-state="thinking"] .orb-glow { opacity: .2; }
.voice-overlay[data-state="speaking"] .orb-glow { animation: orbSpeak 1.5s ease-in-out infinite; }
@keyframes orbBreathe { 0%,100% { box-shadow: 0 20px 60px -14px var(--glow); } 50% { box-shadow: 0 22px 86px -4px var(--glow); } }
@keyframes orbThink { 0%,100% { opacity: .6; } 50% { opacity: 1; } }
@keyframes orbSpeak { 0%,100% { opacity: .35; transform: scale(1); } 50% { opacity: .9; transform: scale(1.28); } }
.voice-status { font-family: var(--font-display); font-size: 22px; font-weight: 600; letter-spacing: -.01em; min-height: 28px; }
.voice-hint { color: var(--muted); font-size: 13.5px; max-width: 320px; line-height: 1.5; }
.voice-voices { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.vv-label { color: var(--muted); font-size: 12px; margin-right: 2px; }
.vpick { padding: 7px 14px; border-radius: 20px; background: var(--bg-3); border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 13px; cursor: pointer; }
.vpick:hover { color: var(--text); }
.vpick.on { color: var(--text); background: color-mix(in srgb, var(--accent) 18%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }

/* ============================================================
   Accounts (accounts.krattlabs.eu) + Admin (admin.krattlabs.eu)
   ============================================================ */
.acct-app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.acct-app .appbar { flex-shrink: 0; }
.acct-main { flex: 1; min-height: 0; overflow-y: auto; padding: 26px 20px 60px; }
.acct-main > * { max-width: 720px; margin: 0 auto 18px; }
.card { background: color-mix(in srgb, var(--bg-2) 92%, transparent); border: 1px solid var(--border); border-radius: 16px; padding: 22px 22px 24px; }
.card h2 { margin: 0 0 14px; font-size: 18px; }
.card h3.sub { margin: 4px 0 12px; font-size: 14px; color: var(--muted); font-weight: 600; }
.card p.muted { margin: -6px 0 14px; }
.small { font-size: 12.5px; }

.btn-primary { background: var(--grad); color: #fff; font-weight: 600; border-radius: 11px; padding: 10px 16px; display: inline-flex; align-items: center; gap: 8px; box-shadow: 0 6px 18px -6px var(--glow); }
.btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn-ghost { background: var(--bg-3); border: 1px solid var(--border); border-radius: 11px; padding: 9px 14px; color: var(--text); font-weight: 600; display: inline-flex; align-items: center; gap: 7px; }
.btn-ghost:hover { border-color: var(--border-2); }
.btn-ghost.danger-text, .btn-danger { color: var(--danger); }
.btn-danger { background: color-mix(in srgb, var(--danger) 13%, transparent); border: 1px solid color-mix(in srgb, var(--danger) 32%, transparent); border-radius: 11px; padding: 9px 14px; font-weight: 600; }

.field-inline { display: flex; gap: 8px; }
.field-inline input { flex: 1; }
.field-row { display: flex; gap: 14px; margin: 14px 0; flex-wrap: wrap; }
.field { flex: 1; min-width: 160px; }
.lbl { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field select, .acct-main select { width: 100%; color: var(--text); background: var(--bg-3); border: 1px solid var(--border-2); border-radius: 11px; padding: 11px 12px; cursor: pointer; }
.toggle { display: inline-flex; align-items: center; gap: 9px; margin-top: 6px; font-size: 14px; cursor: pointer; }
.toggle input { width: auto; }
.actions { margin-top: 16px; }
.acct-main textarea { resize: vertical; }

.profile-row { display: flex; align-items: center; gap: 16px; }
.big-avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--grad); color: #fff; font-family: var(--font-display); font-weight: 800; font-size: 24px; }
.p-name { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.p-sub { margin-top: 4px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.email-state { margin-top: 12px; display: flex; align-items: center; gap: 8px; }
.email-state .ok { color: var(--accent); font-weight: 600; }
.email-state .warn { color: var(--pin, #f5b942); }
.banner { padding: 12px 16px; border-radius: 12px; font-weight: 600; }
.banner.ok { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--text); border: 1px solid color-mix(in srgb, var(--accent) 36%, transparent); }
.banner.warn { background: color-mix(in srgb, var(--pin, #f5b942) 16%, transparent); color: var(--text); border: 1px solid color-mix(in srgb, var(--pin, #f5b942) 36%, transparent); }

.sec-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.sep { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.sec-rows { display: flex; flex-direction: column; gap: 14px; }
.sec-line { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.sec-line > div { display: flex; flex-direction: column; gap: 2px; }
.sec-line.danger b { color: var(--danger); }

/* Admin */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-tile { background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px; padding: 16px; text-align: center; }
.stat-tile b { display: block; font-family: var(--font-mono); font-size: 24px; }
.stat-tile span { color: var(--muted); font-size: 12.5px; }
.model-table { display: flex; flex-direction: column; gap: 2px; }
.model-row { display: grid; grid-template-columns: 1fr auto auto; gap: 14px; align-items: center; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; }
.model-row:nth-child(odd) { background: color-mix(in srgb, var(--text) 3%, transparent); }
.mono { font-family: var(--font-mono); }
.admin-users { display: flex; flex-direction: column; gap: 8px; }
.auser { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; background: var(--bg-3); border: 1px solid var(--border); border-radius: 12px; flex-wrap: wrap; }
.au-name { font-weight: 600; }
.au-name .tag, .tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); padding: 1px 6px; border-radius: 10px; margin-left: 7px; }
.au-meta { margin-top: 3px; font-size: 12.5px; }
.au-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.plan-select { color: var(--text); background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 9px; padding: 6px 8px; }
.add-user { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.add-user input { width: auto; flex: 1; min-width: 130px; }
.add-user select { width: auto; }
.denied { display: grid; place-items: center; height: 100vh; text-align: center; }
@media (max-width: 560px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } .sec-line { flex-direction: column; align-items: flex-start; } }

/* Kratt-styled confirm / prompt (replaces native browser dialogs) */
.kmodal { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.5); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.kmodal-card { width: 100%; max-width: 380px; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 18px; padding: 24px; box-shadow: var(--shadow, 0 20px 55px -20px rgba(0,0,0,.7)); }
.kmodal-card h3 { margin: 0 0 8px; font-family: var(--font-display); font-size: 19px; }
.kmodal-msg { color: var(--muted); margin: 0 0 16px; line-height: 1.5; }
.kmodal-input { margin-bottom: 16px; }
.kmodal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Reminders card (accounts) */
.rem-add { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 14px; }
.rem-add #rem-text { flex: 1 1 220px; }
.rem-add input { padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--bg-2); color: var(--text); font: inherit; }
.rem-list { display: flex; flex-direction: column; gap: 8px; }
.rem-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-2); }
.rem-when { font-family: var(--mono); font-size: 12.5px; color: var(--accent); white-space: nowrap; }
.rem-txt { flex: 1; min-width: 0; }
.rem-del { margin-left: auto; background: transparent; border: 1px solid var(--border-2); color: var(--muted); border-radius: 8px; width: 28px; height: 28px; cursor: pointer; flex-shrink: 0; }
.rem-del:hover { color: #e5484d; border-color: #e5484d; }
