/* Haba side panel — desain modern
   Font : Plus Jakarta Sans (dibundel di /fonts, lisensi OFL)
   Warna: indigo DSAI-RC (brand) + emas USK (aksen), latar krem terang; mode gelap otomatis */


@font-face {
  font-family: "Plus Jakarta Sans"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(fonts/PlusJakartaSans-latin.woff2) format("woff2");
  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: "Plus Jakarta Sans"; font-style: normal; font-weight: 400 800; font-display: swap;
  src: url(fonts/PlusJakartaSans-latin-ext.woff2) format("woff2");
  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-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: light dark;
  --brand: #4527b5;  --brand-600: #3a1fa0; --brand-700: #2a1478;
  --brand-50: #f1edff; --brand-100: #ded5ff;
  --accent: #f5b50a; --accent-600: #d99a00; --accent-50: #fff5d1;
  --grad: linear-gradient(135deg, #5b3bd8 0%, #3a1fa0 55%, #24107a 100%);
  --grad-gold: linear-gradient(135deg, #ffd84d 0%, #f5b50a 60%, #e09400 100%);
  --glow: rgba(58, 31, 160, .55);
  --ink: #1a1238; --ink-2: #463d66; --muted: #736b8f; --faint: #a39cba;
  --bg: #fbf8f1; --surface: #ffffff; --surface-2: #fdfaf4;
  --border: #ece6da; --border-2: #ddd4c4;
  --danger: #e5484d; --danger-50: #fdecec; --ok: #12a150;
  --shadow-sm: 0 1px 2px rgba(36, 16, 122, .06);
  --shadow: 0 1px 2px rgba(36, 16, 122, .05), 0 8px 24px -10px rgba(36, 16, 122, .16);
  --ring: 0 0 0 3px rgba(69, 39, 181, .28);
  --r-sm: 10px; --r: 14px; --r-lg: 20px;
  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px; letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #a897ff; --brand-600: #9581ff; --brand-700: #c9bdff;
    --brand-50: rgba(168, 151, 255, .12); --brand-100: rgba(168, 151, 255, .24);
    --accent: #ffcc33; --accent-600: #ffd659; --accent-50: rgba(255, 204, 51, .13);
    --grad: linear-gradient(135deg, #6b4ef0 0%, #4a2cc0 55%, #2f1a8c 100%);
    --glow: rgba(107, 78, 240, .55);
    --ink: #efecfa; --ink-2: #c9c3e0; --muted: #9a92b8; --faint: #6d6690;
    --bg: #100b22; --surface: #18122e; --surface-2: #140f28;
    --border: #2a2248; --border-2: #382f5e;
    --danger: #ff6b6f; --danger-50: rgba(255, 107, 111, .12); --ok: #34d399;
    --shadow-sm: none; --shadow: 0 8px 24px -10px rgba(0, 0, 0, .6);
    --ring: 0 0 0 3px rgba(168, 151, 255, .3);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
/* font dipasang di html & body: Chrome menyisipkan font-family bawaan ke <body> halaman extension */
html, body { font-family: var(--font); }
body { margin: 0; background: var(--bg); color: var(--ink); min-width: 300px; }
svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
button { font: inherit; cursor: pointer; color: inherit; }
button:focus-visible, select:focus-visible, input:focus-visible, [contenteditable]:focus-visible { outline: none; box-shadow: var(--ring); }
.hidden { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- header ---------- */
.bar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, var(--brand), var(--accent) 70%, transparent); opacity: .7; }
.bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 10px; height: 58px; padding: 0 8px 0 14px;
  background: color-mix(in srgb, var(--surface) 82%, transparent); backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border); }
.logo { width: 34px; height: 34px; display: block; filter: drop-shadow(0 3px 6px rgba(224, 148, 0, .35)); }
.brand { display: flex; flex-direction: column; line-height: 1.1; }
.title { font-size: 17px; font-weight: 800; letter-spacing: -.02em; }
.sub { color: var(--muted); font-size: 11.5px; font-weight: 500; }
.icon-btn { width: 36px; height: 36px; border: 0; border-radius: 11px; background: transparent; color: var(--muted);
  display: grid; place-items: center; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--brand-50); color: var(--brand-600); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- layout ---------- */
main { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); margin: 2px 2px -4px; }

/* ---------- bahasa (segmented) ---------- */
.seg { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.seg::before { content: ""; position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 10px;
  background: var(--grad); box-shadow: 0 4px 12px -4px var(--glow); transition: transform .28s cubic-bezier(.3, .7, .2, 1); }
.seg:has(.seg-btn[data-lang="gayo"].active)::before { transform: translateX(100%); }
.seg-btn { position: relative; z-index: 1; border: 0; background: transparent; padding: 9px 0; font-size: 13.5px; font-weight: 650;
  color: var(--muted); border-radius: 10px; transition: color .2s; }
.seg-btn.active { color: #fff; }
.seg-btn:not(.active):hover { color: var(--ink); }

/* ---------- sumber ---------- */
.sources { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.src { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px 10px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600;
  box-shadow: var(--shadow-sm); transition: border-color .15s, background .15s, color .15s, transform .15s; }
.src .ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2);
  border: 1px solid var(--border); transition: inherit; }
.src svg { width: 18px; height: 18px; }
.src:hover { border-color: var(--border-2); color: var(--ink); transform: translateY(-1px); }
.src.active { border-color: var(--brand); color: var(--brand-700); background: var(--brand-50); }
.src.active .ic { background: var(--grad); color: #fff; border-color: transparent; }

/* ---------- kartu input ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.input-card { position: relative; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 24px 14px 14px; }
.input-card::before { content: ""; position: absolute; inset: -40% -20% auto; height: 180px; pointer-events: none;
  background: radial-gradient(closest-side, var(--brand-100), transparent 70%); opacity: .8; }
.input-card > * { position: relative; }
.rec { width: 78px; height: 78px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; display: grid; place-items: center;
  box-shadow: 0 10px 24px -8px var(--glow), inset 0 1px 0 rgba(255, 255, 255, .25);
  transition: transform .18s, box-shadow .18s, filter .18s; }
.rec svg { width: 32px; height: 32px; }
.rec:hover { transform: translateY(-2px) scale(1.03); }
.rec:active { transform: scale(.97); }
.rec:disabled { background: var(--border-2); box-shadow: none; cursor: default; transform: none; color: var(--surface); }
.rec.on { background: linear-gradient(135deg, #ff7a7e, #e5484d 60%, #c8343a); box-shadow: 0 10px 24px -8px rgba(229, 72, 77, .7); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .45); } 70% { box-shadow: 0 0 0 18px rgba(229, 72, 77, 0); } 100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); } }
.hint { color: var(--ink-2); font-size: 13px; font-weight: 500; text-align: center; }
#level { width: 100%; max-width: 280px; height: 32px; }
.vad { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px 4px 8px; border-radius: 999px; background: var(--surface-2);
  border: 1px solid var(--border); color: var(--muted); font-size: 11.5px; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); transition: background .15s, box-shadow .15s; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }

/* ---------- status ---------- */
.status { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--muted); padding: 0 4px; }
.status #statusText { display: flex; align-items: center; gap: 7px; }
.status #statusText::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--accent-50); flex: none; }
.status.err { color: var(--danger); }
.status.err #statusText::before { background: var(--danger); }
.progress { height: 5px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--grad-gold); border-radius: 99px; transition: width .2s; }

/* ---------- kartu hasil ---------- */
.out-card { display: flex; flex-direction: column; min-height: 240px; overflow: hidden; }
.out-head { display: flex; align-items: center; gap: 8px; padding: 12px 14px 0; }
.out-head .t { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.output { flex: 1; padding: 8px 16px 4px; font-size: 16.5px; line-height: 1.65; font-weight: 500; color: var(--ink);
  outline: none; white-space: pre-wrap; word-wrap: break-word; min-height: 1.6em; border-radius: 8px; }
.output:focus-visible { box-shadow: none; }
.output:empty::before { content: attr(data-placeholder); color: var(--faint); font-weight: 400; }
.output .low { text-decoration: underline wavy var(--accent); text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
.partial { padding: 0 16px; font-size: 16.5px; line-height: 1.65; color: var(--faint); font-style: italic; }
.meta { padding: 6px 14px 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 11px; font-weight: 600; color: var(--brand-700); padding: 3px 9px; background: var(--brand-50); border-radius: 999px; }
.credit { margin-top: 6px; font-size: 11.5px; color: var(--muted); }
.credit b { color: var(--brand-700); font-weight: 700; }
.tools { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--border); background: var(--surface-2); }
.text-btn { border: 1px solid var(--border); background: var(--surface); color: var(--ink-2); height: 32px; padding: 0 11px; border-radius: 10px;
  font-weight: 650; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; transition: border-color .15s, color .15s; }
.text-btn svg { width: 16px; height: 16px; }
.text-btn:hover { border-color: var(--brand); color: var(--brand-600); }
.tools .icon-btn { width: 32px; height: 32px; border-radius: 10px; }
.tools .icon-btn.danger:hover { background: var(--danger-50); color: var(--danger); }

/* ---------- halaman pengaturan & riwayat ---------- */
.page { padding: 6px 14px 18px; }
.page h2 { display: flex; align-items: center; gap: 6px; font-size: 17px; font-weight: 800; letter-spacing: -.02em; margin: 8px 0 14px -6px; }
.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; font-weight: 650; font-size: 13px; }
.group .field:last-child { margin-bottom: 0; }
.field select, .field input { font: inherit; font-size: 13.5px; font-weight: 500; color: var(--ink); padding: 10px 12px; border: 1px solid var(--border-2);
  border-radius: var(--r-sm); background: var(--surface-2); transition: border-color .15s, box-shadow .15s; }
.field select { appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%236b7b78'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 20px; }
.field select:focus, .field input:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.field small { color: var(--muted); font-weight: 450; font-size: 12px; line-height: 1.5; }
.row-btns { display: flex; gap: 8px; margin: 4px 0 14px; flex-wrap: wrap; }
.btn { border: 1px solid var(--border-2); background: var(--surface); color: var(--ink-2); height: 40px; padding: 0 18px; border-radius: 12px;
  font-weight: 700; font-size: 13px; transition: filter .15s, border-color .15s, transform .1s; }
.btn:hover { border-color: var(--brand); color: var(--brand-600); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 6px 16px -6px var(--glow); }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.about { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: var(--r); background: var(--brand-50); color: var(--ink-2); font-size: 12px; line-height: 1.5; }
.about svg { width: 18px; height: 18px; color: var(--brand-600); margin-top: 1px; }
.links { display: flex; gap: 14px; margin-top: 10px; font-size: 12px; font-weight: 600; }
.links a { color: var(--brand-600); text-decoration: none; }
.links a:hover { text-decoration: underline; }

.history { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 8px; }
.history li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 12px 14px; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: border-color .15s, transform .15s; }
.history li:hover { border-color: var(--brand); transform: translateY(-1px); }
.history li.muted { cursor: default; text-align: center; padding: 28px 14px; border-style: dashed; box-shadow: none; }
.history li.muted:hover { border-color: var(--border); transform: none; }
.history .h-meta { font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.history .h-text { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.5; font-weight: 500; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(120px); background: var(--ink); color: var(--surface);
  padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 600; transition: transform .3s cubic-bezier(.3, .7, .2, 1);
  max-width: 90%; text-align: center; box-shadow: 0 12px 30px -10px rgba(0, 0, 0, .4); z-index: 20; }
.toast.show { transform: translateX(-50%) translateY(0); }

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