/* voicekit Studio — visual language after maitflow.com: Inter, indigo→violet→pink gradient,
   soft lavender surfaces, generous radii, pill badges. */
:root {
  --c-primary: #667eea;
  --c-secondary: #764ba2;
  --c-accent: #f093fb;
  --c-dark: #0f0f23;
  --c-ink: #1a1a2e;
  --c-text: #374151;
  --c-text-light: #6b7280;
  --c-bg-soft: #f8f9ff;
  --c-border: #e5e7f0;
  --c-green: #10b981;
  --c-amber: #f59e0b;
  --c-red: #f43f5e;
  --gradient: linear-gradient(135deg, #667eea 0%, #764ba2 55%, #f093fb 100%);
  --gradient-subtle: linear-gradient(135deg, rgba(102,126,234,.08) 0%, rgba(118,75,162,.06) 55%, rgba(240,147,251,.04) 100%);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow-md: 0 4px 20px rgba(102,126,234,.12);
  --shadow-lg: 0 12px 48px rgba(102,126,234,.18);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--c-ink);
  background: #fff;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -.02em; }
.muted { color: var(--c-text-light); margin: 2px 0 0; }
.small { font-size: .85rem; }

.bg-glow {
  position: fixed; inset: 0 0 auto 0; height: 560px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(600px 300px at 15% 0%, rgba(102,126,234,.16), transparent 70%),
    radial-gradient(500px 280px at 85% 10%, rgba(240,147,251,.14), transparent 70%);
}

.text-gradient {
  background: var(--gradient);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Nav ---------------------------------------------------------------------------------------- */
.nav {
  position: sticky; top: 0; z-index: 10;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(102,126,234,.08);
}
.nav-inner { max-width: 880px; margin: 0 auto; padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; }
.nav-brand { font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }

.badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 16px; border-radius: 999px;
  font-size: .8rem; font-weight: 600;
  background: var(--gradient-subtle); color: var(--c-primary);
  border: 1px solid rgba(102,126,234,.15);
}
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--c-green); box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.dot-red { background: var(--c-red); }
.pulse { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* Hero --------------------------------------------------------------------------------------- */
.hero { max-width: 880px; margin: 0 auto; padding: 56px 24px 28px; text-align: center; }
.hero h1 { font-size: clamp(2rem, 4.2vw, 3rem); font-weight: 900; line-height: 1.1; letter-spacing: -.03em; margin: 18px 0 16px; }
.hero-sub { max-width: 600px; margin: 0 auto; color: var(--c-text); font-size: 1.08rem; }

/* Cards / steps ------------------------------------------------------------------------------ */
.steps { max-width: 880px; margin: 0 auto; padding: 12px 24px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }
.card {
  background: #fff; border: 1px solid var(--c-border); border-radius: 20px;
  padding: 28px; box-shadow: var(--shadow-md);
  transition: opacity .25s, transform .25s, box-shadow .25s;
}
.card.locked { opacity: .45; pointer-events: none; box-shadow: var(--shadow-sm); }
.card.active { box-shadow: var(--shadow-lg); }
.card-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 20px; }
.card-head h2 { font-size: 1.25rem; font-weight: 800; }
.card-head > div { flex: 1; }
.step-num {
  flex: none; width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--gradient); color: #fff; font-weight: 800;
  box-shadow: 0 4px 14px rgba(102,126,234,.35);
}
.elapsed { font-variant-numeric: tabular-nums; color: var(--c-text-light); font-weight: 600; }

/* Form --------------------------------------------------------------------------------------- */
.field-label { display: block; font-weight: 700; font-size: .9rem; margin: 18px 0 8px; color: var(--c-ink); }
.card-head + .field-label { margin-top: 0; }
.field-hint { font-size: .82rem; color: var(--c-text-light); margin: 6px 0 0; }
.field-hint.bad { color: var(--c-red); }
.input {
  width: 100%; padding: 12px 14px; font: inherit; color: var(--c-ink);
  background: var(--c-bg-soft); border: 1.5px solid var(--c-border); border-radius: 12px;
  outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.input:focus { border-color: var(--c-primary); background: #fff; box-shadow: 0 0 0 4px rgba(102,126,234,.12); }
.select { width: auto; flex: 1; min-width: 0; cursor: pointer; }

.chip-group, .chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 999px; font: inherit; font-weight: 600; font-size: .92rem;
  background: #fff; color: var(--c-text); border: 1.5px solid var(--c-border); cursor: pointer;
  transition: border-color .2s, background .2s, color .2s;
}
.chip:hover { border-color: var(--c-primary); }
.chip[aria-checked="true"] { background: var(--gradient-subtle); border-color: var(--c-primary); color: var(--c-primary); }
.chip .code-tag { font-size: .72rem; font-weight: 800; padding: 1px 6px; border-radius: 6px; background: var(--c-bg-soft); color: var(--c-secondary); }
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600; border: 1px solid var(--c-border); background: var(--c-bg-soft); color: var(--c-text); }
.tag.good { color: #059669; background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.25); }
.tag.warn { color: #b45309; background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.3); }
.tag.bad  { color: #be123c; background: rgba(244,63,94,.07); border-color: rgba(244,63,94,.3); }

.mic-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.meter { height: 8px; margin-top: 12px; border-radius: 999px; background: var(--c-bg-soft); border: 1px solid var(--c-border); overflow: hidden; }
.meter-fill { height: 100%; width: 0; background: linear-gradient(90deg, #10b981, #34d399 60%, #f59e0b 85%, #f43f5e); transition: width .06s linear; }

/* Buttons ------------------------------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 24px; border-radius: 14px; font: inherit; font-weight: 700; cursor: pointer;
  transition: filter .2s, transform .15s, box-shadow .2s, border-color .2s, color .2s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { color: #fff; background: var(--gradient); border: none; box-shadow: 0 4px 20px rgba(102,126,234,.3); padding: 14px 30px; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.06); box-shadow: 0 8px 28px rgba(102,126,234,.4); transform: translateY(-1px); }
.btn-ghost { background: #fff; color: var(--c-ink); border: 1.5px solid var(--c-border); }
.btn-ghost:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn-ghost.on { border-color: var(--c-green); color: #059669; }
.icon { width: 18px; height: 18px; fill: currentColor; flex: none; }
.link-btn { background: none; border: none; padding: 0; font: inherit; font-weight: 600; font-size: .85rem; color: var(--c-primary); cursor: pointer; text-decoration: none; }
.link-btn:hover { text-decoration: underline; }
.link-btn:disabled { opacity: .4; cursor: not-allowed; text-decoration: none; }
.actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 20px; flex-wrap: wrap; }

/* Teleprompter ------------------------------------------------------------------------------- */
.prompter {
  position: relative; overflow: hidden;
  background: var(--c-dark); color: #fff; border-radius: var(--radius);
  padding: 22px 28px 30px;
  box-shadow: 0 24px 64px rgba(15,15,35,.14);
}
.prompter::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(500px 200px at 100% 0%, rgba(240,147,251,.18), transparent 70%),
              radial-gradient(500px 200px at 0% 100%, rgba(102,126,234,.22), transparent 70%);
}
.prompter-top { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: .8rem; color: rgba(255,255,255,.55); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.prompter-top .link-btn { color: #c4b5fd; text-transform: none; letter-spacing: 0; }
.prompter-text { position: relative; margin: 18px 0 0; font-size: clamp(1.3rem, 2.6vw, 1.75rem); line-height: 1.6; font-weight: 600; letter-spacing: -.01em; transition: opacity .3s; }
.prompter.dim .prompter-text { opacity: .35; }
.rec-pill { display: inline-flex; align-items: center; gap: 6px; color: #fda4af; }
.countdown {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 6rem; font-weight: 900; background: rgba(15,15,35,.55);
  backdrop-filter: blur(2px);
}
.countdown span { background: var(--gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: pop .9s ease-out; }
@keyframes pop { from { transform: scale(1.6); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); } }

.record-bar { display: flex; align-items: center; gap: 22px; margin-top: 22px; }
.rec-btn {
  flex: none; width: 72px; height: 72px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--gradient); display: grid; place-items: center;
  box-shadow: 0 8px 28px rgba(118,75,162,.4); transition: transform .15s, box-shadow .2s;
}
.rec-btn:hover:not(:disabled) { transform: scale(1.05); }
.rec-btn:disabled { opacity: .5; cursor: not-allowed; }
.rec-icon { width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: border-radius .2s, width .2s, height .2s; }
.rec-btn.recording { background: var(--c-red); box-shadow: 0 0 0 8px rgba(244,63,94,.15), 0 8px 28px rgba(244,63,94,.35); }
.rec-btn.recording .rec-icon { width: 22px; height: 22px; border-radius: 5px; }
.timer-wrap { flex: 1; }
.timer-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.timer { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
/* 0-30 s timeline: 0-6 short, 6-15 ideal, 15-30 long */
.timeline { position: relative; display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--c-bg-soft); }
.zone { height: 100%; }
.zone-short { width: 20%; background: rgba(107,114,128,.12); }
.zone-ideal { width: 30%; background: rgba(16,185,129,.18); }
.zone-long  { width: 50%; background: rgba(245,158,11,.14); }
.timeline-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--gradient); border-radius: 999px; opacity: .9; }

/* Review ------------------------------------------------------------------------------------- */
audio { width: 100%; margin-bottom: 14px; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 16px; font-weight: 600; font-size: .92rem; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--c-primary); }
.form-error { margin: 14px 0 0; padding: 12px 14px; border-radius: 12px; background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; font-size: .9rem; }

/* Training status ---------------------------------------------------------------------------- */
.stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.stage { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 12px; color: var(--c-text-light); font-weight: 600; transition: background .2s, color .2s; }
.stage .s-icon { width: 24px; height: 24px; flex: none; border-radius: 50%; border: 2px solid var(--c-border); display: grid; place-items: center; font-size: .75rem; color: #fff; }
.stage .s-time { margin-left: auto; font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.stage.active { background: var(--gradient-subtle); color: var(--c-ink); }
.stage.active .s-icon { border-color: rgba(102,126,234,.25); border-top-color: var(--c-primary); animation: spin .8s linear infinite; }
.stage.done { color: var(--c-ink); }
.stage.done .s-icon { border: none; background: linear-gradient(135deg, #10b981, #059669); }
.stage.done .s-icon::after { content: "✓"; }
.stage.failed { color: #be123c; background: #fef2f2; }
.stage.failed .s-icon { border: none; background: var(--c-red); }
.stage.failed .s-icon::after { content: "✕"; }
@keyframes spin { to { transform: rotate(360deg); } }

.result { margin-top: 18px; padding: 18px 20px; border-radius: var(--radius); }
.result p { margin: 6px 0; }
.result-title { font-weight: 800; font-size: 1.05rem; }
.result.success { background: linear-gradient(135deg, rgba(52,211,153,.08), rgba(16,185,129,.04)); border: 1px solid rgba(16,185,129,.25); }
.result.success .result-title { color: #059669; }
.result.success .btn { margin-top: 14px; }
.result.failure { background: #fef2f2; border: 1px solid #fecaca; }
.result.failure .result-title { color: #b91c1c; }
.code { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--c-dark); color: #e5e7f0; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: .82rem; overflow-x: auto; }
.code code { flex: 1; white-space: pre; }
.code .link-btn { color: #c4b5fd; flex: none; }

.log-wrap { margin-top: 16px; }
.log-wrap summary { cursor: pointer; color: var(--c-text-light); font-size: .85rem; font-weight: 600; }
.log { margin: 10px 0 0; max-height: 240px; overflow: auto; padding: 14px; border-radius: 12px; background: var(--c-bg-soft); border: 1px solid var(--c-border); font-size: .78rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; color: var(--c-text); }

.voices h3 { font-size: 1rem; margin: 8px 0 12px; }
.footer { text-align: center; padding: 10px 24px 40px; color: var(--c-text-light); font-size: .82rem; }

@media (max-width: 600px) {
  .card { padding: 20px; }
  .record-bar { gap: 14px; }
  .rec-btn { width: 60px; height: 60px; }
}

/* Tabs (nav) --------------------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--c-bg-soft); border: 1px solid var(--c-border); }
.tab { padding: 6px 16px; border-radius: 999px; font-weight: 700; font-size: .88rem; color: var(--c-text-light); text-decoration: none; transition: background .2s, color .2s; }
.tab:hover { color: var(--c-primary); }
.tab.active { background: #fff; color: var(--c-primary); box-shadow: var(--shadow-sm); }
@media (max-width: 700px) { .nav-badge { display: none; } }

/* Speak view --------------------------------------------------------------------------------- */
.hero-compact { padding: 44px 24px 18px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-2 .field-label { margin-top: 0; }
@media (max-width: 600px) { .row-2 { grid-template-columns: 1fr; } }
.select-full { cursor: pointer; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; margin-top: 18px; }
.label-row .field-label { margin: 0 0 8px; }
.textarea { resize: vertical; min-height: 150px; line-height: 1.6; font-size: 1.02rem; }
.textarea-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 6px; }
#sp-count.over { color: var(--c-red); font-weight: 700; }
.actions { align-items: center; }
.actions.start { justify-content: flex-start; margin-top: 4px; }
.kbd-hint { margin-right: auto; }
.btn-sm { padding: 8px 14px; font-size: .88rem; border-radius: 12px; text-decoration: none; }

.progress-box { margin-top: 18px; padding: 14px 16px; border-radius: 14px; background: var(--gradient-subtle); border: 1px solid rgba(102,126,234,.15); }
.progress-head { display: flex; justify-content: space-between; font-weight: 700; font-size: .92rem; margin-bottom: 10px; }
.progress { position: relative; height: 8px; border-radius: 999px; background: rgba(102,126,234,.12); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 999px; background: var(--gradient); transition: width .5s ease; position: relative; overflow: hidden; }
.progress-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.55), transparent); animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

.player-card { border-color: rgba(102,126,234,.25); }
.player-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.player-title { font-weight: 800; font-size: 1.1rem; }
.player-text { margin: 4px 0 0; color: var(--c-text); white-space: pre-wrap; max-height: 9.6em; overflow: auto; }

.history h3 { font-size: 1rem; margin: 8px 0 12px; }
.history-item { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--c-border); background: #fff; margin-bottom: 8px; transition: border-color .2s, box-shadow .2s; }
.history-item:hover { border-color: rgba(102,126,234,.35); box-shadow: var(--shadow-md); }
.history-body { flex: 1; min-width: 0; }
.history-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.play-btn { flex: none; width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer; display: grid; place-items: center; color: #fff; background: var(--gradient); box-shadow: 0 4px 14px rgba(102,126,234,.3); }
.play-btn .icon { width: 16px; height: 16px; margin-left: 2px; }
.warn-text { color: #b45309; font-weight: 600; }

/* AI writer chat ----------------------------------------------------------------------------- */
.card-head h2 .muted { font-weight: 500; }
.llm-pill { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; font-size: .78rem; font-weight: 700; color: var(--c-text-light); background: var(--c-bg-soft); border: 1px solid var(--c-border); cursor: default; }
.llm-pill .dot { background: #cbd5e1; }
.llm-pill.ok .dot { background: var(--c-green); box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.llm-pill.bad .dot { background: var(--c-red); }
.chat-log { max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 12px; }
.chat-empty .chip-row { gap: 8px; }
.chip-sm { padding: 7px 14px; font-size: .84rem; font-weight: 500; text-align: left; border-radius: 14px; }
.bubble { max-width: 88%; padding: 12px 16px; border-radius: 18px; line-height: 1.6; }
.bubble-text { white-space: pre-wrap; word-wrap: break-word; }
.bubble.user { align-self: flex-end; background: var(--gradient); color: #fff; border-bottom-right-radius: 6px; box-shadow: 0 4px 14px rgba(102,126,234,.25); }
.bubble.assistant { align-self: flex-start; background: var(--c-bg-soft); border: 1px solid var(--c-border); border-bottom-left-radius: 6px; }
.bubble.streaming .bubble-text:empty::before { content: "Writing"; color: var(--c-text-light); }
.bubble.streaming .bubble-text::after { content: "▍"; color: var(--c-primary); animation: pulse 1s steps(2) infinite; margin-left: 1px; }
.bubble-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--c-border); }
.use-btn.used { color: #059669; }
.chat-input-row { display: flex; gap: 10px; align-items: flex-end; margin-top: 4px; }
.chat-input { resize: none; min-height: 48px; max-height: 180px; line-height: 1.5; }
.chat-send { flex: none; width: 48px; height: 48px; padding: 0; border-radius: 14px; }
.chat-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 8px; }

.dl-group { display: flex; gap: 8px; flex: none; }
.dl-links { display: flex; gap: 12px; flex: none; }
#sp-reuse { margin-top: 8px; }

/* Login & scopes ----------------------------------------------------------------------------- */
.login-page { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(700px 360px at 20% 0%, rgba(102,126,234,.18), transparent 70%),
              radial-gradient(600px 320px at 85% 100%, rgba(240,147,251,.16), transparent 70%), var(--c-bg-soft); }
body.auth-pending > :not(.login-page):not(script) { display: none !important; }
.login .field-label { margin-top: 4px; }
.login #login-password-fields, .login #login-key-fields { display: grid; gap: 6px; }
.login #login-password-fields[hidden], .login #login-key-fields[hidden] { display: none; }
.login { width: 100%; max-width: 420px; display: grid; gap: 12px; box-shadow: var(--shadow-lg); }
.login h2 { font-size: 1.5rem; font-weight: 800; margin-top: 8px; }
.login p { margin: 0; }
.login code { font-size: .85em; padding: 1px 6px; border-radius: 6px; background: var(--c-bg-soft); border: 1px solid var(--c-border); }
.login a { color: var(--c-primary); }
.account { display: inline-flex; align-items: center; gap: 12px; font-size: .85rem; font-weight: 600; }
.account-name { padding: 5px 12px; border-radius: 999px; background: var(--gradient-subtle); color: var(--c-primary); border: 1px solid rgba(102,126,234,.15); }
.account:not([hidden]) ~ .nav-badge, .nav-inner:has(.account:not([hidden])) #local-badge { display: none; }
.no-tts-note { display: none; }
body.no-tts .tts-only { display: none !important; }
body.no-tts .no-tts-note { display: block; margin-top: 14px; }

/* API keys view -------------------------------------------------------------------------------- */
.notice { margin: 0; padding: 14px 18px; border-radius: 14px; background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.3); color: #92400e; font-size: .9rem; }
.notice code, .new-key code:not(#new-key-value), .scope-option code { font-size: .85em; padding: 1px 6px; border-radius: 6px; background: var(--c-bg-soft); border: 1px solid var(--c-border); }
.scope-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.scope-option { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1.5px solid var(--c-border); border-radius: 14px; cursor: pointer; transition: border-color .2s, background .2s; }
.scope-option:has(input:checked) { border-color: var(--c-primary); background: var(--gradient-subtle); }
.scope-option.danger:has(input:checked) { border-color: var(--c-amber); background: rgba(245,158,11,.06); }
.scope-option input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--c-primary); flex: none; }
.new-key { margin-top: 18px; padding: 18px 20px; border-radius: var(--radius); background: linear-gradient(135deg, rgba(52,211,153,.08), rgba(16,185,129,.04)); border: 1px solid rgba(16,185,129,.25); display: grid; gap: 10px; }
.new-key .result-title { color: #059669; }
.new-key p { margin: 0; }
.keys-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.keys-table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text-light); padding: 8px 10px; border-bottom: 1.5px solid var(--c-border); }
.keys-table td { padding: 12px 10px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.keys-table td:last-child { text-align: right; }
.keys-table code { font-size: .85em; }

/* Wizard (Speak / Record voice): one step at a time ------------------------------------------- */
.wz-hidden { display: none !important; }
.wizard .card.locked { opacity: 1; pointer-events: auto; }  /* the wizard itself decides what can be entered */
.stepper { list-style: none; margin: 0 0 4px; padding: 0; display: flex; align-items: flex-start; }
.wz-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative;
  color: var(--c-text-light); font-size: .85rem; font-weight: 600; text-align: center; }
.wz-item + .wz-item::before { content: ""; position: absolute; top: 17px; right: 50%; width: 100%; height: 2px;
  background: var(--c-border); z-index: 0; }
.wz-item.done + .wz-item::before, .wz-item.done + .wz-item.current::before { background: linear-gradient(90deg, #10b981, var(--c-primary)); }
.wz-dot { position: relative; z-index: 1; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 800; background: #fff; border: 2px solid var(--c-border); color: var(--c-text-light); transition: all .2s; }
.wz-item.current { color: var(--c-ink); }
.wz-item.current .wz-dot { border: none; color: #fff; background: var(--gradient); box-shadow: 0 4px 14px rgba(102,126,234,.4); }
.wz-item.done .wz-dot { border: none; color: #fff; background: linear-gradient(135deg, #10b981, #059669); }
.wz-item.clickable { cursor: pointer; }
.wz-item.clickable:hover .wz-dot { border-color: var(--c-primary); transform: scale(1.06); }
.wz-item.clickable:hover { color: var(--c-primary); }
.wizard-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wizard-nav .wz-count { flex: 1; text-align: center; }
.wizard-nav .wz-back[hidden] + .wz-count { text-align: left; }
@media (max-width: 600px) {
  .wz-item:not(.current) .wz-label { display: none; }
}

/* Logs view ------------------------------------------------------------------------------------ */
.steps.logs-main { max-width: 1180px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.stat-n { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.stat-l { font-size: .8rem; font-weight: 600; color: var(--c-text-light); }
.stat-l span { font-weight: 500; }
.stat.warn .stat-n { color: #b45309; }
.log-filters { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; margin-bottom: 12px; }
.log-filters .input { flex: 1; min-width: 220px; }
.log-filters .check { margin-top: 0; }
.log-table-wrap { overflow-x: auto; }
.log-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.log-table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--c-text-light); padding: 8px 10px; border-bottom: 1.5px solid var(--c-border); white-space: nowrap; }
.log-table td { padding: 9px 10px; border-bottom: 1px solid var(--c-border); vertical-align: top; overflow-wrap: anywhere; }
.log-table code { font-size: .82em; }
.log-table .nowrap { white-space: nowrap; }
.log-table tr.lvl-warn { background: rgba(245,158,11,.04); }
.log-table tr.lvl-error { background: rgba(244,63,94,.05); }
.log-table tr.fresh { animation: fresh 2s ease-out; }
@keyframes fresh { from { background: rgba(102,126,234,.16); } }
.ev { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; background: var(--gradient-subtle); color: var(--c-primary); border: 1px solid rgba(102,126,234,.18); }
.ev-warn { background: rgba(245,158,11,.1); color: #b45309; border-color: rgba(245,158,11,.3); }
.ev-error { background: rgba(244,63,94,.08); color: #be123c; border-color: rgba(244,63,94,.3); }

/* Small screens */
#keys-list { overflow-x: auto; }
.keys-table { min-width: 600px; }
@media (max-width: 700px) {
  .nav-inner { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .tabs { order: 3; width: 100%; overflow-x: auto; border-radius: 14px; }
  .tab { white-space: nowrap; flex: none; padding: 8px 12px; }
  .account { margin-left: auto; min-width: 0; }
  .account-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .steps { padding: 12px 16px 32px; }
  .hero { padding: 32px 16px 18px; }
  .login-page { overflow-y: auto; padding: 16px; }
  .scope-grid { grid-template-columns: minmax(0, 1fr); }
  .input { font-size: 16px; }
  .player-head { flex-wrap: wrap; }
  .log-filters .input { min-width: 0; flex-basis: 100%; }
}

/* System health */
.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; }
.health-item { min-width: 0; padding: 14px; border: 1px solid var(--c-border); border-radius: 14px; background: var(--c-bg-soft); overflow-wrap: anywhere; }
.health-heading { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.health-state { font-size: .75rem; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.health-state.good { color: #047857; background: #d1fae5; }
.health-state.warn { color: #92400e; background: #fef3c7; }
.model-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--c-border); overflow-wrap: anywhere; }
.model-row > div:first-child { min-width: 0; }
.model-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
@media (max-width: 600px) { .model-row { align-items: flex-start; flex-direction: column; } }
.language-control { display: grid; gap: 4px; font-size: .78rem; font-weight: 600; color: var(--c-text-light); }
.nav-language select { max-width: 110px; padding: 7px 8px; border: 1px solid var(--c-border); border-radius: 10px; background: #fff; font: inherit; color: var(--c-ink); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
@media (max-width: 700px) { .nav-language { margin-left: auto; } .account { margin-left: 0; } }

/* Ollama model operation */
.model-progress {
  position: relative; overflow: hidden; isolation: isolate; min-width: 0;
  padding: 24px; border: 1px solid rgba(151, 154, 255, .3); border-radius: 22px;
  color: #f7f5ff; background: #171832;
  box-shadow: 0 20px 50px rgba(68, 55, 143, .22), inset 0 1px rgba(255, 255, 255, .08);
}
.model-progress::before, .model-progress::after { content: ""; position: absolute; z-index: -1; pointer-events: none; border-radius: 50%; filter: blur(4px); }
.model-progress::before { width: 320px; height: 260px; right: -50px; top: -140px; background: radial-gradient(circle, rgba(191, 102, 255, .3), transparent 70%); }
.model-progress::after { width: 280px; height: 220px; left: -100px; bottom: -150px; background: radial-gradient(circle, rgba(46, 195, 255, .23), transparent 70%); }
.model-progress-top { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.model-progress-orb { flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 16px; background: linear-gradient(135deg, #9c8aff, #f089d7); box-shadow: 0 0 28px rgba(178, 120, 255, .55); }
.model-progress-orb span { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; }
.is-running .model-progress-orb span { animation: spin 1s linear infinite; }
.is-done .model-progress-orb { background: linear-gradient(135deg, #19bd9b, #68e9b6); box-shadow: 0 0 28px rgba(50, 220, 171, .4); }
.is-done .model-progress-orb span { border: 0; width: auto; height: auto; }
.is-done .model-progress-orb span::after { content: "✓"; font-size: 1.3rem; font-weight: 800; }
.is-error .model-progress-orb { background: linear-gradient(135deg, #e86b82, #b93a61); }
.is-error .model-progress-orb span { border: 0; width: auto; height: auto; }
.is-error .model-progress-orb span::after { content: "!"; font-size: 1.3rem; font-weight: 800; }
.model-progress-title { flex: 1; min-width: 0; }
.model-progress-title h2 { font-size: 1.15rem; overflow-wrap: anywhere; }
.model-progress-eyebrow { color: #c4b7ff; font-size: .73rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.model-progress-percent { font-size: 1.45rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.model-progress progress { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 11px; border: 0; border-radius: 999px; overflow: hidden; background: rgba(255,255,255,.12); }
.model-progress progress::-webkit-progress-bar { border-radius: 999px; background: rgba(255,255,255,.12); }
.model-progress progress::-webkit-progress-value { border-radius: 999px; background: linear-gradient(90deg, #6cb8ff, #a987ff, #f18bda); box-shadow: 0 0 15px #a987ff; transition: width .45s ease; }
.model-progress progress::-moz-progress-bar { border-radius: 999px; background: linear-gradient(90deg, #6cb8ff, #a987ff, #f18bda); }
.model-progress progress:indeterminate { background: linear-gradient(100deg, rgba(255,255,255,.08) 20%, #a987ff 50%, rgba(255,255,255,.08) 80%); background-size: 220% 100%; animation: model-glow 1.8s linear infinite; }
.model-progress progress:indeterminate::-webkit-progress-bar { background: transparent; }
.model-progress progress:indeterminate::-moz-progress-bar { background: transparent; }
@keyframes model-glow { to { background-position: -220% 0; } }
.model-progress-meta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; margin-top: 12px; font-size: .83rem; color: #ddd8f7; overflow-wrap: anywhere; }
#model-progress-detail { color: #aaa7c6; font-variant-numeric: tabular-nums; }
.model-progress-steps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.model-progress-steps span { padding: 4px 10px; border: 1px solid rgba(255,255,255,.11); border-radius: 999px; color: #aba8c5; font-size: .72rem; font-weight: 700; }
.model-progress-steps .current { color: #fff; border-color: rgba(190,167,255,.65); background: rgba(160,128,255,.2); }
.model-progress-steps .finished { color: #a1f1d7; border-color: rgba(105,222,185,.35); }
@media (max-width: 600px) { .model-progress { padding: 20px; } .model-progress-meta { flex-direction: column; } }
@media (prefers-reduced-motion: reduce) { .model-progress * { animation: none !important; transition: none !important; } }
.model-chat-log { display: flex; flex-direction: column; gap: 10px; max-height: 360px; overflow-y: auto; margin-top: 16px; }
.model-chat-bubble { max-width: 90%; padding: 12px 15px; border-radius: 16px; background: var(--c-bg-soft); border: 1px solid var(--c-border); white-space: pre-wrap; overflow-wrap: anywhere; }
.model-chat-bubble.user { align-self: flex-end; background: var(--gradient); color: white; border: 0; }
.model-chat-bubble.assistant { align-self: flex-start; }
.model-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr)); gap: 10px; margin-top: 20px; }
.model-metric { padding: 12px; border-radius: 13px; background: var(--gradient-subtle); border: 1px solid rgba(102,126,234,.16); display: grid; gap: 3px; }
.model-metric span { color: var(--c-text-light); font-size: .75rem; font-weight: 600; }
.model-metric strong { color: var(--c-primary); font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.model-custom-row { display: flex; gap: 10px; }
.model-custom-row .input { min-width: 0; flex: 1; }
@media (max-width: 600px) { .model-custom-row { flex-direction: column; } }

.model-chat-limit { max-width: 220px; }
.model-chat-truncated { margin-top: 16px; }
.model-chat-content { min-width: 0; }
.model-chat-bubble.assistant { max-width: 100%; min-width: 0; }
.model-chat-code { max-width: 100%; margin: 10px 0; overflow: hidden; border-radius: 12px; background: var(--c-dark); color: #e5e7f0; text-align: left; }
.model-chat-code-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 12px; background: rgba(255,255,255,.07); color: #c4b5fd; font: 600 .78rem ui-monospace, monospace; }
.model-chat-code pre { margin: 0; padding: 14px; overflow-x: auto; white-space: pre; font: .82rem/1.5 ui-monospace, monospace; }
.model-chat-copy { padding: 5px 9px; border: 1px solid var(--c-border); border-radius: 8px; background: #fff; color: var(--c-primary); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; }
.model-chat-bubble > .model-chat-copy { margin-top: 10px; }
.model-chat-code-head .model-chat-copy { background: rgba(255,255,255,.08); color: #ddd6fe; border-color: rgba(255,255,255,.17); }
.model-chat-truncated .link-btn { margin-left: 6px; }

/* Models: a clearer workspace for testing and managing local models. */
#view-models { --model-ink: #262444; --model-violet: #5e4bb8; }
#view-models .model-hero { max-width: 930px; padding-top: 50px; padding-bottom: 28px; }
#view-models .model-hero h1 { margin: 15px 0 10px; letter-spacing: -.045em; }
#view-models .model-hero .hero-sub { color: #585672; }
#view-models .model-hero-badge { color: #5845aa; background: linear-gradient(110deg, #f0edff, #fceafa); border-color: #e3daf8; }
.model-live-dot { display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 50%; background: #25b78a; box-shadow: 0 0 0 4px rgba(37,183,138,.12); }
#view-models > .steps { max-width: 930px; gap: 18px; }
#view-models .model-fit-notice { color: #64518a; border-color: #e4daf4; background: linear-gradient(110deg, #f5f1ff, #fff3fb); line-height: 1.6; }
#view-models .model-panel { border: 1px solid #e8e5f2; border-radius: 22px; background: linear-gradient(145deg, #fff 52%, #faf9ff); box-shadow: 0 8px 32px rgba(61,47,114,.07), 0 1px 3px rgba(31,23,64,.04); }
#view-models .model-panel .card-head { align-items: center; gap: 14px; }
#view-models .model-panel h2 { color: var(--model-ink); letter-spacing: -.025em; }
#view-models .model-panel .muted { color: #67647d; }
.model-section-icon { display: grid; place-items: center; width: 45px; height: 45px; flex: none; border-radius: 15px; color: #604bb7; font-size: 1.35rem; font-weight: 800; background: linear-gradient(145deg, #eee8ff, #f9eafa); box-shadow: inset 0 1px #fff; }
.model-section-icon-blue { color: #4775b8; background: linear-gradient(145deg, #e3efff, #edeaff); }
.model-section-icon-green { color: #138569; background: linear-gradient(145deg, #ddf8ee, #e9f3ff); }
.model-section-icon-pink { color: #ae5a92; background: linear-gradient(145deg, #ffeaf4, #f4e8ff); }
#view-models .model-chat-panel { border-color: #ded5f3; box-shadow: 0 14px 42px rgba(91,69,153,.12); }
.model-selected-pill { display: inline-flex; align-items: center; gap: 9px; flex-wrap: wrap; max-width: 100%; margin: 0; padding: 9px 13px; border: 1px solid #e9e4f6; border-radius: 12px; background: #f8f6ff; color: #6a657e; font-size: .8rem; }
.model-selected-pill strong { color: #4c4089; overflow-wrap: anywhere; }
.model-chat-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 18px; padding: 28px 16px; text-align: center; color: #77718f; font-size: .86rem; border: 1px dashed #dcd5ef; border-radius: 17px; background: linear-gradient(130deg, #faf9ff, #fff8fc); }
.model-chat-empty strong { color: #4b426d; font-size: .95rem; }
.model-empty-icon { display: grid; place-items: center; margin-bottom: 5px; width: 38px; height: 38px; border-radius: 13px; color: #795fc8; background: #eee8ff; font-size: 1.35rem; }
#view-models .model-chat-log:not(:empty) { padding: 15px; border-radius: 17px; border: 1px solid #ece8f5; background: linear-gradient(150deg, #f8f7fc, #fdfbff); }
#view-models .model-chat-bubble { box-shadow: 0 3px 12px rgba(63,47,105,.06); }
#view-models .model-chat-bubble.user { background: linear-gradient(125deg, #6258bd, #8a66c5); }
#view-models .model-chat-bubble.assistant { background: #fff; border-color: #ebe7f4; }
#view-models .input { border-color: #ded9ed; background: #fbfaff; }
#view-models .input:focus { border-color: #8d78d7; background: #fff; box-shadow: 0 0 0 4px rgba(132,108,204,.13); }
#view-models .btn-primary { background: linear-gradient(120deg, #6256bd, #9b67c6); box-shadow: 0 5px 16px rgba(100,78,171,.25); }
#view-models .btn-ghost { color: #514577; border-color: #e1dced; background: #fff; }
#view-models .btn-ghost:hover:not(:disabled) { color: #5f46ad; border-color: #b7a6e1; background: #f9f6ff; }
#view-models :is(button, a, input, textarea, select):focus-visible { outline: 3px solid #9f8ce0; outline-offset: 3px; }
#view-models .model-metric { background: linear-gradient(135deg, #f0ecff, #faf0fb); border-color: #e7dff5; }
#view-models .model-metric span { color: #69617e; }
#view-models .model-metric strong { color: #5540a7; }
#view-models .model-row { gap: 14px; padding: 14px; margin: 8px 0; border: 1px solid #eeeaf4; border-radius: 15px; background: rgba(255,255,255,.85); }
#view-models .model-row strong { color: #33304e; }
#view-models .model-row-selected { border-color: #cfc2ee; background: linear-gradient(110deg, #f3efff, #fff8fd); box-shadow: inset 3px 0 #8f74d6; }
#view-models .model-row-selected .tag.good { color: #247b63; background: #e4f8ef; border-color: #c0ead8; }
#view-models #models-catalog { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
#view-models #models-catalog .health-item { display: flex; flex-direction: column; gap: 9px; padding: 17px; background: linear-gradient(150deg, #fff, #f8f5ff); border-color: #e9e3f4; box-shadow: 0 3px 10px rgba(78,58,133,.04); }
#view-models #models-catalog .health-item > strong { color: #3d315f; font-size: 1rem; }
#view-models #models-catalog .health-item .small { flex: 1; color: #69627d; }
#view-models #models-catalog .model-actions { margin-top: 2px; }
#view-models #model-custom-form { margin-top: 22px; padding-top: 4px; border-top: 1px solid #eeeaf5; }
#view-models .model-backup-panel { border-color: #e2e8f2; background: linear-gradient(125deg, #f7f8ff, #fff); }
#view-models #models-backups code { overflow-wrap: anywhere; }
@media (max-width: 600px) {
  #view-models .model-hero { padding: 32px 16px 18px; }
  #view-models .model-panel { padding: 20px; }
  #view-models .model-row { align-items: flex-start; }
  #view-models .model-actions { width: 100%; }
  #view-models #model-chat-form .model-actions .btn { flex: 1 1 auto; }
  .model-selected-pill { align-items: flex-start; }
}
.model-chat-bubble.streaming .model-chat-content:empty::before { content: "···"; color: #7a6fb5; letter-spacing: .15em; animation: pulse 1.2s ease-in-out infinite; }
.model-chat-bubble.streaming .model-chat-content:not(:empty)::after { content: "▍"; color: #8266d0; animation: pulse 1s steps(2) infinite; }
@media (prefers-reduced-motion: reduce) { .model-chat-bubble.streaming .model-chat-content::before, .model-chat-bubble.streaming .model-chat-content::after { animation: none; } }

/* Main navigation */
.nav-main { background: rgba(255,255,255,.93); border-bottom: 1px solid #e9e6f2; box-shadow: 0 4px 24px rgba(39,29,74,.05); }
.nav-main .nav-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 20px; align-items: center; max-width: 1240px; padding: 12px 24px 10px; }
.nav-main .nav-home { display: inline-flex; align-items: center; gap: 10px; width: fit-content; min-width: 0; color: var(--c-ink); text-decoration: none; white-space: nowrap; }
.nav-mark { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 12px; background: linear-gradient(135deg, #7165d9, #b06ac8); box-shadow: 0 5px 14px rgba(115,90,190,.24); }
.nav-mark svg { width: 20px; height: 20px; fill: none; stroke: white; stroke-width: 2; stroke-linecap: round; }
.nav-main .nav-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px; min-width: 0; }
.nav-main .nav-badge { white-space: nowrap; padding: 5px 11px; font-size: .73rem; }
.nav-main .nav-language { margin: 0; }
.nav-main .nav-language select { max-width: 108px; min-height: 38px; padding: 7px 10px; border-color: #e8e4f1; color: #514a69; background: #faf9fd; }
.nav-main .account { gap: 9px; min-width: 0; }
.nav-main .account-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-main .nav-tabs-wrap { grid-column: 1 / -1; min-width: 0; position: relative; }
.nav-main .nav-tabs-wrap.has-more::after { content: "›"; position: absolute; top: 1px; right: 1px; bottom: 1px; display: grid; place-items: center; width: 30px; border-radius: 0 13px 13px 0; color: #65519a; font-size: 1.25rem; font-weight: 700; background: linear-gradient(90deg, rgba(250,247,252,.1), #f8f4fb 55%); pointer-events: none; }
.nav-main .nav-tabs { width: 100%; min-width: 0; overflow-x: auto; display: flex; gap: 4px; padding: 5px; border-radius: 15px; border-color: #eeeaf4; background: linear-gradient(110deg, #f6f4fb, #fbf7fc); scrollbar-width: thin; scrollbar-color: #cfc3e7 transparent; }
.nav-main .tab { display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: 0 0 auto; min-height: 40px; padding: 8px 13px; border-radius: 11px; color: #665e79; white-space: nowrap; font-size: .85rem; }
.nav-main .tab svg { width: 17px; height: 17px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-main .tab:hover { color: #5a48a9; background: rgba(255,255,255,.75); }
.nav-main .tab.active { color: #fff; background: linear-gradient(120deg, #675dc5, #9a69c5); box-shadow: 0 4px 12px rgba(111,83,181,.25); }
.nav-main .tab:focus-visible, .nav-main :is(a, button, select):focus-visible { outline: 3px solid #9c8ae2; outline-offset: 2px; }
@media (max-width: 700px) {
  .nav-main .nav-inner { gap: 9px 10px; padding: 10px 14px 9px; }
  .nav-main .nav-actions { gap: 6px; }
  .nav-main .nav-home { gap: 7px; font-size: 1rem; }
  .nav-main .nav-mark { width: 32px; height: 32px; border-radius: 10px; }
  .nav-main .account-name { max-width: 85px; padding: 4px 8px; }
  .nav-main .account { font-size: .78rem; gap: 6px; }
  .nav-main .nav-language select { max-width: 88px; min-height: 34px; padding: 5px; font-size: .76rem; }
  .nav-main .nav-tabs { order: initial; padding: 4px; border-radius: 13px; }
  .nav-main .tab { min-height: 40px; padding: 8px 11px; }
}
@media (max-width: 380px) {
  .nav-main .nav-inner { grid-template-columns: minmax(0, 1fr) auto; }
  .nav-main .account-name { max-width: 62px; }
  .nav-main .nav-actions { gap: 4px; }
  .nav-main .account { gap: 4px; }
}
@media (max-width: 420px) {
  .nav-main .nav-actions { max-width: calc(100vw - 180px); }
}
/* Formatted model replies */
.model-chat-bubble.assistant .model-chat-content { white-space: normal; line-height: 1.65; }
.model-chat-content > :first-child { margin-top: 0; }
.model-chat-content > :last-child { margin-bottom: 0; }
.model-chat-content :is(h3,h4,h5,h6) { margin: 1.15em 0 .45em; color: #302751; line-height: 1.35; letter-spacing: -.015em; }
.model-chat-content h3 { font-size: 1.2rem; }
.model-chat-content h4 { font-size: 1.08rem; }
.model-chat-content h5, .model-chat-content h6 { font-size: 1rem; }
.model-chat-content p { margin: .7em 0; }
.model-chat-content :is(ul,ol) { padding-left: 1.5em; margin: .55em 0 .85em; }
.model-chat-content li { padding-left: .15em; margin: .25em 0; }
.model-chat-content li > :is(ul,ol) { margin: .25em 0 .45em; }
.model-chat-content strong { color: #302751; }
.model-chat-content a { color: #5a46b1; text-decoration: underline; overflow-wrap: anywhere; }
.model-chat-content :not(pre) > code { padding: .12em .35em; border-radius: 5px; color: #594596; background: #f0ecf9; font: .9em ui-monospace, monospace; }
.model-chat-content blockquote { margin: .8em 0; padding: .5em 1em; border-left: 3px solid #a995df; color: #615b76; background: #f8f6fd; }
.model-chat-table-wrap { max-width: 100%; margin: .9em 0; overflow-x: auto; border: 1px solid #e6e1f0; border-radius: 12px; }
.model-chat-table-wrap table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.model-chat-table-wrap :is(th,td) { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid #eeeaf5; min-width: 100px; }
.model-chat-table-wrap th { background: #f3f0fb; color: #4b3d78; font-weight: 700; }
.model-chat-table-wrap tbody tr:last-child td { border-bottom: 0; }

.model-chat-log { max-height: min(65vh, 720px); }
.account-mail-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--c-border); }
.account-mail-section h3 { font-size: 1rem; }
#mail-form .row-2 { margin-top: 18px; }
#mail-form .row-2 .field-label { margin-top: 0; }

.login-success { padding: 10px 12px; border-radius: 10px; background: #e8f8f0; color: #047857; }
/* GPU energy dashboard */
.energy-main { max-width: 1000px; }
.energy-live { display: flex; justify-content: space-between; align-items: center; gap: 24px; color: #fff; border: 1px solid #4f4683; background: radial-gradient(400px 180px at 90% 0%, rgba(178,110,236,.28), transparent 70%), linear-gradient(120deg, #22203f, #393058); box-shadow: 0 16px 36px rgba(71,55,127,.18); }
.energy-live .muted { color: #d0cbe5; }
.energy-eyebrow { color: #d0c1ff; font-size: .76rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.energy-watts { font-size: clamp(2rem, 4vw, 2.8rem); font-weight: 850; line-height: 1.1; font-variant-numeric: tabular-nums; margin: 8px 0; }
.energy-devices { display: grid; gap: 8px; min-width: min(100%, 260px); }
.energy-device { display: flex; justify-content: space-between; gap: 18px; padding: 9px 12px; border: 1px solid rgba(255,255,255,.12); border-radius: 11px; background: rgba(255,255,255,.07); font-size: .83rem; }
.energy-device span { color: #e0dcf0; }
.energy-device strong { white-space: nowrap; font-variant-numeric: tabular-nums; }
.energy-periods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.energy-period { display: flex; flex-direction: column; gap: 5px; min-width: 0; padding: 20px; border: 1px solid #e6e1f0; border-radius: 18px; background: linear-gradient(145deg, #fff, #f9f6ff); box-shadow: 0 6px 24px rgba(61,47,114,.06); }
.energy-period-label { color: #6a617f; font-size: .78rem; font-weight: 700; }
.energy-period-value { color: #392b6d; font-size: clamp(1.12rem, 2vw, 1.45rem); font-weight: 800; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.energy-period-caption { color: #716882; font-size: .76rem; }
.energy-period-rule { height: 1px; background: #e9e4f1; margin: 9px 0; }
.energy-period-row { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 8px; color: #716882; font-size: .76rem; }
.energy-period-row strong { color: #453c60; font-variant-numeric: tabular-nums; }
.energy-chart-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
.energy-chart-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.energy-chart-controls :is(.energy-range,.energy-mode)[aria-pressed="true"] { color: #fff; border-color: #7960c6; background: linear-gradient(120deg, #685ac3, #9a68c4); }
.energy-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px; font-size: .8rem; font-weight: 600; color: #6b6580; }
.energy-legend span { display: inline-flex; align-items: center; gap: 7px; }
.energy-legend i { width: 10px; height: 10px; border-radius: 3px; }
.energy-legend-total { background: #ded5f7; border: 1px solid #b8a6df; }
.energy-legend-active { background: #7960c6; }
.energy-chart { margin-top: 14px; overflow-x: auto; }
.energy-chart svg { display: block; width: 100%; min-width: 480px; height: auto; }
.energy-history { margin-top: 15px; }
.energy-history summary { cursor: pointer; color: #5c4aab; font-weight: 700; font-size: .86rem; }
.energy-table { margin-top: 12px; min-width: 540px; }
@media (max-width: 700px) {
  .energy-live { align-items: flex-start; flex-direction: column; }
  .energy-devices { width: 100%; }
  .energy-periods { grid-template-columns: 1fr; }
  .energy-period { padding: 16px 18px; }
  .energy-chart svg { min-width: 480px; }
}

.energy-coverage { margin: -6px 2px 0; }
.energy-breakdown-row { display: grid; grid-template-columns: minmax(0, 2fr) repeat(2, minmax(100px, 1fr)); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--c-border); }
.energy-breakdown-row:last-child { border-bottom: 0; }
.energy-breakdown-row > div { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.energy-breakdown-row span { color: var(--c-text-light); font-size: .76rem; }
.energy-breakdown-row strong { color: #433b60; font-size: .9rem; font-variant-numeric: tabular-nums; }
@media (max-width: 600px) { .energy-breakdown-row { grid-template-columns: 1fr 1fr; } .energy-breakdown-row > div:first-child { grid-column: 1 / -1; } }
.mfa-qr { display: block; width: min(100%, 220px); height: auto; margin: 12px auto; padding: 8px; border: 1px solid var(--c-border); border-radius: 12px; background: #fff; }
.mfa-secret, .mfa-recovery-codes { display: block; padding: 12px; border-radius: 10px; background: var(--c-bg-soft); border: 1px solid var(--c-border); font: .88rem/1.6 ui-monospace, monospace; overflow-wrap: anywhere; user-select: all; }
.mfa-recovery-codes { margin: 0; white-space: pre-wrap; }
