html, body {
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background: radial-gradient(circle at top right, rgba(251, 113, 133, 0.18), transparent 26%), radial-gradient(circle at top left, rgba(244, 63, 94, 0.20), transparent 24%), linear-gradient(180deg, #081120 0, #121f38 7rem, #f6f1f3 26rem, #f5eff1 100%);
    color: #0f172a;
}

a {
    color: #c81e4f;
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

.page {
    min-height: 100vh;
}

.app-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(16px);
    background: rgba(7, 17, 31, 0.86);
    border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.7rem 0.9rem;
    display: flex;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 55;
}


.menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

.brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    text-decoration: none;
}

.brand-badge {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    background: linear-gradient(135deg, #ef4444, #be123c);
    box-shadow: 0 10px 24px rgba(225, 29, 72, 0.35);
}

.brand-copy {
    display: grid;
    gap: 0.05rem;
}

    .brand-copy strong {
        font-size: 1rem;
    }

    .brand-copy span {
        color: rgba(255, 255, 255, 0.72);
        font-size: 0.75rem;
    }

.topnav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: center;
}

    .topnav a {
        color: #fff;
        padding: 0.6rem 0.9rem;
        border-radius: 999px;
        background: rgba(255, 255, 255, 0.08);
        font-weight: 600;
    }

        .topnav a:hover {
            text-decoration: none;
            background: rgba(255, 255, 255, 0.16);
        }

.topnav-lang {
    position: relative;
}

.topnav-lang-trigger,
.topnav-lang-item {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    border-radius: 0.9rem;
    padding: 0.48rem 0.72rem;
    border: 1px solid rgba(56, 189, 248, 0.5);
    background: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    box-shadow: none;
    font-weight: 700;
}

.topnav-lang-trigger {
    cursor: pointer;
}

.topnav-lang-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    z-index: 60;
    min-width: 12rem;
    border-radius: 0.9rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(7, 17, 31, 0.98);
    padding: 0.45rem;
    display: grid;
    gap: 0.4rem;
    box-shadow: 0 14px 30px rgba(2, 6, 23, 0.45);
}

.topnav-lang-menu .topnav-lang-item {
    width: 100%;
    justify-content: flex-start;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}

.topnav-lang-menu .topnav-lang-item:hover {
    background: rgba(255, 255, 255, 0.16);
}

.topnav-lang-flag {
    width: 2rem;
    height: 1.3rem;
    border-radius: 0.25rem;
    object-fit: cover;
    border: 1px solid rgba(15, 23, 42, 0.16);
}

.page-stack,
.capture-page-shell,
.packs-page {
    display: grid;
    gap: 0.75rem;
}

.page-hero {
    position: relative;
    overflow: hidden;
    border-radius: 1.5rem;
    padding: 0.95rem 1rem;
    color: #fff;
    background: linear-gradient(135deg, #dc2626 0%, #e11d48 48%, #fb7185 100%);
    box-shadow: 0 24px 50px rgba(15, 23, 42, 0.20);
}

    .page-hero::after {
        content: "";
        position: absolute;
        inset: auto -2rem -3rem auto;
        width: 10rem;
        height: 10rem;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.16);
    }

.hero-copy {
    position: relative;
    z-index: 1;
    max-width: 40rem;
}

.hero-kicker,
.section-eyebrow {
    display: inline-block;
    margin-bottom: 0.45rem;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-copy h1,
.page-title {
    margin: 0;
    font-size: clamp(1.75rem, 6vw, 2.5rem);
    line-height: 1.05;
}

.hero-summary {
    margin: 0.55rem 0 0;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.92);
}

.capture-layout-grid,
.discover-layout-grid {
    display: grid;
    gap: 0.75rem;
}

.capture-sidebar {
    display: grid;
    gap: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94) 0%, rgba(255, 255, 255, 0.90) 100%);
    border-radius: 1.35rem;
    padding: 0.2rem;
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.08);
}

    .capture-sidebar > section {
        border-radius: 1.15rem;
        margin: 0;
        box-shadow: none;
    }

        .capture-sidebar > section + section {
            margin-top: 0.2rem;
        }


.stage-panel,
.capture-sidebar,
.control-card,
.history-card,
.pack-card,
.packs-panel,
.login-card,
.message-card,
.success-banner,
.error-banner,
.learning-details-panel,
.diagnostics-panel,
.panel-surface {
    border-radius: 1.35rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 16px 42px rgba(15, 23, 42, 0.10);
    overflow: hidden;
}

.stage-panel,
.control-card,
.history-card,
.pack-card,
.packs-panel,
.login-card,
.message-card,
.learning-details-panel,
.diagnostics-panel,
.panel-surface {
    background: aliceblue
}

.stage-panel,
.control-card,
.pack-card,
.packs-panel,
.login-card,
.message-card,
.learning-details-panel,
.diagnostics-panel,
.panel-surface {
    padding: 0.85rem;
}

.stage-panel {
    min-width: 0;
    overflow: hidden;
}

.control-card-primary {
    background: linear-gradient(180deg, #ffffff 0%, #fff1f2 100%);
}

.accent-card {
    background: linear-gradient(180deg, #fff1f2 0%, #fff7ed 100%);
}

.success-card,
.success-banner {
    background: linear-gradient(180deg, #ecfdf3 0%, #d1fadf 100%);
}

.challenge-card {
    background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
}

.challenge-card-success {
    background: linear-gradient(180deg, #ecfdf3 0%, #d1fadf 100%);
}

.discover-streak-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    align-items: center;
    margin: 0;
}

.diagnostics-card {
    background: linear-gradient(180deg, #0f172a 0%, #172554 100%);
    color: #e5eefc;
}

.diagnostics-stack {
    display: grid;
    gap: 0.75rem;
}

.diagnostics-card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
}

.diagnostics-collapse-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #e5eefc;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(191, 219, 254, 0.32);
    box-shadow: none;
}

    .diagnostics-collapse-action:hover {
        background: rgba(255, 255, 255, 0.16);
    }

    .diagnostics-card h2,
    .diagnostics-card h3,
    .diagnostics-card li,
    .diagnostics-card p {
        color: inherit;
    }

.section-heading {
    display: grid;
    gap: 0.2rem;
    margin-bottom: 0.65rem;
}

    .section-heading h2,
    .pack-card strong,
    .history-label {
        margin: 0;
        font-size: 1.1rem;
    }

.muted-text,
.pack-meta,
.pack-count,
.pack-selector-subtitle,
.detail-lead,
.history-timestamp {
    color: #475467;
}

.action-row,
.pack-actions,
.provider-grid {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.action-row-split > * {
    flex: 1 1 9rem;
}

.form-stack,
.quick-list-grid,
.packs-search,
.diagnostics-tuning-grid,
.history-list {
    display: grid;
    gap: 0.85rem;
}

.field-block,
.field-inline {
    display: grid;
    gap: 0.4rem;
    font-weight: 600;
}

.admin-runtime-sections,
.admin-runtime-grid {
    display: grid;
    gap: 0.85rem;
}

.runtime-settings-section {
    display: grid;
    gap: 0.85rem;
}

.runtime-setting-card {
    display: grid;
    gap: 0.7rem;
    padding: 0.9rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.runtime-setting-help {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.5;
    color: #475467;
}

.runtime-setting-actions,
.admin-runtime-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.admin-runtime-actions {
    padding-top: 0.15rem;
}

.admin-table-wrap {
    overflow-x: auto;
}

.admin-table-wrap table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table-wrap th,
.admin-table-wrap td {
    padding: 0.75rem 0.65rem;
    text-align: left;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    vertical-align: top;
}

.admin-table-wrap th {
    font-size: 0.82rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #475467;
}

.checkbox-row {
    grid-template-columns: auto 1fr;
    align-items: center;
}

input,
select {
    width: 100%;
    box-sizing: border-box;
    border-radius: 0.95rem;
    border: 1px solid #c7d2fe;
    background: #fff;
    padding: 0.85rem 0.95rem;
    font: inherit;
    color: #0f172a;
}

    input:focus,
    select:focus {
        outline: 3px solid rgba(59, 130, 246, 0.20);
        border-color: #2563eb;
    }

.action-btn,
button,
.zaki-btn {
    border: 0;
    border-radius: 999px;
    padding: 0.85rem 1.1rem;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.action-btn-primary,
button,
.zaki-btn,
.zaki-btn-strong {
    color: #fff;
    background: linear-gradient(135deg, #ef4444, #be123c);
    box-shadow: 0 14px 24px rgba(225, 29, 72, 0.28);
}

.action-btn-secondary {
    color: #be123c;
    background: #ffe4e6;
    box-shadow: none;
}

.action-btn-positive {
    color: #fff;
    background: linear-gradient(135deg, #16a34a, #15803d);
    box-shadow: 0 14px 24px rgba(21, 128, 61, 0.28);
}

.action-btn-danger {
    color: #fff;
    background: linear-gradient(135deg, #ef4444, #be123c);
    box-shadow: 0 14px 24px rgba(225, 29, 72, 0.28);
}

button:disabled,
.zaki-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.text-link-strong {
    font-weight: 700;
}

.language-card {
    display: grid;
    gap: 0.55rem;
    padding: 0.9rem;
    border-radius: 1rem;
    background: rgba(225, 29, 72, 0.08);
}

.video-overlay-stage {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 1rem;
    isolation: isolate;
}

.stage-frame {
    background: linear-gradient(180deg, #1f0a10 0%, #2f0d18 100%);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 0.55rem;
    border-radius: 1.1rem;
    overflow: hidden;
}

.video-overlay-stage video,
.capture-page.mock-camera .capture-canvas,
.video-overlay-stage .zaki-overlay {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.video-overlay-stage video,
.capture-page.mock-camera .capture-canvas {
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 1rem;
    background: #111827;
}

.video-overlay-stage .zaki-overlay {
    position: absolute;
    inset: 0.55rem;
    overflow: hidden;
    border-radius: 1rem;
    z-index: 5;
}

.scan-progress-shell {
    position: absolute;
    left: 0.55rem;
    right: 0.55rem;
    bottom: 0.55rem;
    z-index: 80;
    display: block;
    height: 1rem;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(15, 23, 42, 0.75);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 6px 18px rgba(2, 6, 23, 0.38);
    pointer-events: none;
}

.scan-progress-fill {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #00e5ff 0%, #14b8a6 45%, #84cc16 100%);
    box-shadow: 0 0 18px rgba(0, 229, 255, 0.7);
    transition: width 120ms linear;
}

.scan-progress-shell.is-scanning .scan-progress-fill {
    animation: scan-progress-pulse 0.9s ease-in-out infinite;
}

@keyframes scan-progress-pulse {
    0%,
    100% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }
}

.capture-canvas {
    display: none;
}

.capture-page.mock-camera .video-overlay-stage video {
    display: none;
}

.pack-selector {
    display: grid;
    gap: 0.85rem;
}

.pack-option {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.6rem;
    align-items: center;
    padding: 0.65rem 0.8rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.72);
}

.home-packs-quick-list {
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    padding-top: 0.85rem;
}

    .home-packs-quick-list summary {
        cursor: pointer;
        font-weight: 800;
    }

.example-card {
    padding: 0.9rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.8);
}

.error-banner {
    background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
    color: #9f1239;
    padding: 0.95rem 1rem;
}

.app-toast-stack {
    position: fixed;
    left: 50%;
    bottom: 0.75rem;
    transform: translateX(-50%);
    z-index: 120;
    display: grid;
    gap: 0.55rem;
    width: min(32rem, calc(100vw - 1rem));
}

.saveword-toast {
    max-width: 100%;
    border-radius: 0.9rem;
    padding: 0.75rem 0.9rem;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.24);
    font-weight: 800;
    display: flex;
    align-items: start;
    gap: 0.75rem;
}

.saveword-toast-message {
    flex: 1 1 auto;
}

.saveword-toast-close {
    width: 2rem;
    height: 2rem;
    flex: 0 0 auto;
    padding: 0;
    border: 1px solid currentColor;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    box-shadow: none;
    line-height: 1;
    font-size: 1.15rem;
}

    .saveword-toast-close:hover {
        background: rgba(15, 23, 42, 0.08);
    }

    .saveword-toast-close:focus-visible {
        outline: 3px solid rgba(59, 130, 246, 0.22);
        outline-offset: 2px;
    }

.saveword-toast.is-success {
    background: linear-gradient(180deg, #ecfdf3 0%, #d1fadf 100%);
    color: #065f46;
}

.saveword-toast.is-error {
    background: linear-gradient(180deg, #fff1f2 0%, #ffe4e6 100%);
    color: #9f1239;
}

.success-banner {
    color: #065f46;
    padding: 1rem;
}

.discover-target-panel {
    border-left: 0.45rem solid #f97316;
}

.discover-sidebar {
    gap: 0.15rem;
    align-content: start;
}

.discover-sidebar > section,
.discover-sidebar > div {
    margin: 0;
}

.discover-sidebar .control-card,
.discover-sidebar .success-card {
    padding: 0.7rem;
}

.challenge-target {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 900;
    color: #9a3412;
}

.discover-card-stack {
    display: grid;
    gap: 0.35rem;
}

.discover-card-row {
    display: grid;
    gap: 0.25rem;
}

.discover-card-row-secondary {
    color: #475467;
}

.discover-language-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 0.16rem 0.5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.78);
    color: #14532d;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.discover-language-chip-secondary {
    color: #475467;
}

.discover-card-label,
.discover-card-example,
.discover-card-supporting {
    margin: 0;
    line-height: 1.35;
}

.discover-card-label {
    font-size: 1rem;
}

.discover-card-label-secondary,
.discover-card-example,
.discover-card-supporting {
    font-size: 0.92rem;
}

.packs-toolbar {
    align-items: end;
}

.packs-search input {
    min-width: 0;
}

.packs-confirm {
    padding: 1rem;
    background: linear-gradient(180deg, #fff7ed 0%, #ffedd5 100%);
}

.packs-panel {
    display: grid;
    gap: 1rem;
}

.pack-card {
    margin-bottom: 0;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.pack-card-header {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: start;
}

.pack-status-grid,
.diagnostics-grid {
    display: grid;
    gap: 0.55rem;
}

.pack-status-badge,
.history-status,
.provider-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    font-size: 0.86rem;
    font-weight: 800;
}

.pack-status-badge {
    background: #ffe4e6;
    color: #be123c;
}

.history-card {
    padding: 1rem;
}

.history-card-clickable {
    cursor: pointer;
    background-color: grey;
}

.save-word-panel-below {
    margin-top: 0.9rem;
}

.saved-word-thumb {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 0.9rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
}

.saved-word-record-thumb {
    width: min(50%, 9rem);
    min-width: 6rem;
    display: block;
    justify-self: center;
    margin: 0 auto;
}

.saved-word-record-card {
    display: grid;
    gap: 0.9rem;
    align-content: start;
}

.saved-word-record-card .history-timestamp {
    margin: 0;
}

.saved-word-record-cards {
    display: grid;
    gap: 0.9rem;
}

.saved-word-record-current {
    min-height: 0;
    padding: 0.85rem 1rem;
    font-size: clamp(1.15rem, 3vw, 1.6rem);
    font-weight: 750;
    line-height: 1.25;
}

.saved-word-language-card {
    gap: 0.5rem;
}

.saved-word-language-card .translation-preview-label {
    font-size: 1.1rem;
    line-height: 1.25;
}

.saved-word-language-card .translation-preview-sentence {
    font-size: 0.95rem;
}

.saved-word-record-actions {
    justify-content: center;
    gap: 0.75rem;
}

.saved-word-record-actions > * {
    flex: 0 1 auto;
    min-width: 5.75rem;
}

.saved-word-language-card.is-current {
    background: linear-gradient(180deg, rgba(236, 253, 243, 0.96) 0%, rgba(209, 250, 223, 0.9) 100%);
}

.save-word-detail-panel {
    display: grid;
    gap: 0.95rem;
}

.save-word-detail-layout {
    display: grid;
    gap: 0.95rem;
    align-items: start;
}

.save-word-detail-media,
.save-word-detail-content {
    min-width: 0;
}

.save-word-detail-content {
    display: grid;
    gap: 0.85rem;
    align-content: start;
}

.saved-word-image {
    width: 100%;
    max-width: 28rem;
    display: block;
    border-radius: 1rem;
    border: 1px solid rgba(15, 23, 42, 0.12);
    margin: 0;
}

.history-status {
    width: fit-content;
    margin-top: 0.55rem;
}

.history-status-mapped {
    background: #dcfce7;
    color: #166534;
}

.history-status-unmapped {
    background: #fee2e2;
    color: #991b1b;
}

.login-card,
.external-login-panel {
    display: grid;
    gap: 1rem;
}

.login-submit {
    width: 100%;
    margin-top: 1rem;
}

.provider-chip {
    background: #ffe4e6;
    color: #9f1239;
}

.diagnostics-log-card {
    display: grid;
    gap: 0.75rem;
}

.diagnostics-log-header {
    gap: 0.55rem;
}

.diagnostics-log-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.diagnostics-log-action {
    color: #e5eefc;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(191, 219, 254, 0.32);
    box-shadow: none;
}

.diagnostics-log-action:hover {
    background: rgba(255, 255, 255, 0.16);
}

.diagnostics-log-status {
    margin: 0;
    color: rgba(226, 232, 240, 0.85);
}

.diagnostics-log-textarea {
    width: 100%;
    min-height: 16rem;
    height: 16rem;
    max-height: 24rem;
    resize: vertical;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 0.88rem;
    line-height: 1.45;
    color: #e5eefc;
    background: rgba(2, 6, 23, 0.45);
    border: 1px solid rgba(191, 219, 254, 0.25);
    user-select: text;
    -webkit-user-select: text;
}

@media (min-width: 760px) {
    .app-content {
        padding: 1rem;
    }

    .capture-layout-grid,
    .discover-layout-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        align-items: start;
    }

    .discover-layout-grid {
        grid-template-columns: minmax(0, 1.35fr) minmax(18rem, 0.95fr);
    }

    .stage-panel {
        max-width: 100%;
    }

    .diagnostics-tuning-grid,
    .diagnostics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .history-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .capture-layout-grid,
    .discover-layout-grid {
        grid-template-columns: minmax(0, 1fr) minmax(22rem, 1fr);
    }

    .discover-layout-grid {
        grid-template-columns: minmax(0, 1.5fr) minmax(20rem, 0.85fr);
    }

    .diagnostics-tuning-grid,
    .diagnostics-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .history-list {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.topnav-desktop,
.topnav-mobile {
    display: flex;
    gap: 0.55rem;
    align-items: center;
}

.topnav-mobile {
    display: none;
    position: relative;
}

.topnav-config {
    position: relative;
}

.topnav-config-trigger,
.topnav-menu-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    border-radius: 0.9rem;
    padding: 0.6rem 0.9rem;
    font-weight: 700;
}

.topnav-config-trigger {
    color: #0f172a;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(56, 189, 248, 0.5);
    box-shadow: none;
}

.topnav-config-menu,
.topnav-mobile-menu {
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(7, 17, 31, 0.98);
    color: #e2e8f0;
    box-shadow: 0 14px 30px rgba(2, 6, 23, 0.45);
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}


.topnav-config-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.4rem);
    z-index: 60;
    width: min(23rem, calc(100vw - 1rem));
    max-height: min(34rem, calc(100vh - 5.25rem));
    padding: 0.75rem;
    display: grid;
    gap: 0.75rem;
}

.topnav-mobile-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.55rem);
    z-index: 70;
    width: min(21rem, calc(100vw - 2rem));
    max-height: min(36rem, calc(100vh - 6rem));
    padding: 0.9rem;
    display: grid;
    gap: 0.9rem;
}

.topnav-mobile-links {
    display: grid;
    gap: 0.55rem;
}

    .topnav-mobile-links a {
        color: #fff;
        padding: 0.65rem 0.85rem;
        border-radius: 0.9rem;
        background: rgba(255, 255, 255, 0.08);
        font-weight: 700;
    }

.topnav-mobile-link-button {
    width: 100%;
    justify-content: flex-start;
    color: #fff;
    padding: 0.65rem 0.85rem;
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid transparent;
    box-shadow: none;
    font-weight: 700;
}

.topnav-mobile-link-button.is-active {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(191, 219, 254, 0.35);
}

.config-menu-stack,
.topnav-mobile-settings {
    display: grid;
    gap: 0.75rem;
}

.config-menu-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.config-menu-tab {
    flex: 1 1 6.5rem;
    min-width: 0;
    padding: 0.55rem 0.7rem;
    border-radius: 0.85rem;
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    box-shadow: none;
    font-weight: 700;
}

    .config-menu-tab.is-active {
        color: #0f172a;
        background: rgba(255, 255, 255, 0.94);
        border: 1px solid rgba(56, 189, 248, 0.45);
    }

.config-menu-panel {
    min-height: 0;
    overflow-y: auto;
    max-height: min(25rem, calc(100vh - 12rem));
    padding-right: 0.1rem;
}

.config-menu-section {
    display: grid;
    gap: 0.65rem;
    padding: 0.8rem;
    border-radius: 0.95rem;
    background: rgba(255, 255, 255, 0.06);
}

    .config-menu-section h3 {
        margin: 0;
        font-size: 0.95rem;
        color: #fff;
    }

.config-menu-hint {
    margin: 0;
    color: rgba(226, 232, 240, 0.76);
    font-size: 0.86rem;
}

.config-field-block span,
.config-field-inline span {
    color: #e2e8f0;
}

.config-field-inline.is-disabled {
    opacity: 0.6;
}

.config-check-grid,
.config-pack-list {
    display: grid;
    gap: 0.45rem;
}

.config-pack-list {
    max-height: min(14rem, calc(100vh - 19rem));
    overflow-y: auto;
    padding-right: 0.1rem;
}

.config-menu-section input,
.config-menu-section select {
    border-color: rgba(191, 219, 254, 0.32);
    background: rgba(255, 255, 255, 0.96);
}

.topnav-menu-trigger {
    width: 3rem;
    height: 3rem;
    padding: 0;
    background: rgba(255, 255, 255, 0.10);
    display: inline-flex;
    flex-direction: column;
    gap: 0.22rem;
}

    .topnav-menu-trigger span {
        display: block;
        width: 1.1rem;
        height: 0.14rem;
        border-radius: 999px;
        background: #fff;
        margin: 0;
        flex: 0 0 auto;
    }

.capture-stage-panel {
    display: grid;
    gap: 0.65rem;
}

.stage-action-row {
    justify-content: stretch;
}

    .stage-action-row > * {
        flex: 1 1 12rem;
    }

.zaki-btn.zaki-btn-positive {
    background: linear-gradient(135deg, #16a34a, #15803d);
    box-shadow: 0 14px 24px rgba(21, 128, 61, 0.28);
}

.zaki-btn.zaki-btn-danger {
    background: linear-gradient(135deg, #ef4444, #be123c);
    box-shadow: 0 14px 24px rgba(225, 29, 72, 0.28);
}

.save-preview-sidebar {
    padding: 0;
}

.save-word-preview-panel {
    display: grid;
    gap: 0.65rem;
    min-height: 100%;
    align-content: start;
}

.current-word-display {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 0.75rem 0.9rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.76);
    font-size: clamp(1.45rem, 4vw, 2rem);
    font-weight: 700;
    text-align: center;
    color: #0f172a;
}

.current-word-display.is-placeholder {
    color: #64748b;
    background: rgba(255, 255, 255, 0.62);
}

.translation-preview-card {
    display: grid;
    gap: 0.45rem;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 0.8rem 0.9rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

.translation-preview-language {
    font-size: 0.82rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #334155;
}

.translation-preview-row {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
}

.translation-preview-row > :first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.translation-preview-label {
    min-width: 0;
    font-size: 1.2rem;
    font-weight: 800;
    color: #0f172a;
    overflow-wrap: anywhere;
}

.translation-preview-audio-button {
    width: 2.6rem;
    height: 2.6rem;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #ffffff;
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.18);
    line-height: 1;
    font-size: 1.05rem;
    touch-action: manipulation;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, color 120ms ease;
}

.translation-preview-audio-button:hover:not(:disabled) {
    background: linear-gradient(180deg, #111827 0%, #334155 100%);
    transform: translateY(-1px);
}

.translation-preview-audio-button.is-starting {
    background: linear-gradient(135deg, #c2410c 0%, #f97316 100%);
    color: #ffffff;
    box-shadow: 0 10px 20px rgba(249, 115, 22, 0.28);
}

.translation-preview-audio-button.is-starting:disabled {
    opacity: 1;
}

.translation-preview-audio-button.is-speaking {
    background: linear-gradient(135deg, #047857 0%, #10b981 100%);
    color: #ffffff;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18), 0 12px 20px rgba(4, 120, 87, 0.24);
    animation: translation-preview-audio-pulse 1.15s ease-in-out infinite;
}

.translation-preview-audio-icon {
    font-size: 1.12rem;
}

.translation-preview-audio-spinner {
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.34);
    border-top-color: #ffffff;
    border-radius: 999px;
    animation: translation-preview-audio-spin 0.85s linear infinite;
}

@keyframes translation-preview-audio-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes translation-preview-audio-pulse {
    0%,
    100% {
        transform: translateY(0);
        box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16), 0 12px 20px rgba(4, 120, 87, 0.2);
    }

    50% {
        transform: translateY(-1px);
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.2), 0 14px 24px rgba(4, 120, 87, 0.28);
    }
}

.translation-preview-sentence {
    margin: 0;
    color: #334155;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

@media (min-width: 760px) {
    .admin-runtime-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .save-word-detail-layout {
        grid-template-columns: minmax(16rem, 24rem) minmax(0, 1fr);
    }

    .saved-word-image {
        max-width: none;
    }
}

@media (max-width: 759px) {
    .topbar-inner {
        gap: 0.5rem;
        padding: 0.28rem 0.45rem;
    }

    .brand-lockup {
        gap: 0.45rem;
    }

    .brand-badge {
        width: 1.65rem;
        height: 1.65rem;
        border-radius: 0.58rem;
    }

    .brand-copy strong {
        font-size: 0.86rem;
    }

    .brand-copy span {
        font-size: 0.62rem;
    }

    .topnav {
        width: auto;
    }

    .topnav-desktop {
        display: none;
    }

    .topnav-mobile {
        display: flex;
    }

    .topnav-lang-trigger {
        gap: 0.4rem;
        padding: 0.28rem 0.42rem;
        border-radius: 0.78rem;
    }

    .topnav-menu-trigger {
        width: 2.65rem;
        height: 2.65rem;
        border-radius: 0.8rem;
    }

    .topnav-mobile-menu {
        position: fixed;
        top: 3.35rem;
        right: 0.4rem;
        left: 0.4rem;
        width: auto;
        max-height: calc(100dvh - 3.9rem);
        padding: 0.6rem;
        overflow-y: auto;
    }

    .topnav-config-menu,
    .topnav-lang-menu,
    .topnav-lang-menu-mobile {
        max-height: calc(100dvh - 4.5rem);
    }

    .topnav-mobile-settings .config-menu-panel,
    .topnav-mobile-settings .config-pack-list {
        max-height: none;
    }

    .diagnostics-card-header {
        align-items: stretch;
    }

    .diagnostics-collapse-action {
        width: 100%;
        justify-content: center;
    }

    .diagnostics-log-textarea {
        min-height: 22rem;
        height: min(26rem, 52dvh);
        max-height: 60dvh;
    }

    .topnav-lang-menu-mobile {
        position: fixed;
        top: 3.35rem;
        right: 0.4rem;
        left: 0.4rem;
        min-width: 0;
        width: auto;
        overflow-y: auto;
    }

    .page-hero {
        padding: 0.52rem 0.64rem;
        border-radius: 1rem;
    }

    .hero-copy h1 {
        font-size: 1.55rem;
    }

    .hero-summary {
        margin-top: 0.18rem;
        font-size: 0.8rem;
        line-height: 1.32;
    }

    .app-content {
        padding: 0.42rem;
    }

    .capture-layout-grid {
        gap: 0.4rem;
    }

    .discover-layout-grid {
        gap: 0.34rem;
    }

    .stage-panel,
    .save-word-preview-panel {
        padding: 0.42rem;
    }

    .discover-sidebar,
    .discover-sidebar .control-card,
    .discover-sidebar .success-card {
        padding: 0.55rem;
    }

    .challenge-target {
        font-size: 1.1rem;
    }

    .discover-card-label {
        font-size: 0.95rem;
    }

    .discover-card-label-secondary,
    .discover-card-example,
    .discover-card-supporting {
        font-size: 0.86rem;
    }

    .stage-frame {
        padding: 0.35rem;
    }

    .stage-action-row {
        gap: 0.5rem;
    }

    .stage-action-row > * {
        flex-basis: calc(50% - 0.25rem);
    }

    .current-word-display {
        font-size: 1.3rem;
        padding: 0.65rem 0.75rem;
    }

    .translation-preview-card {
        padding: 0.7rem 0.75rem;
    }

    .translation-preview-audio-button {
        width: 2.75rem;
        height: 2.75rem;
    }
}

.discover-page {
    display: grid;
    gap: 0.5rem;
}

.discover-hero {
    padding: 0.62rem 0.9rem;
    border-radius: 1.1rem;
}

.discover-hero .hero-kicker {
    margin-bottom: 0.12rem;
    font-size: 0.72rem;
}

.discover-hero .page-title {
    font-size: clamp(1.45rem, 4vw, 2.15rem);
}

.discover-layout-grid {
    gap: 0.5rem;
    align-items: start;
}

.discover-stage-panel {
    padding: 0.5rem;
}

.discover-stage-frame {
    padding: 0.4rem;
}

.discover-sidebar {
    gap: 0.16rem;
    padding: 0.16rem;
}

.discover-sidebar > section,
.discover-sidebar > div {
    margin: 0;
}

.discover-sidebar .control-card,
.discover-sidebar .success-card {
    padding: 0.62rem;
}

.discover-target-panel {
    padding: 0.62rem;
    border-left-width: 0.32rem;
}

.discover-streak-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.4rem 0.95rem;
    margin: 0;
    font-size: 0.98rem;
    font-weight: 800;
    text-align: center;
}

.discover-streak-summary strong {
    font-weight: 900;
}

.discover-action-row .action-btn,
.discover-next-btn {
    padding: 0.7rem 0.95rem;
}

.discover-category-panel {
    display: grid;
    gap: 0.45rem;
}

.discover-category-helper {
    margin: 0;
    font-size: 0.86rem;
    line-height: 1.35;
    color: #475467;
    text-align: center;
}

.discover-category-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
}

.discover-category-btn {
    border: 1px solid #bbf7d0;
    border-radius: 999px;
    background: #ffffff;
    color: #14532d;
    padding: 0.45rem 0.8rem;
    font-size: 0.84rem;
    font-weight: 800;
    line-height: 1.2;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.discover-category-btn:hover {
    border-color: #22c55e;
    background: #f0fdf4;
}

.discover-category-btn:focus-visible {
    outline: 2px solid #16a34a;
    outline-offset: 2px;
}

.discover-category-btn-active {
    border-color: #15803d;
    background: #166534;
    color: #ffffff;
    box-shadow: 0 0 0 1px rgba(21, 128, 61, 0.18);
}

.discover-category-btn-active:hover,
.discover-category-btn-active:focus-visible,
.discover-category-btn-active:active {
    border-color: #15803d;
    background: #166534;
    color: #ffffff;
}

.discover-compact-card-list {
    display: grid;
    gap: 0.24rem;
}

.discover-compact-card-line {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
    margin: 0;
    line-height: 1.24;
}

.discover-compact-card-line-primary .discover-compact-card-value {
    color: #9a3412;
    font-weight: 900;
}

.discover-compact-card-language {
    flex: 0 0 4.65rem;
    min-width: 4.65rem;
    font-size: 0.78rem;
    font-weight: 800;
    color: #14532d;
}

.discover-compact-card-value {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.98rem;
    font-weight: 700;
    color: #0f172a;
    overflow-wrap: anywhere;
}

.discover-success-example {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.91rem;
    font-weight: 600;
    line-height: 1.25;
    color: #0f172a;
    overflow-wrap: anywhere;
}

.discover-success-card {
    padding-bottom: 0.62rem;
}

.discover-card-title,
.discover-success-title {
    margin: 0 0 0.42rem;
    font-weight: 900;
    text-align: center;
}

@media (min-width: 760px) {
    .discover-layout-grid {
        grid-template-columns: minmax(0, 1.08fr) minmax(18rem, 0.92fr);
    }
}

@media (min-width: 1024px) {
    .discover-layout-grid {
        grid-template-columns: minmax(0, 1.05fr) minmax(22rem, 0.95fr);
    }
}

@media (max-width: 759px) {
    .discover-page {
        gap: 0.3rem;
    }

    .discover-hero {
        padding: 0.42rem 0.62rem;
    }

    .discover-stage-panel {
        padding: 0.28rem;
    }

    .discover-stage-frame {
        padding: 0.22rem;
    }

    .discover-stage-frame .zaki-overlay {
        inset: 0.22rem;
        border-radius: 0.9rem;
    }

    .discover-stage-frame .scan-progress-shell {
        left: 0.22rem;
        right: 0.22rem;
        bottom: 0.22rem;
    }

    .discover-sidebar,
    .discover-sidebar .control-card,
    .discover-sidebar .success-card,
    .discover-target-panel {
        padding: 0.46rem;
    }

    .discover-sidebar {
        gap: 0.12rem;
    }

    .discover-category-panel {
        order: 1;
        gap: 0.35rem;
    }

    .discover-controls-panel {
        order: 2;
    }

    .discover-streak-panel {
        order: 3;
    }

    .discover-labels-panel {
        order: 4;
    }

    .discover-compact-card-line {
        gap: 0.28rem;
    }

    .discover-category-list {
        justify-content: flex-start;
        gap: 0.22rem;
    }

    .discover-category-btn {
        padding: 0.28rem 0.54rem;
        font-size: 0.84rem;
    }

    .discover-category-btn-active,
    .discover-category-btn-active:hover,
    .discover-category-btn-active:focus-visible,
    .discover-category-btn-active:active {
        border-color: #15803d;
        background: #166534;
        color: #ffffff;
    }

    .discover-compact-card-language {
        flex-basis: 4rem;
        min-width: 4rem;
        font-size: 0.74rem;
    }

    .discover-compact-card-value {
        font-size: 0.92rem;
    }

    .discover-success-example {
        font-size: 0.86rem;
    }
}
