@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

:root {
    color-scheme: light dark;

    /* Core Light Tokens (WCAG AA verified) */
    --bg-page: #fcf8fa;
    --bg-surface: #ffffff;
    --bg-subtle: #f8eef3;
    --bg-input: #ffffff;
    --bg-hover: #fdf2f8;

    --text-primary: #23151d;
    --text-muted: #634a58;

    --border-subtle: #ebd6e1;
    --border-strong: #a96e89;

    --accent: #be185d;
    --accent-hover: #9d174d;
    --accent-text-on-solid: #ffffff;
    --accent-soft: #fce7f3;
    --accent-soft-text: #9d174d;

    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --danger-text: #b91c1c;

    --success-bg: #fdf2f8;
    --success-border: #f5c2db;
    --success-text: #9d174d;

    --ok-bg: #dcfce7;
    --ok-text: #15803d;
    --chart-decode: #475569;

    --focus-ring: #be185d;
    --shadow-card: 0 2px 10px rgba(35, 21, 29, 0.04);
    --shadow-elevated: 0 12px 32px rgba(35, 21, 29, 0.14);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-pill: 999px;

    --sidebar-width: 256px;
    --topbar-height: 68px;

    accent-color: var(--accent);
}

/* Explicit Dark Override or System Dark Preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not(:has(> head > meta[name="color-scheme"][content="light"])) {
        color-scheme: dark;
        --bg-page: #140d12;
        --bg-surface: #1e141b;
        --bg-subtle: #2a1c26;
        --bg-input: #170f15;
        --bg-hover: #33202e;

        --text-primary: #f9eef4;
        --text-muted: #c9b2bf;

        --border-subtle: #442b3c;
        --border-strong: #8f627a;

        --accent: #f472b6;
        --accent-hover: #f9a8d4;
        --accent-text-on-solid: #1a0a12;
        --accent-soft: #3d1b30;
        --accent-soft-text: #fbcfe8;

        --danger-bg: #3b1219;
        --danger-border: #7f1d1d;
        --danger-text: #fca5a5;

        --success-bg: #311728;
        --success-border: #6d284d;
        --success-text: #fbcfe8;

        --ok-bg: #143322;
        --ok-text: #86efac;
        --chart-decode: #94a3b8;

        --focus-ring: #f9a8d4;
        --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.25);
        --shadow-elevated: 0 16px 40px rgba(0, 0, 0, 0.5);
    }
}

:root[data-theme="dark"],
:root:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
    --bg-page: #140d12;
    --bg-surface: #1e141b;
    --bg-subtle: #2a1c26;
    --bg-input: #170f15;
    --bg-hover: #33202e;

    --text-primary: #f9eef4;
    --text-muted: #c9b2bf;

    --border-subtle: #442b3c;
    --border-strong: #8f627a;

    --accent: #f472b6;
    --accent-hover: #f9a8d4;
    --accent-text-on-solid: #1a0a12;
    --accent-soft: #3d1b30;
    --accent-soft-text: #fbcfe8;

    --danger-bg: #3b1219;
    --danger-border: #7f1d1d;
    --danger-text: #fca5a5;

    --success-bg: #311728;
    --success-border: #6d284d;
    --success-text: #fbcfe8;

    --ok-bg: #143322;
    --ok-text: #86efac;
    --chart-decode: #94a3b8;

    --focus-ring: #f9a8d4;
    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.25);
    --shadow-elevated: 0 16px 40px rgba(0, 0, 0, 0.5);
}

:root[data-theme="light"],
:root:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Poppins', ui-sans-serif, system-ui, -apple-system, sans-serif;
    color: var(--text-primary);
    background: var(--bg-page);
    line-height: 1.55;
    overflow-x: hidden;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

button,
input,
textarea,
select {
    font: inherit;
    color: inherit;
}

img,
svg,
video,
canvas {
    display: block;
    max-width: 100%;
}

/* Base interaction affordances (R-32, R-39) */
a[href],
button:not(:disabled),
summary,
select,
label[for],
input[type="checkbox"]:not(:disabled),
input[type="radio"]:not(:disabled),
input[type="range"]:not(:disabled),
[role="button"]:not([aria-disabled="true"]) {
    cursor: pointer;
}

:disabled,
[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.6;
}

:where(a[href], button, input, textarea, select, summary, [tabindex]):focus-visible {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.skip-link {
    position: fixed;
    top: -100px;
    left: 16px;
    z-index: 100;
    background: var(--accent);
    color: var(--accent-text-on-solid);
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.875rem;
}

.skip-link:focus {
    top: 16px;
}

/* App Shell */
.app-layout {
    display: flex;
    min-height: 100dvh;
}

.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    inset: 0 auto 0 0;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-subtle);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 40;
    overflow-y: auto;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    text-decoration: none;
    padding: 4px;
    border-radius: var(--radius-md);
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 11px;
}

.brand-text strong {
    display: block;
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.2;
}

.brand-text small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.drawer-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-subtle);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.nav-group-label {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0 10px;
    margin-bottom: 8px;
}

.navigation ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.navigation a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
    position: relative;
}

.navigation a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.navigation a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.navigation a.active {
    background: var(--accent-soft);
    color: var(--accent-soft-text);
    font-weight: 600;
}

.navigation a.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 10px;
    bottom: 10px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
}

.sidebar-bottom {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 4px;
}

.avatar {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: var(--radius-pill);
    background: var(--accent-soft);
    color: var(--accent-soft-text);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.user-meta {
    min-width: 0;
}

.user-meta strong {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-meta small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.logout-button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.logout-button:hover {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

.logout-button svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(16, 8, 13, 0.55);
    z-index: 35;
}

.sidebar-backdrop.is-visible {
    display: block;
}

/* Main Shell */
.main-shell {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 25;
    min-height: var(--topbar-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 12px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.menu-trigger {
    display: none;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 600;
    flex-shrink: 0;
}

.menu-trigger svg {
    width: 20px;
    height: 20px;
}

.topbar-title h1 {
    font-size: clamp(1.05rem, 1.8vw, 1.3rem);
    font-weight: 700;
    line-height: 1.25;
    color: var(--text-primary);
}

.topbar-title p {
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.3;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Theme Toggle Button (2-state per modern-web-guidance) */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.theme-toggle-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Show moon ("Mode Gelap") in light mode, sun ("Mode Terang") in dark mode */
.theme-toggle-btn .theme-opt-light {
    display: none;
}

.theme-toggle-btn .theme-opt-dark {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-toggle-btn .theme-opt-dark {
        display: none;
    }
    :root:not([data-theme="light"]):not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-toggle-btn .theme-opt-light {
        display: inline-flex;
        align-items: center;
        gap: 8px;
    }
}

:root[data-theme="dark"] .theme-toggle-btn .theme-opt-dark,
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-toggle-btn .theme-opt-dark {
    display: none;
}

:root[data-theme="dark"] .theme-toggle-btn .theme-opt-light,
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-toggle-btn .theme-opt-light {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

:root[data-theme="light"] .theme-toggle-btn .theme-opt-dark,
:root:has(> head > meta[name="color-scheme"][content="light"]) .theme-toggle-btn .theme-opt-dark {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

:root[data-theme="light"] .theme-toggle-btn .theme-opt-light,
:root:has(> head > meta[name="color-scheme"][content="light"]) .theme-toggle-btn .theme-opt-light {
    display: none;
}

.page-content {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px 28px 36px;
}

.footer {
    border-top: 1px solid var(--border-subtle);
    padding: 16px 28px;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: center;
}

/* Surfaces & Typography */
.surface-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-card);
}

.surface-card + .surface-card {
    margin-top: 20px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.muted-copy {
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.6;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-variant-numeric: tabular-nums;
}

.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.btn:hover {
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
}

.btn-primary {
    background: var(--accent);
    color: var(--accent-text-on-solid);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.btn-secondary[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent-soft-text);
}

.btn-danger-ghost {
    background: transparent;
    border-color: var(--danger-border);
    color: var(--danger-text);
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.82rem;
}

.btn-danger-ghost:hover {
    background: var(--danger-bg);
}

.btn-full {
    width: 100%;
}

/* Forms */
.field-group {
    margin-top: 16px;
}

.field-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.field-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.input-control,
.textarea-control {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.92rem;
    transition: border-color 0.15s ease;
}

.input-control::placeholder,
.textarea-control::placeholder {
    color: var(--text-muted);
    opacity: 0.85;
}

.input-control:focus,
.textarea-control:focus {
    border-color: var(--accent);
}

.textarea-control {
    resize: vertical;
    min-height: 140px;
}

.password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.password-wrap .input-control {
    padding-right: 92px;
}

.password-toggle {
    position: absolute;
    right: 6px;
    min-height: 36px;
    padding: 4px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    background: var(--bg-subtle);
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 600;
}

.password-toggle:hover {
    border-color: var(--accent);
}

/* Dropzone / File Upload */
.dropzone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 20px 16px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    text-align: center;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover,
.dropzone.is-dragover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.dropzone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.dropzone-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dropzone-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

/* Inline Camera Capture Panel */
.camera-panel {
    margin-top: 12px;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
}

.camera-viewfinder {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
}

.camera-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

/* Accessible Tabs (modern-web-guidance tabs pattern) */
.tablist {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 14px;
    overflow-x: auto;
}

.tab-btn {
    position: relative;
    min-height: 44px;
    padding: 10px 16px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn[aria-selected="true"] {
    color: var(--accent);
}

.tab-btn[aria-selected="true"]::after {
    content: "";
    position: absolute;
    inset: auto 0 0;
    border-block-end: 3px solid var(--accent);
}

/* Security Options & Multimedia Cards */
.options-stack {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.option-check-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    min-height: 44px;
}

.option-check-card input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
}

.option-check-card strong {
    display: block;
    font-size: 0.86rem;
    font-weight: 600;
    color: var(--text-primary);
}

.option-check-card small {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.45;
    margin-top: 2px;
}

.option-check-card.is-disabled {
    opacity: 0.55;
}

.audio-player-box {
    width: 100%;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    margin-top: 10px;
}

.audio-player-box audio {
    width: 100%;
    display: block;
}

.file-payload-card {
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    margin-top: 12px;
}

.file-payload-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

/* Dashboard Analytics & Charts */
.analytics-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin: 8px 0 12px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
}

.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

.chart-svg-wrap {
    width: 100%;
    overflow-x: auto;
}

.chart-svg {
    width: 100%;
    height: auto;
    min-width: 320px;
}

.decode-split-bar {
    display: flex;
    width: 100%;
    height: 14px;
    border-radius: var(--radius-pill);
    overflow: hidden;
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    margin: 14px 0;
}

.decode-split-ok {
    background: var(--ok-text);
    height: 100%;
}

.decode-split-fail {
    background: var(--danger-text);
    height: 100%;
}

.decode-kpi-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.capacity-list {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.capacity-item {
    display: grid;
    gap: 6px;
}

.capacity-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.84rem;
}

.capacity-track {
    width: 100%;
    height: 10px;
    border-radius: var(--radius-pill);
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

.capacity-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-pill);
    min-width: 4px;
}

.badge-ok {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.badge-fail {
    background: var(--danger-bg);
    color: var(--danger-text);
}

/* Search & Admin Toolbar */
.search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.search-row .input-control {
    flex: 1;
    min-width: 220px;
}

/* Guide TOC & Sections */
.toc-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin-top: 14px;
}

.toc-list a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-subtle);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 600;
}

.toc-list a:hover {
    border-color: var(--accent);
    color: var(--accent);
    text-decoration: none;
}

.guide-section {
    scroll-margin-top: calc(var(--topbar-height) + 16px);
}

.guide-prose {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.75;
    display: grid;
    gap: 10px;
    margin-top: 10px;
}

.guide-formula {
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    font-size: 0.84rem;
    color: var(--text-primary);
    overflow-x: auto;
}

@media (max-width: 960px) {
    .analytics-grid {
        grid-template-columns: 1fr;
    }
}

/* Alerts & Banners (R-25, R-27, Color-only feedback avoided via icon + text) */
.banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    margin-bottom: 18px;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
}

.banner svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.banner-error {
    background: var(--danger-bg);
    border-color: var(--danger-border);
    color: var(--danger-text);
}

.banner-success {
    background: var(--success-bg);
    border-color: var(--success-border);
    color: var(--success-text);
}

.banner-info {
    background: var(--bg-subtle);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.inline-feedback {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    display: none;
}

.inline-feedback.is-visible {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Badges & Status */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--accent-soft-text);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge-neutral {
    background: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}

/* Dashboard */
.dashboard-banner {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 26px 28px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-card);
}

.dashboard-banner h2 {
    font-size: clamp(1.25rem, 2.2vw, 1.65rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.dashboard-banner p {
    color: var(--text-muted);
    max-width: 560px;
    font-size: 0.92rem;
}

.dashboard-cta-group {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 26px;
}

.stats-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
}

.stat-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1.2;
    margin: 10px 0 4px;
    font-variant-numeric: tabular-nums;
}

.stat-sub {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.section-heading {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.section-heading h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

/* Tables */
.table-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

caption {
    text-align: left;
    padding: 14px 16px 0;
    color: var(--text-muted);
    font-size: 0.82rem;
}

th,
td {
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: top;
}

th {
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: none;
}

.empty-state {
    padding: 36px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state p {
    margin-bottom: 14px;
}

/* Pagination (fixes unstyled Laravel Tailwind pagination) */
.pagination {
    margin-top: 18px;
}

.pagination nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.pagination nav > div:first-child {
    display: flex;
    gap: 8px;
}

.pagination nav > div:last-child {
    display: none;
}

.pagination svg {
    width: 18px;
    height: 18px;
}

.pagination a,
.pagination span[aria-current="page"] > span,
.pagination span[aria-disabled="true"] > span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
}

.pagination span[aria-current="page"] > span {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text-on-solid);
}

.pagination span[aria-disabled="true"] > span {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (min-width: 720px) {
    .pagination nav > div:first-child {
        display: none;
    }
    .pagination nav > div:last-child {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 12px;
    }
    .pagination nav > div:last-child > div:last-child > span {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }
}

/* Studio / Workbench 2-column layout (Encode & Decode) */
.workbench-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
    gap: 20px;
    align-items: start;
}

.workbench-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.tools-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.tools-row .btn {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 0.82rem;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.metric-grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-box {
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.metric-box small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.metric-box strong {
    display: block;
    color: var(--accent);
    font-size: 1.05rem;
    font-weight: 700;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.preview-frame {
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 10px;
}

.preview-frame figcaption {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.preview-frame img {
    width: 100%;
    height: 190px;
    object-fit: contain;
    background: var(--bg-page);
    border-radius: var(--radius-sm);
}

.compare-box {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-page);
    height: 260px;
    margin-top: 10px;
}

.compare-box img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.compare-box .compare-top {
    clip-path: inset(0 50% 0 0);
}

.range-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.range-row input[type="range"] {
    flex: 1;
    min-height: 36px;
}

.qr-panel {
    margin-top: 16px;
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-subtle);
    text-align: center;
}

.qr-frame {
    display: inline-block;
    background: #ffffff;
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid #ebd6e1;
}

.qr-frame img {
    width: 200px;
    height: 200px;
    object-fit: contain;
}

.analysis-block {
    margin-top: 22px;
    padding-top: 18px;
    border-top: 1px solid var(--border-subtle);
}

.analysis-block h3 {
    font-size: 0.98rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.diff-canvas {
    width: 100%;
    max-height: 280px;
    object-fit: contain;
    background: var(--bg-input);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-top: 10px;
}

.binary-readout {
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    font-size: 0.84rem;
    line-height: 1.7;
    overflow-wrap: anywhere;
    margin-top: 8px;
}

.notes-list {
    padding-left: 18px;
    color: var(--text-muted);
    font-size: 0.875rem;
    line-height: 1.85;
}

/* Panduan LSB Simulator */
.rgb-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.rgb-channel-card {
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.rgb-swatch-row {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 14px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    border: 1px solid var(--border-subtle);
}

.rgb-swatch {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    flex-shrink: 0;
}

/* Auth & Share Standalone Pages */
.standalone-page {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px 16px;
    background: var(--bg-page);
}

.standalone-topbar {
    width: 100%;
    max-width: 440px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    box-shadow: var(--shadow-elevated);
}

.auth-header {
    text-align: center;
    margin-bottom: 22px;
}

.auth-header .brand-mark {
    margin: 0 auto 12px;
    width: 48px;
    height: 48px;
}

.auth-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.86rem;
    margin-top: 4px;
}

.remember-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    font-size: 0.88rem;
    color: var(--text-primary);
    min-height: 36px;
}

.remember-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.auth-footer {
    margin-top: 20px;
    text-align: center;
    font-size: 0.86rem;
    color: var(--text-muted);
}

.auth-footer a {
    font-weight: 600;
}

/* Responsive Breakpoints (3-state reflow: desktop, tablet/small-laptop, mobile) */
@media (max-width: 1080px) {
    .workbench-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 960px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: var(--shadow-elevated);
        visibility: hidden;
    }

    .sidebar.is-open {
        transform: translateX(0);
        visibility: visible;
    }

    .drawer-close-btn {
        display: inline-flex;
    }

    .main-shell {
        margin-left: 0;
        width: 100%;
    }

    .menu-trigger {
        display: inline-flex;
    }

    .stats-grid,
    .stats-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar {
        padding: 12px 18px;
    }

    .page-content {
        padding: 20px 18px 32px;
    }
}

@media (max-width: 620px) {
    .stats-grid,
    .stats-grid-4,
    .preview-grid,
    .rgb-grid {
        grid-template-columns: 1fr;
    }

    .metric-grid,
    .metric-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar {
        padding: 10px 14px;
    }

    .topbar-title p {
        display: none;
    }

    .theme-toggle-btn .theme-label-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .page-content {
        padding: 16px 14px 28px;
    }

    .surface-card,
    .dashboard-banner,
    .auth-card {
        padding: 18px 16px;
    }
}

/* Responsive table cards for narrow screens on History */
@media (max-width: 760px) {
    .table-responsive-cards thead {
        display: none;
    }

    .table-responsive-cards table,
    .table-responsive-cards tbody,
    .table-responsive-cards tr,
    .table-responsive-cards td {
        display: block;
        width: 100%;
    }

    .table-responsive-cards tr {
        padding: 14px 16px;
        border-bottom: 1px solid var(--border-subtle);
    }

    .table-responsive-cards tr:last-child {
        border-bottom: none;
    }

    .table-responsive-cards td {
        padding: 4px 0;
        border-bottom: none;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
    }

    .table-responsive-cards td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
        font-size: 0.78rem;
        flex-shrink: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition-duration: 0.001ms !important;
        animation-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}
