/* ===== Token ===== */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --ink: #18181b;
  --ink-2: #3f3f46;
  --muted: #71717a;
  --line: #e7e5e4;
  --line-strong: #d6d3d1;
  --primary: #ea7a12;          /* oranye SHD, kontras teks putih memenuhi AA untuk teks tebal */
  --primary-hover: #d46b0a;
  --primary-soft: #fff4e8;
  --primary-ink: #9a4a05;
  --live: #16a34a;
  --live-soft: #e8f7ee;
  --wait: #b45309;
  --wait-soft: #fef3e2;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .05);
  --shadow-md: 0 4px 16px rgb(0 0 0 / .06), 0 1px 3px rgb(0 0 0 / .05);
  --radius: 12px;
  --radius-sm: 8px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f11;
    --surface: #18181b;
    --surface-2: #1d1d21;
    --ink: #f4f4f5;
    --ink-2: #d4d4d8;
    --muted: #a1a1aa;
    --line: #27272a;
    --line-strong: #3f3f46;
    --primary: #f28c28;
    --primary-hover: #f59e47;
    --primary-soft: #2b1d10;
    --primary-ink: #fbbf7a;
    --live: #4ade80;
    --live-soft: #12261a;
    --wait: #fbbf24;
    --wait-soft: #2a2110;
    --danger: #f87171;
    --danger-soft: #2c1414;
    --shadow-sm: none;
    --shadow-md: 0 0 0 1px var(--line);
    color-scheme: dark;
  }
}

/* ===== Dasar ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { line-height: 1.25; letter-spacing: -.015em; margin: 0; }
a { color: inherit; }
code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.muted { color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }
.ic { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }

/* ===== Tombol ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font: 600 14px/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 16%, var(--surface)); }
.btn-block { width: 100%; min-height: 44px; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-icon { width: 40px; padding: 0; }

/* ===== Layout ===== */
.app { display: grid; grid-template-columns: 288px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 16px; padding: 20px 16px;
  background: var(--surface); border-right: 1px solid var(--line);
}
main { padding: 32px clamp(16px, 5vw, 64px) 80px; outline: none; }
.menu-btn { display: none; }

/* ===== Sidebar ===== */
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 8px; }
.brand img { border-radius: 8px; object-fit: contain; }
.brand strong { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.brand span { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; }

.search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--muted); transition: border-color .15s; }
.search:focus-within { border-color: var(--primary); }
.search input { flex: 1; min-width: 0; border: 0; background: none; font: inherit; font-size: 14px; color: var(--ink); outline: none; }

.history { display: flex; flex-direction: column; gap: 2px; margin: 0 -4px; }
.logout-btn { margin-top: auto; flex: none; }
.history-group { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; }
.history-item {
  display: grid; grid-template-columns: 10px 1fr auto; align-items: center; gap: 10px;
  min-height: 44px; padding: 8px 10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--ink-2);
  transition: background-color .15s var(--ease);
}
.history-item:hover { background: var(--surface-2); }
.history-item[aria-current="page"] { background: var(--primary-soft); color: var(--ink); }
.history-item > span:nth-child(2) { min-width: 0; }
.history-item .t, .history-item .s { display: block; }
.history-item .t { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-item .s { font-size: 12px; color: var(--muted); }
.history-item .when { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.history-empty { font-size: 13px; color: var(--muted); padding: 12px 10px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.dot.live { background: var(--live); box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 25%, transparent); }
.dot.wait { background: var(--wait); }
.dot.failed { background: var(--danger); }

/* ===== Beranda ===== */
.home { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; padding-top: 24px; }
.eyebrow { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--primary-ink); background: var(--primary-soft); padding: 6px 12px; border-radius: 999px; }
.eyebrow .ic { width: 15px; height: 15px; }
.hero h1 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; margin: 16px 0 12px; max-width: 18ch; }
.hero p { font-size: 17px; color: var(--ink-2); max-width: 62ch; margin: 0; }

.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; counter-reset: step; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow-sm); }
.step h3 { font-size: 15px; margin-bottom: 4px; }
.step p { margin: 0; font-size: 14px; color: var(--muted); }
.step-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary-ink); flex: none; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.install { padding: 22px; }
.install-head { display: flex; gap: 14px; align-items: center; }
.install-head h2 { font-size: 18px; }
.install-head .grow { flex: 1; min-width: 0; }
.step-ic.ok { background: var(--live-soft); color: var(--live); }
.install-ok { border-color: color-mix(in srgb, var(--live) 30%, var(--line)); }
@media (max-width: 640px) { .install-head { flex-wrap: wrap; } .install-head .btn { width: 100%; } }
.install-head p { margin: 2px 0 0; font-size: 14px; }
.install-list { margin: 18px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 10px; color: var(--ink-2); }
.install-list li::marker { color: var(--muted); font-weight: 700; }
.kbd { display: inline-flex; align-items: center; gap: 6px; font: 600 13px ui-monospace, Consolas, monospace; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 6px; padding: 3px 8px; color: var(--ink); cursor: pointer; }
.kbd:hover { border-color: var(--primary); }
.kbd .ic { width: 14px; height: 14px; color: var(--muted); }
.tip { display: flex; gap: 10px; align-items: flex-start; margin: 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--wait-soft); color: var(--ink-2); font-size: 14px; }
.tip .ic { color: var(--wait); margin-top: 2px; }

/* ===== Detail ===== */
.detail { max-width: 860px; margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; margin-top: -12px; background: var(--bg); }
.topbar-actions { display: flex; gap: 8px; }

.status { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.status.live { background: var(--live-soft); border-color: transparent; color: var(--live); }
.status.live .status-dot { background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
.status.wait { background: var(--wait-soft); border-color: transparent; color: var(--wait); }
.status.wait .status-dot { background: var(--wait); }
.status.failed { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.status.failed .status-dot { background: var(--danger); }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--live) 50%, transparent); } 50% { box-shadow: 0 0 0 5px transparent; } }

.detail-head { padding: 20px 0 8px; }
.date { margin: 0 0 6px; font-size: 14px; color: var(--muted); font-weight: 500; }
.detail-head h1 { font-size: clamp(24px, 3.2vw, 32px); font-weight: 800; }
.meta { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 14px; color: var(--muted); }
.meta li { display: inline-flex; align-items: center; gap: 6px; }
.meta .ic { width: 16px; height: 16px; }
.meta a { text-decoration: none; }
.meta a:hover { color: var(--ink); text-decoration: underline; }

.alert { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 14px; }
.alert .ic { margin-top: 2px; }

.screen { margin: 16px 0 0; padding: 10px; }
.screen img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: contain; border-radius: var(--radius-sm); background: #000; }
.screen figcaption { font-size: 12px; margin-top: 8px; }

.tabs { display: flex; align-items: center; gap: 4px; margin: 24px 0 20px; border-bottom: 1px solid var(--line); }
.tabs [role="tab"] {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; margin-bottom: -1px;
  background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: 600 14px var(--font); cursor: pointer;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--primary); }
.tabs .ic { width: 16px; height: 16px; }
.badge { font-size: 12px; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; line-height: 20px; color: var(--muted); font-variant-numeric: tabular-nums; }
.screen-btn { margin-left: auto; }

/* ===== Notula ===== */
.notes-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); min-height: 20px; margin-bottom: 8px; }
.notes-status .ic { width: 15px; height: 15px; color: var(--primary); }
.notes { font-size: 16px; line-height: 1.75; color: var(--ink-2); max-width: 72ch; }
.notes h1, .notes h2 { font-size: 20px; font-weight: 800; color: var(--ink); margin: 32px 0 10px; }
.notes > :first-child { margin-top: 0; }
.notes h3 { font-size: 16px; color: var(--ink); margin: 20px 0 6px; }
.notes ul, .notes ol { padding-left: 22px; margin: 0 0 12px; }
.notes li { margin: 4px 0; }
.notes li::marker { color: var(--primary); }
.notes strong { color: var(--ink); }
.notes table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; line-height: 1.5; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin: 8px 0 16px; }
.notes th, .notes td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.notes tr:last-child td { border-bottom: 0; }
.notes th { background: var(--surface-2); font-weight: 700; color: var(--ink); font-size: 13px; }
.notes .updated { animation: glow 1.4s var(--ease); }
@keyframes glow { from { background: var(--primary-soft); } to { background: transparent; } }

/* ===== Kosong & skeleton ===== */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 48px 16px; color: var(--muted); }
.empty .step-ic { width: 48px; height: 48px; border-radius: 14px; }
.empty h3 { color: var(--ink); font-size: 16px; }
.empty p { margin: 0; max-width: 42ch; font-size: 14px; }
.skeleton { display: flex; flex-direction: column; gap: 12px; }
.skeleton span { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite linear; }
.skeleton span:nth-child(1) { width: 40%; height: 20px; }
.skeleton span:nth-child(2) { width: 92%; }
.skeleton span:nth-child(3) { width: 78%; }
.skeleton span:nth-child(4) { width: 85%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ===== Transkrip ===== */
.transcript { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.seg { display: grid; grid-template-columns: 36px 1fr; gap: 12px; animation: rise .25s var(--ease); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; }
.seg-head { display: flex; align-items: baseline; gap: 8px; }
.seg-name { font-weight: 700; font-size: 14px; color: var(--ink); }
.seg-time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.seg-text { margin: 2px 0 0; color: var(--ink-2); }
.seg.partial .seg-text::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--primary); vertical-align: middle; animation: blink 1s infinite; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
@keyframes blink { 50% { opacity: .2; } }

/* ===== Dialog ===== */
.dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink); box-shadow: 0 24px 64px rgb(0 0 0 / .2); }
.dialog::backdrop { background: rgb(0 0 0 / .45); }
.dialog[open] { animation: pop .2s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dialog form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dialog-head { display: flex; gap: 14px; align-items: flex-start; }
.dialog-head h2 { font-size: 18px; }
.dialog-head p { margin: 4px 0 0; font-size: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; font-weight: 600; }
.field em { font-style: normal; font-weight: 400; color: var(--muted); }
.field input { height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font: inherit; transition: border-color .15s; }
.field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 13px; }
.alert.warn { margin: 0; background: var(--wait-soft); color: var(--ink-2); }
.alert.warn .ic { color: var(--wait); }
.alert a { color: var(--primary-ink); font-weight: 600; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
@media (max-width: 480px) { .dialog-actions { flex-direction: column-reverse; } .dialog-actions .btn { width: 100%; } }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 999px;
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: var(--shadow-md);
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Responsif ===== */
@media (max-width: 900px) {
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow-md); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex; margin-bottom: 12px; }
  main { padding: 16px 16px 64px; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { width: 40px; padding: 0; }
}

/* ===== Asisten AI (bola + gelembung) ===== */
.ai-dock {
  position: fixed; right: 28px; bottom: 24px; z-index: 30;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
  pointer-events: none;
}
main:has(.ai-dock:not([hidden])) { padding-bottom: 200px; }
.ai-bubble {
  max-width: min(320px, calc(100vw - 48px)); padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  background: color-mix(in srgb, var(--ink) 90%, transparent); color: var(--bg);
  backdrop-filter: blur(8px); box-shadow: var(--shadow-md);
  opacity: 0; transform: translateY(8px) scale(.97); transform-origin: bottom right;
  transition: opacity .25s var(--ease), transform .25s var(--ease);
}
.ai-bubble.show { opacity: 1; transform: none; }
.ai-bubble-name { display: block; font-size: 11px; font-weight: 700; letter-spacing: .03em; opacity: .6; }
.ai-bubble-text { margin: 2px 0 0; font-size: 14px; font-weight: 600; line-height: 1.45; }

.ai-orb { position: relative; width: 112px; height: 112px; display: grid; place-items: center; }
.ai-orb::before {
  content: ""; position: absolute; inset: 10%; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--primary) 60%, transparent), transparent 70%);
  filter: blur(14px); animation: orb-glow 3s ease-in-out infinite;
}
.ai-orb canvas { position: relative; width: 100%; height: 100%; }
/* Cadangan kalau WebGL/three.js tidak tersedia */
.ai-orb-core {
  position: absolute; inset: 22%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd08a, #ef7d1a 45%, #b8430a 100%);
  animation: orb-breathe 3s ease-in-out infinite;
}
.ai-orb.webgl .ai-orb-core { display: none; }
.ai-orb-label {
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  white-space: nowrap; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--surface); color: var(--ink-2); border: 1px solid var(--line); box-shadow: var(--shadow-sm);
}
.ai-dock[data-mode="writing"] .ai-orb::before { animation-duration: 1.2s; }
.ai-dock[data-mode="waiting"] .ai-orb { opacity: .75; }
@keyframes orb-glow { 50% { transform: scale(1.18); opacity: .65; } }
@keyframes orb-breathe { 50% { transform: scale(1.06); } }

/* Efek mengetik notula */
.tw-wait { display: none !important; }
td.tw-wait, th.tw-wait { display: table-cell !important; visibility: hidden; }
.tw-caret {
  display: inline-block; width: 2px; height: 1.1em; margin-left: 2px; vertical-align: -.18em;
  background: var(--primary); border-radius: 1px; animation: caret-blink .8s steps(2) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }

@media (max-width: 640px) {
  .ai-dock { right: 16px; bottom: 16px; }
  .ai-orb { width: 84px; height: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
