*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    min-width: 0; /* KUNCI UTAMA: Mencegah flex/grid child meluap keluar layar */
}

:root {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --success: #16a34a;
    --success-hover: #15803d;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --slate-900: #0f172a;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;
}

html {
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden; /* Pastikan tidak ada scroll horizontal */
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #f8fafc;
    background-image: 
        radial-gradient(at 0% 0%, rgba(224, 242, 254, 0.6) 0, transparent 50%),
        radial-gradient(at 100% 0%, rgba(238, 242, 255, 0.6) 0, transparent 50%),
        radial-gradient(at 50% 100%, rgba(240, 253, 244, 0.5) 0, transparent 50%);
    background-attachment: fixed;
    color: var(--slate-800);
    line-height: 1.5;
    padding-bottom: 48px;
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* Gambar & Media Aman Responsif */
img, video, canvas, svg {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Header & Navigasi */
.top-nav {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--slate-200);
    padding: 10px 14px;
    width: 100%;
}

.nav-inner {
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
}

.nav-brand-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 1;
}

.nav-brand {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--slate-900);
    text-decoration: none;
    white-space: nowrap;
}

/* Nav Dropdown Artikel */
.nav-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.nav-dropdown-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    padding: 5px 10px;
    border-radius: 9px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--slate-700);
    cursor: pointer;
    white-space: nowrap;
}

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: min(290px, calc(100vw - 28px));
    max-height: 360px;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid var(--slate-200);
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15);
    padding: 6px;
    z-index: 60;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: flex;
    flex-direction: column;
}

.nav-dropdown-item {
    display: block;
    padding: 8px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--slate-700);
    text-decoration: none;
    border-radius: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-dropdown-item:hover {
    background: var(--slate-100);
    color: var(--primary);
}

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

.lang-switch-box {
    display: inline-flex;
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    border-radius: 999px;
    padding: 2px;
}

.lang-btn {
    border: none;
    background: transparent;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--slate-600);
    cursor: pointer;
}

.lang-btn.active {
    background: var(--primary);
    color: #ffffff;
}

/* Container */
.container {
    max-width: 1120px;
    width: 100%;
    margin: 14px auto 0;
    padding: 0 12px; /* Dikecilkan agar ruang konten Galaxy Flip lebih lega */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Banner */
.banner-card {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: 16px;
    padding: 6px;
    width: 100%;
}

.banner-wrapper {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    background: #06152d;
}

.banner-img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Hero Caption */
.hero-caption {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: 14px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.hero-title-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.hero-badge {
    background: var(--primary-light);
    color: var(--primary-hover);
    border: 1px solid #bae6fd;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
}

/* Grid & Cards */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
    width: 100%;
}

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

.card {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 3px 16px -2px rgba(15, 23, 42, 0.05);
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
}

@media (max-width: 480px) {
    .card {
        padding: 12px;
    }
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--slate-100);
}

.card-title {
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--slate-900);
    display: flex;
    align-items: center;
    gap: 6px;
}

.step-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: var(--primary-light);
    color: var(--primary-hover);
    border: 1px solid #bae6fd;
    font-size: 0.78rem;
    font-weight: 800;
    flex-shrink: 0;
}

.card-tag {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--slate-600);
    background: var(--slate-100);
    border: 1px solid var(--slate-200);
    padding: 2px 8px;
    border-radius: 999px;
}

/* Control Group & Inputs */
.control-group {
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.control-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--slate-800);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

select, textarea, input[type="text"], input[type="password"], input[type="email"] {
    width: 100%;
    max-width: 100%;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--slate-200);
    background: #ffffff;
    font-size: 0.85rem;
    color: var(--slate-800);
    outline: none;
}

textarea {
    resize: vertical;
}

/* Input File Responsif (Mencegah overflow di mobile) */
.file-input-custom {
    width: 100%;
    max-width: 100%;
    font-size: 0.78rem;
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: 8px;
    padding: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Baris Input PDF & STT */
.responsive-flex-row {
    display: flex;
    gap: 8px;
    width: 100%;
}

@media (max-width: 440px) {
    .responsive-flex-row {
        flex-direction: column;
    }
}

/* Tombol */
.btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
}

@media (max-width: 480px) {
    .btn-row {
        grid-template-columns: 1fr;
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 700;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    max-width: 100%;
    white-space: normal; /* Izinkan teks melipat jika layar sempit */
}

.btn-primary { background: #2563eb; color: #ffffff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-success { background: var(--success); color: #ffffff; }
.btn-warning { background: #ea580c; color: #ffffff; }
.btn-secondary { background: var(--slate-100); color: var(--slate-800); border-color: var(--slate-200); }
.btn-outline { background: var(--primary-light); color: var(--primary-hover); border-color: #bae6fd; }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-dark { background: var(--slate-900); color: #ffffff; }
.btn-sm { padding: 5px 10px; font-size: 0.75rem; border-radius: 6px; }

/* Kamera & Preview */
.video-box {
    position: relative;
    width: 100%;
    height: 200px;
    background: #0f172a;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.braille-guide-box {
    position: absolute;
    width: 86%;
    height: 65%;
    border: 2px dashed #38bdf8;
    background: rgba(56, 189, 248, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 6px;
    pointer-events: none;
}

.braille-guide-box span {
    background: rgba(255, 255, 255, 0.95);
    color: var(--slate-900);
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    text-align: center;
    max-width: 90%;
}

.preview-box {
    width: 100%;
    height: 160px;
    background: var(--slate-50);
    border: 2px dashed var(--slate-200);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 0.8rem;
    color: var(--slate-500);
    font-weight: 600;
    padding: 6px;
    text-align: center;
}

/* Hasil Pembacaan */
.result-box {
    background: linear-gradient(180deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.kata-utama {
    font-size: clamp(1.2rem, 4vw, 1.8rem);
    font-weight: 800;
    color: var(--slate-900);
    word-break: break-word;
    overflow-wrap: anywhere;
}

.pola-biner {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    background: #ffffff;
    border: 1px solid var(--slate-200);
    padding: 6px 10px;
    border-radius: 6px;
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Riwayat & Accordion */
.history-accordion-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.history-accordion-item {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    overflow: hidden;
}

.history-accordion-header {
    list-style: none;
    cursor: pointer;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.history-accordion-body {
    padding: 12px;
    background: var(--slate-50);
    border-top: 1px solid var(--slate-200);
}

.history-grid-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 600px) {
    .history-grid-info { grid-template-columns: 1fr; }
}

.history-full-text {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: 6px;
    padding: 8px;
    font-size: 0.8rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 150px;
    overflow-y: auto;
}

/* Katalog Artikel Grid */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: 14px;
    width: 100%;
}

.article-item-card {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.article-thumb {
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.article-item-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 6px;
}

/* Modal Dialog Responsif */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}

.modal-card {
    background: #ffffff;
    border: 1px solid var(--slate-200);
    border-radius: 16px;
    width: 100%;
    max-width: 380px;
    padding: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.modal-tabs {
    display: flex;
    background: var(--slate-100);
    padding: 2px;
    border-radius: 8px;
    margin-bottom: 12px;
    gap: 2px;
}

.auth-tab-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--slate-600);
    border-radius: 6px;
    cursor: pointer;
}

.auth-tab-btn.active {
    background: #ffffff;
    color: var(--slate-900);
}