/* =====================================================================
   AI Gammabeta — gaya tampilan
   Tipografi: Plus Jakarta Sans (Tokotype, Jakarta) + JetBrains Mono untuk kode.
   Tanda merek γβ memakai huruf matematika KaTeX — merek dan rumus satu bahasa.
   ===================================================================== */

@font-face { font-family: "Jakarta"; src: url(fonts/jakarta-latin.woff2) format("woff2"); font-weight: 200 800; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Jakarta"; src: url(fonts/jakarta-latin-ext.woff2) format("woff2"); font-weight: 200 800; font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "JB Mono"; src: url(fonts/jbmono-400.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "JB Mono"; src: url(fonts/jbmono-600.woff2) format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "GB Math"; src: url(vendor/katex/fonts/KaTeX_Math-Italic.woff2) format("woff2"); font-style: normal; font-display: block; }

:root {
  --bg: #F6F7FA;
  --surface: #FFFFFF;
  --sidebar: #ECEEF5;
  --sidebar-hover: #E1E5F0;
  --ink: #172033;
  --ink-2: #485270;
  --ink-3: #737C96;
  --line: #DCE0EA;
  --line-soft: #E8EBF2;
  --gamma: #2E3A87;
  --gamma-hover: #24306F;
  --gamma-ink: #FFFFFF;
  --gamma-soft: #E6E9F7;
  --beta: #0F8B8D;
  --beta-soft: #DDF1F0;
  --danger: #B9323A;
  --danger-soft: #FBE9EA;
  --ok: #187A4A;
  --user-bubble: #E4E8F6;
  --code-bg: #F1F3F8;
  --shadow-pop: 0 12px 32px -12px rgba(23, 32, 51, .28), 0 2px 6px rgba(23, 32, 51, .08);
  --composer-shadow: 0 10px 30px -18px rgba(46, 58, 135, .45), 0 1px 2px rgba(23, 32, 51, .06);

  --font: "Jakarta", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JB Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --glyph: "GB Math", "KaTeX_Math", "Times New Roman", serif;

  --prose-size: 16px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 20px;
  --sb-w: 284px;
  --col: 768px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1322; --surface: #151B2E; --sidebar: #0A0E1A; --sidebar-hover: #161C30;
    --ink: #E6E9F3; --ink-2: #AEB5CB; --ink-3: #7F88A3; --line: #262E47; --line-soft: #1D2439;
    --gamma: #9AA5FF; --gamma-hover: #B3BCFF; --gamma-ink: #0E1322; --gamma-soft: #1F2747;
    --beta: #43C9C4; --beta-soft: #12302F; --danger: #F07178; --danger-soft: #3A1B22; --ok: #5BD49A;
    --user-bubble: #1E2643; --code-bg: #0B0F1C;
    --shadow-pop: 0 16px 40px -12px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);
    --composer-shadow: 0 10px 30px -16px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E1322; --surface: #151B2E; --sidebar: #0A0E1A; --sidebar-hover: #161C30;
  --ink: #E6E9F3; --ink-2: #AEB5CB; --ink-3: #7F88A3; --line: #262E47; --line-soft: #1D2439;
  --gamma: #9AA5FF; --gamma-hover: #B3BCFF; --gamma-ink: #0E1322; --gamma-soft: #1F2747;
  --beta: #43C9C4; --beta-soft: #12302F; --danger: #F07178; --danger-soft: #3A1B22; --ok: #5BD49A;
  --user-bubble: #1E2643; --code-bg: #0B0F1C;
  --shadow-pop: 0 16px 40px -12px rgba(0, 0, 0, .6), 0 2px 6px rgba(0, 0, 0, .3);
  --composer-shadow: 0 10px 30px -16px rgba(0, 0, 0, .8);
  color-scheme: dark;
}
:root[data-fontsize="sm"] { --prose-size: 15px; }
:root[data-fontsize="lg"] { --prose-size: 17.5px; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "ss01" 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gamma); }
:focus-visible { outline: 2px solid var(--beta); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -40px; background: var(--gamma); color: var(--gamma-ink); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { top: 12px; }
.muted { color: var(--ink-3); }
.ic { width: 20px; height: 20px; flex: none; }
kbd { font-family: var(--font); font-size: 11px; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px;
  border-radius: 10px; border: 1px solid transparent; font-weight: 600; font-size: 14.5px; text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s; }
.btn-primary { background: var(--gamma); color: var(--gamma-ink); }
.btn-primary:hover { background: var(--gamma-hover); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-danger-ghost { background: transparent; border-color: color-mix(in srgb, var(--danger) 40%, transparent); color: var(--danger); min-height: 36px; padding: 0 14px; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 0; background: transparent; color: var(--ink-2); }
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }

/* ------------------------------------------------------------ forms */
.form { display: grid; gap: 16px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.field small, .help { font-size: 12.5px; color: var(--ink-3); }
.field input, .field select, .field textarea, .input {
  width: 100%; min-height: 44px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.field textarea.mono { font-family: var(--mono); font-size: 13px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--gamma);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gamma) 18%, transparent); }
.input-with-action { position: relative; display: block; }
.input-with-action input { padding-right: 104px; }
.input-action { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent;
  color: var(--gamma); font-size: 13px; font-weight: 600; padding: 6px 10px; border-radius: 6px; }
.input-action:hover { background: var(--gamma-soft); }

.notice { padding: 12px 14px; border-radius: 10px; background: var(--gamma-soft); color: var(--ink); font-size: 14px; margin-bottom: 16px; }
.notice-error { background: var(--danger-soft); color: var(--danger); }
.notice-ok { background: var(--beta-soft); color: var(--ink); }
.notice code, .checklist code { font-family: var(--mono); font-size: 12.5px; }

/* ------------------------------------------------------------ auth pages */
.page-auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 32px 20px;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, transparent 0 25%, var(--bg) 80%),
    repeating-linear-gradient(0deg, transparent 0 27px, var(--line-soft) 27px 28px),
    repeating-linear-gradient(90deg, transparent 0 27px, var(--line-soft) 27px 28px), var(--bg);
  background-attachment: fixed; }
.auth-shell { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 36px 32px 28px; box-shadow: var(--shadow-pop); }
.auth-shell--wide { max-width: 560px; }
.auth-mark { width: 56px; height: 56px; border-radius: 16px; background: var(--gamma); color: var(--gamma-ink);
  display: grid; place-items: center; margin-bottom: 20px; }
.glyph, .brand-glyph, .welcome-mark, .msg-ai-mark { font-family: var(--glyph); letter-spacing: -.02em; }
.auth-mark .glyph { font-size: 28px; line-height: 1; transform: translateY(-1px); }
.auth-title { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; margin: 0; font-weight: 700; }
.auth-sub { margin: 6px 0 24px; color: var(--ink-3); font-size: 14.5px; }
.auth-foot { margin: 20px 0 0; font-size: 13px; color: var(--ink-3); text-align: center; }
.form-heading { font-size: 16px; margin: 8px 0 0; }
.checklist { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 8px; font-size: 14px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; }
.checklist .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 7px; flex: none; background: var(--ok); }
.checklist .bad .dot { background: var(--danger); }
.checklist small { display: block; color: var(--ink-3); font-size: 12.5px; }
.install-log { margin: 8px 0 0; padding-left: 18px; }

/* ------------------------------------------------------------ app shell */
.page-chat { height: 100vh; height: 100dvh; overflow: hidden; }
.app { display: grid; grid-template-columns: var(--sb-w) 1fr; height: 100%; }

.sidebar { background: var(--sidebar); display: flex; flex-direction: column; min-height: 0; padding: 14px 12px 12px;
  border-right: 1px solid var(--line-soft); }
.sb-head { display: flex; align-items: center; gap: 8px; padding: 4px 4px 14px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--ink); min-width: 0; flex: 1; }
.brand-glyph { width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--gamma); color: var(--gamma-ink);
  display: grid; place-items: center; font-size: 21px; line-height: 1; }
.brand-text { display: grid; min-width: 0; }
.brand-text strong { font-size: 16px; letter-spacing: -.015em; font-weight: 700; }
.brand-text small { font-size: 11.5px; color: var(--ink-3); line-height: 1.35; }
.sb-close { display: none; }

.btn-new { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 0 12px 0 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s; }
.btn-new .ic { color: var(--gamma); }
.btn-new:hover { border-color: color-mix(in srgb, var(--gamma) 45%, var(--line)); box-shadow: 0 1px 0 var(--line); }
.kbd-hint { margin-left: auto; color: var(--ink-3); font-weight: 500; }

.sb-search { display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; padding: 0 10px; height: 38px; border-radius: 10px;
  color: var(--ink-3); background: transparent; transition: background-color .15s; }
.sb-search:focus-within { background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.sb-search .ic { width: 18px; height: 18px; }
.sb-search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: 14px; color: var(--ink); }
.sb-search input::placeholder { color: var(--ink-3); }

.sb-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0 -6px; padding: 0 6px; scrollbar-width: thin; }
.sb-group { font-size: 12px; font-weight: 600; color: var(--ink-3); margin: 16px 8px 4px; }
.sb-items { list-style: none; margin: 0; padding: 0; }
.sb-item { position: relative; border-radius: 9px; }
.sb-item a { display: block; padding: 8px 36px 8px 10px; border-radius: 9px; color: var(--ink-2); text-decoration: none; font-size: 14px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent calc(100% - 30px)); mask-image: linear-gradient(90deg, #000 calc(100% - 44px), transparent calc(100% - 30px)); }
.sb-item:hover a, .sb-item.active a { background: var(--sidebar-hover); color: var(--ink); }
.sb-item.active a { font-weight: 600; box-shadow: inset 2px 0 0 var(--gamma); }
.sb-more { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; border: 0; border-radius: 7px;
  background: transparent; color: var(--ink-3); display: grid; place-items: center; opacity: 0; }
.sb-more .ic { width: 18px; height: 18px; }
.sb-item:hover .sb-more, .sb-item.active .sb-more, .sb-more:focus-visible { opacity: 1; }
.sb-more:hover { background: var(--line); color: var(--ink); }
.sb-empty { font-size: 13.5px; color: var(--ink-3); padding: 14px 10px; margin: 0; }

.sb-foot { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; display: grid; gap: 2px; }
.sb-link { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px; border: 0; border-radius: 9px;
  background: transparent; color: var(--ink-2); text-decoration: none; font-size: 14px; text-align: left; }
.sb-link:hover { background: var(--sidebar-hover); color: var(--ink); }
.sb-link .ic { width: 19px; height: 19px; }
.sb-profile { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; text-decoration: none; color: var(--ink); margin-top: 4px; }
.sb-profile:hover { background: var(--sidebar-hover); }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--beta-soft); color: var(--beta); }
.sb-profile-text { display: grid; min-width: 0; }
.sb-profile-text strong { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-profile-text small { font-size: 12px; color: var(--ink-3); }
.scrim { display: none; }

/* ------------------------------------------------------------ main */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 6px; height: 58px; padding: 0 16px 0 22px; flex: none; }
.topbar-title { font-size: 15px; font-weight: 600; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.model-chip { font-size: 12px; font-weight: 600; color: var(--ink-3); border: 1px solid var(--line); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.only-mobile { display: none; }

.thread { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: auto; padding: 8px 20px 24px; overscroll-behavior: contain; }
.messages { max-width: var(--col); margin: 0 auto; display: grid; gap: 26px; }

/* empty state — kertas berpetak tipis di belakang sapaan */
.thread.is-empty { display: grid; align-content: center; }
.welcome { position: relative; max-width: var(--col); width: 100%; margin: 0 auto; padding: 48px 0 24px; isolation: isolate; }
.welcome::before { content: ""; position: absolute; inset: -40px -60px; z-index: -1;
  background:
    repeating-linear-gradient(0deg, transparent 0 31px, var(--line-soft) 31px 32px),
    repeating-linear-gradient(90deg, transparent 0 31px, var(--line-soft) 31px 32px);
  -webkit-mask-image: radial-gradient(ellipse 60% 55% at 30% 40%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 60% 55% at 30% 40%, #000 20%, transparent 75%); }
.welcome-mark { font-size: 64px; line-height: 1; color: var(--gamma); margin-bottom: 18px; }
.welcome-title { font-size: clamp(28px, 4.4vw, 42px); line-height: 1.12; letter-spacing: -.03em; font-weight: 700; margin: 0; max-width: 16ch; }
.welcome-sub { color: var(--ink-2); font-size: 16px; max-width: 54ch; margin: 14px 0 30px; }
.suggestions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.suggestion { text-align: left; padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 14px; line-height: 1.45; transition: border-color .15s, color .15s, transform .15s; }
.suggestion:hover { border-color: var(--gamma); color: var(--ink); }
.suggestion:active { transform: translateY(1px); }

/* ------------------------------------------------------------ messages */
.msg { position: relative; animation: rise .22s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.msg-user-bubble { max-width: min(85%, 620px); background: var(--user-bubble); padding: 11px 16px; border-radius: 18px 18px 6px 18px;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; font-size: var(--prose-size); line-height: 1.6; }
.msg-user .msg-actions { opacity: 0; margin-top: 4px; }
.msg-user:hover .msg-actions, .msg-user:focus-within .msg-actions { opacity: 1; }

.msg-ai { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 14px; }
.msg-ai-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; line-height: 1;
  color: var(--gamma); background: var(--gamma-soft); margin-top: 1px; }
.msg-ai.is-streaming .msg-ai-mark { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { background: color-mix(in srgb, var(--gamma) 22%, var(--gamma-soft)); } }
.msg-ai-body { min-width: 0; }
.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 8px; min-height: 30px; }
.msg-ai .msg-actions { opacity: .0; transition: opacity .15s; }
.msg-ai:hover .msg-actions, .msg-ai:focus-within .msg-actions, .msg-ai.is-last .msg-actions { opacity: 1; }
.msg-ai.is-streaming .msg-actions, .msg-ai.is-error .msg-actions { visibility: hidden; }
.act-regen { display: none !important; }
.msg-ai.is-last .act-regen { display: inline-flex !important; }
.act { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink-3); font-size: 12.5px; font-weight: 500; }
.act .ic { width: 16px; height: 16px; }
.act:hover { background: var(--line-soft); color: var(--ink); }
.act.ok { color: var(--ok); }
.msg-meta { margin-left: 8px; font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.error-text { color: var(--danger); background: var(--danger-soft); padding: 10px 14px; border-radius: 10px; margin: 0; font-size: 14.5px; }

.thinking { display: inline-flex; gap: 5px; padding: 10px 0; }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--gamma); opacity: .3; animation: blink 1.2s infinite ease-in-out; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 30% { opacity: 1; transform: translateY(-2px); } }
.msg-ai.is-streaming .prose > :last-child::after { content: ""; display: inline-block; width: .5em; height: 1em; margin-left: 2px;
  vertical-align: -.12em; background: var(--beta); border-radius: 2px; animation: caret 1s steps(2) infinite; }
.msg-ai.is-streaming .prose > .codeblock:last-child::after, .msg-ai.is-streaming .prose > .table-wrap:last-child::after,
.msg-ai.is-streaming .prose > .math-solo:last-child::after { display: none; }
@keyframes caret { 50% { opacity: 0; } }

/* ------------------------------------------------------------ prose (jawaban AI) */
.prose { font-size: var(--prose-size); line-height: 1.72; color: var(--ink); overflow-wrap: break-word; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 .9em; }
.prose h1, .prose h2, .prose h3, .prose h4 { line-height: 1.3; letter-spacing: -.015em; margin: 1.5em 0 .55em; font-weight: 700; }
.prose h1 { font-size: 1.45em; } .prose h2 { font-size: 1.25em; } .prose h3 { font-size: 1.1em; } .prose h4 { font-size: 1em; }
.prose ul, .prose ol { padding-left: 1.5em; margin: 0 0 .9em; }
.prose li { margin: .3em 0; }
.prose li > p { margin: 0 0 .4em; }
.prose li::marker { color: var(--ink-3); }
.prose ol > li::marker { font-weight: 600; }
.prose strong { font-weight: 700; }
.prose a { color: var(--gamma); text-underline-offset: 2px; }
.prose blockquote { margin: 0 0 1em; padding: 2px 0 2px 16px; border-left: 3px solid var(--beta); color: var(--ink-2); }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.prose :not(pre) > code { font-family: var(--mono); font-size: .86em; background: var(--code-bg); border: 1px solid var(--line-soft);
  padding: .12em .38em; border-radius: 5px; }
.prose img { max-width: 100%; border-radius: 10px; }

.table-wrap { overflow-x: auto; margin: 0 0 1.1em; border: 1px solid var(--line); border-radius: 12px; }
.prose table { border-collapse: collapse; width: 100%; font-size: .92em; line-height: 1.5; font-variant-numeric: tabular-nums; }
.prose th, .prose td { padding: 9px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line-soft); }
.prose th { font-weight: 600; background: var(--line-soft); color: var(--ink); white-space: nowrap; }
.prose tr:last-child td { border-bottom: 0; }

.codeblock { margin: 0 0 1.1em; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.codeblock-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 6px 14px; font-size: 12px;
  font-weight: 600; color: var(--ink-3); border-bottom: 1px solid var(--line-soft); }
.code-copy { border: 0; background: transparent; color: var(--ink-2); font-size: 12px; font-weight: 600; padding: 5px 9px; border-radius: 7px; }
.code-copy:hover { background: var(--line); color: var(--ink); }
.code-copy.ok { color: var(--ok); }
.prose pre { margin: 0; padding: 14px 16px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.6; tab-size: 4; }
.prose pre code { font-family: inherit; background: none; padding: 0; border: 0; }

/* rumus */
.prose .katex { font-size: 1.08em; }
.prose .math-block { display: block; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.prose .math-solo { margin: .4em 0 1em; padding: 6px 0; overflow-x: auto; overflow-y: hidden; }
.prose .katex-display { margin: .2em 0; }
.prose .math-error { color: var(--danger); }

/* ------------------------------------------------------------ composer */
.composer-wrap { flex: none; padding: 0 20px calc(14px + env(safe-area-inset-bottom)); }
.composer { max-width: var(--col); margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 22px;
  padding: 12px 12px 10px 18px; box-shadow: var(--composer-shadow); transition: border-color .15s, box-shadow .15s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--gamma) 55%, var(--line)); }
.composer textarea { display: block; width: 100%; border: 0; outline: none; resize: none; background: transparent; padding: 4px 0;
  font-size: 16px; line-height: 1.55; max-height: 40vh; color: var(--ink); }
.composer textarea::placeholder { color: var(--ink-3); }
.composer-row { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.composer-hint { font-size: 12px; color: var(--ink-3); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.send-btn { width: 38px; height: 38px; border-radius: 12px; border: 0; display: grid; place-items: center; background: var(--gamma);
  color: var(--gamma-ink); transition: background-color .15s, opacity .15s, transform .1s; }
.send-btn:hover:not(:disabled) { background: var(--gamma-hover); }
.send-btn:active:not(:disabled) { transform: scale(.95); }
.send-btn:disabled { opacity: .35; cursor: default; }
.send-btn .ic { width: 19px; height: 19px; }
.send-btn .stop-ic { display: none; }
.composer.is-busy .send-btn { background: var(--ink); color: var(--surface); }
.composer.is-busy .send-ic { display: none; }
.composer.is-busy .stop-ic { display: grid; }
.disclaimer { text-align: center; font-size: 11.5px; color: var(--ink-3); margin: 8px 0 0; }

.jump { position: absolute; left: 50%; bottom: 150px; transform: translateX(-50%); width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); display: grid; place-items: center; box-shadow: var(--shadow-pop); z-index: 5; }
.jump .ic { width: 18px; height: 18px; }

/* ------------------------------------------------------------ popover, dialog, toast */
.popover { position: fixed; z-index: 60; min-width: 170px; padding: 6px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--line); box-shadow: var(--shadow-pop); display: grid; }
.popover button { display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 9px 10px; border-radius: 8px;
  font-size: 14px; text-align: left; color: var(--ink); }
.popover button .ic { width: 17px; height: 17px; color: var(--ink-3); }
.popover button:hover, .popover button:focus-visible { background: var(--line-soft); outline: none; }
.popover .danger, .popover .danger .ic { color: var(--danger); }

.dialog { border: 0; padding: 0; border-radius: 18px; background: var(--surface); color: var(--ink); width: min(440px, calc(100vw - 32px));
  box-shadow: var(--shadow-pop); }
.dialog::backdrop { background: rgba(10, 14, 26, .45); backdrop-filter: blur(2px); }
.dialog[open] { animation: pop .16s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog-body { padding: 22px; display: grid; gap: 16px; }
.dialog-body h2 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.dialog-body p { margin: 0; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin: -6px -8px -4px 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.seg-field { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.seg-field legend { font-size: 13.5px; font-weight: 600; color: var(--ink-2); padding: 0; margin-bottom: 8px; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 4px; gap: 4px; border-radius: 12px; background: var(--line-soft); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; }
.segmented span { display: block; text-align: center; padding: 7px 8px; border-radius: 9px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.segmented input:checked + span { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.segmented input:focus-visible + span { outline: 2px solid var(--beta); }
.switch-row, .settings-danger { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch-row span, .settings-danger span { display: grid; gap: 2px; }
.switch-row strong, .settings-danger strong { font-size: 14px; font-weight: 600; }
.switch-row small, .settings-danger small { font-size: 12.5px; color: var(--ink-3); }
.settings-danger { padding-top: 16px; border-top: 1px solid var(--line); }
.settings-links { display: flex; gap: 6px; flex-wrap: wrap; }
.settings-links a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; background: var(--line-soft);
  color: var(--ink); text-decoration: none; font-size: 13.5px; font-weight: 600; }
.settings-logout { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; border: 0; background: var(--line-soft); color: var(--danger); font-size: 13.5px; font-weight: 600; }
.settings-logout .ic { width: 17px; height: 17px; }
.settings-links a .ic { width: 17px; height: 17px; color: var(--gamma); }
.switch { appearance: none; -webkit-appearance: none; width: 44px; height: 26px; border-radius: 99px; background: var(--line); position: relative;
  flex: none; cursor: pointer; transition: background-color .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .18s; }
.switch:checked { background: var(--gamma); }
.switch:checked::after { transform: translateX(18px); }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 90;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 500; max-width: calc(100vw - 32px);
  transition: opacity .2s, transform .2s; box-shadow: var(--shadow-pop); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------ responsif */
@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(88vw, 320px); z-index: 50; transform: translateX(-102%);
    transition: transform .25s cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow-pop); padding-top: calc(14px + env(safe-area-inset-top)); }
  .app.sidebar-open .sidebar { transform: none; }
  .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(10, 14, 26, .45); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .app.sidebar-open .scrim { opacity: 1; pointer-events: auto; }
  .sb-close { display: inline-grid; }
  .kbd-hint { display: none; }
  .only-mobile { display: inline-grid; }
  .topbar { padding: env(safe-area-inset-top) 8px 0; height: calc(54px + env(safe-area-inset-top)); border-bottom: 1px solid var(--line-soft); }
  .topbar-title { text-align: center; font-size: 14.5px; }
  .model-chip { display: none; }
  .thread { padding: 16px 16px 20px; }
  .welcome { padding-top: 24px; }
  .welcome-mark { font-size: 48px; }
  .suggestions { grid-template-columns: 1fr; }
  .suggestion { padding: 12px 14px; }
  .suggestions .suggestion:nth-child(n+4) { display: none; }
  .msg-ai { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .msg-ai-mark { width: 28px; height: 28px; font-size: 14px; border-radius: 8px; }
  .msg-ai .msg-actions, .msg-user .msg-actions { opacity: 1; }
  .msg-user-bubble { max-width: 88%; }
  .composer-wrap { padding: 0 10px calc(8px + env(safe-area-inset-bottom)); }
  .composer { border-radius: 20px; padding: 10px 10px 8px 14px; }
  .composer-hint { visibility: hidden; }
  .jump { bottom: 130px; }
}
@media (hover: none) { .sb-more { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ------------------------------------------------------------ admin & profil */
.page-admin { min-height: 100vh; background: var(--bg); }
.admin-top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; padding: 12px 24px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line-soft); }
.admin-top .brand { flex: none; }
.admin-top .brand-glyph { width: 34px; height: 34px; font-size: 18px; border-radius: 10px; }
.admin-top .spacer { flex: 1; }
.admin-tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.admin-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; color: var(--ink-2); text-decoration: none;
  font-size: 14px; font-weight: 500; white-space: nowrap; }
.admin-tabs a .ic { width: 18px; height: 18px; }
.admin-tabs a:hover { background: var(--line-soft); color: var(--ink); }
.admin-tabs a[aria-current="page"] { background: var(--gamma-soft); color: var(--gamma); font-weight: 600; }
.admin-wrap { max-width: 1120px; margin: 0 auto; padding: 28px 24px 64px; }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.admin-head h1 { font-size: 26px; letter-spacing: -.02em; margin: 0; }
.admin-head p { margin: 4px 0 0; color: var(--ink-3); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 22px; }
.panel + .panel { margin-top: 18px; }
.panel h2 { font-size: 16.5px; margin: 0 0 4px; letter-spacing: -.01em; }
.panel .panel-sub { margin: 0 0 18px; color: var(--ink-3); font-size: 13.5px; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.form-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* statistik: satu angka utama, sisanya baris tenang */
.stat-hero { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 2fr); gap: 18px; margin-bottom: 18px; }
.stat-big { background: var(--gamma); color: var(--gamma-ink); border-radius: 16px; padding: 22px; display: flex; flex-direction: column; justify-content: space-between; min-height: 180px; }
.stat-big .label { font-size: 14px; opacity: .85; }
.stat-big .value { font-size: 44px; font-weight: 700; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-big .foot { font-size: 13px; opacity: .85; }
.stat-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 16px; background: var(--surface); overflow: hidden; }
.stat-rows div { padding: 16px 18px; border-bottom: 1px solid var(--line-soft); }
.stat-rows div:nth-child(odd) { border-right: 1px solid var(--line-soft); }
.stat-rows div:nth-last-child(-n+2) { border-bottom: 0; }
.stat-rows dt { font-size: 13px; color: var(--ink-3); }
.stat-rows dd { margin: 2px 0 0; font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.bars { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; align-items: end; gap: 6px; height: 160px; padding-top: 10px; }
.bar { position: relative; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.bar span { display: block; background: var(--beta); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bar:hover span { background: var(--gamma); }
.bar em { position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); font-style: normal; font-size: 11px; background: var(--ink);
  color: var(--bg); padding: 3px 7px; border-radius: 6px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s; }
.bar:hover em { opacity: 1; }
.bar-labels { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; margin-top: 6px; font-size: 10.5px; color: var(--ink-3); text-align: center; }

.table-scroll { overflow-x: auto; margin: 0 -22px -22px; }
.dtable { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.dtable th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dtable td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.dtable tr:last-child td { border-bottom: 0; }
.dtable th:first-child, .dtable td:first-child { padding-left: 22px; }
.dtable th:last-child, .dtable td:last-child { padding-right: 22px; }
.dtable .num { text-align: right; }
.user-cell { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.user-cell .avatar { width: 32px; height: 32px; font-size: 12px; }
.user-cell small { display: block; color: var(--ink-3); font-size: 12.5px; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--line-soft); color: var(--ink-2); }
.pill-admin { background: var(--gamma-soft); color: var(--gamma); }
.pill-on { background: var(--beta-soft); color: var(--beta); }
.pill-off { background: var(--danger-soft); color: var(--danger); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.key-status { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--line-soft); font-size: 14px; }
.key-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); flex: none; }
.key-status.on .dot { background: var(--ok); }
.key-status code { font-family: var(--mono); font-size: 13px; }
.test-result { font-size: 13.5px; padding: 10px 12px; border-radius: 10px; display: none; white-space: pre-wrap; }
.test-result.show { display: block; }
.test-result.ok { background: var(--beta-soft); }
.test-result.bad { background: var(--danger-soft); color: var(--danger); }
.preset-row { display: flex; gap: 6px; flex-wrap: wrap; }
.preset-row button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 4px 11px; font-size: 12.5px; color: var(--ink-2); }
.preset-row button:hover { border-color: var(--gamma); color: var(--ink); }
.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 14px; margin: 0; }
.info-list dt { color: var(--ink-3); }
.info-list dd { margin: 0; font-family: var(--mono); font-size: 13px; word-break: break-all; }

.profile-card { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.profile-card .avatar { width: 64px; height: 64px; font-size: 22px; }
.profile-card h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.profile-card p { margin: 2px 0 0; color: var(--ink-3); }

@media (max-width: 899px) {
  .admin-top { padding: 10px 14px; flex-wrap: wrap; }
  .admin-top .brand-text { display: none; }
  .admin-tabs { order: 3; width: 100%; }
  .admin-wrap { padding: 20px 14px 48px; }
  .cols-2, .cols-3, .split, .stat-hero { grid-template-columns: 1fr; }
  .panel { padding: 18px; }
  .table-scroll { margin: 0 -18px -18px; }
}
