/* ==========================================================================
   ToraLang Unified Ecosystem Styles (Bunpo Grammar, Words, Parser, Reader & KanjiCombi)
   ========================================================================== */

/* ── Top Navigation Tabs ─────────────────────────────────────────────────── */
.navbar-unified-tabs {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0 auto;
    padding: 0.25rem 0.4rem;
    background: color-mix(in srgb, var(--shell-card) 75%, transparent);
    border: 1px solid var(--shell-panel-border);
    border-radius: var(--shell-radius-pill);
    overflow-x: auto;
    max-width: 100%;
}

.navbar-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.38rem;
    padding: 0.42rem 0.88rem;
    border-radius: var(--shell-radius-pill);
    border: none;
    background: transparent;
    color: var(--shell-muted);
    font-family: var(--shell-font-heading);
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.16s ease;
}

.navbar-tab-btn:hover {
    color: var(--shell-text);
    background: color-mix(in srgb, var(--shell-accent) 12%, transparent);
}

.navbar-tab-btn.active {
    background: var(--shell-accent);
    color: #fff;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--shell-accent) 36%, transparent);
}

.navbar-tab-ext {
    border-left: 1px solid var(--shell-panel-border);
    margin-left: 0.15rem;
    padding-left: 0.75rem;
    font-size: 0.82rem;
}

/* ── Unified Split Workspace Layout (Grammar & Words Pages) ──────────────── */
.unified-page-shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem 2.5rem;
    min-height: calc(100vh - 4.25rem);
}

.unified-split-grid {
    display: grid;
    grid-template-columns: 370px minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 980px) {
    .unified-split-grid {
        grid-template-columns: 1fr;
    }
    .navbar-unified-tabs {
        gap: 0.2rem;
        padding: 0.2rem;
    }
    .navbar-tab-btn {
        padding: 0.35rem 0.65rem;
        font-size: 0.8rem;
    }
}

.unified-sidebar-card,
.unified-main-card {
    background: var(--shell-card);
    border: 1px solid var(--shell-panel-border);
    border-radius: var(--shell-radius-md);
    box-shadow: var(--shell-shadow);
}

.unified-sidebar-card {
    position: sticky;
    top: 4.6rem;
    max-height: calc(100vh - 5.6rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.unified-sidebar-header {
    padding: 1rem 1rem 0.75rem;
    border-bottom: 1px solid var(--shell-panel-border);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.unified-search-input {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border-radius: var(--shell-radius-sm);
    border: 1px solid var(--shell-border);
    background: var(--shell-bg);
    color: var(--shell-text);
    font-size: 0.94rem;
    outline: none;
}

.unified-search-input:focus {
    border-color: var(--shell-accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--shell-accent) 24%, transparent);
}

.unified-filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.unified-pill-btn {
    padding: 0.26rem 0.65rem;
    border-radius: var(--shell-radius-pill);
    border: 1px solid var(--shell-panel-border);
    background: var(--shell-bg);
    color: var(--shell-muted);
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.14s ease;
}

.unified-pill-btn:hover {
    border-color: var(--shell-accent);
    color: var(--shell-text);
}

.unified-pill-btn.active {
    background: var(--shell-accent);
    border-color: var(--shell-accent);
    color: #fff;
}

.unified-list-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.unified-list-item {
    display: flex;
    flex-direction: column;
    gap: 0.22rem;
    padding: 0.65rem 0.8rem;
    border-radius: var(--shell-radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--shell-text);
    text-align: left;
    cursor: pointer;
    transition: all 0.14s ease;
}

.unified-list-item:hover {
    background: color-mix(in srgb, var(--shell-accent) 10%, var(--shell-bg));
}

.unified-list-item.active {
    background: color-mix(in srgb, var(--shell-accent) 16%, var(--shell-bg));
    border-color: var(--shell-accent);
}

.unified-list-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.unified-list-item-title {
    font-size: 1.02rem;
    font-weight: 700;
    color: var(--shell-text);
}

.unified-list-item-sub {
    font-size: 0.83rem;
    color: var(--shell-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── JLPT & Level Badges ─────────────────────────────────────────────────── */
.jlpt-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.14rem 0.5rem;
    border-radius: var(--shell-radius-pill);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    background: color-mix(in srgb, var(--shell-accent) 18%, var(--shell-bg));
    color: var(--shell-accent);
}
.jlpt-N5, .jlpt-JLPT5 { background: rgba(34, 197, 94, 0.16); color: #16a34a; }
.jlpt-N4, .jlpt-JLPT4 { background: rgba(59, 130, 246, 0.16); color: #2563eb; }
.jlpt-N3, .jlpt-JLPT3 { background: rgba(234, 179, 8, 0.18); color: #ca8a04; }
.jlpt-N2, .jlpt-JLPT2 { background: rgba(249, 115, 22, 0.18); color: #ea580c; }
.jlpt-N1, .jlpt-JLPT1 { background: rgba(239, 68, 68, 0.18); color: #dc2626; }

/* ── Grammar Detail View ─────────────────────────────────────────────────── */
.unified-main-card {
    padding: 1.5rem 1.75rem;
}

.gp-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1.1rem;
    border-bottom: 1px solid var(--shell-panel-border);
    margin-bottom: 1.25rem;
}

.gp-detail-title {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.25;
    color: var(--shell-text);
}

.gp-detail-meaning {
    font-size: 1.12rem;
    color: var(--shell-muted);
    margin-top: 0.35rem;
    font-weight: 600;
}

.gp-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.65rem;
}

.gp-section-block {
    margin-top: 1.35rem;
    padding: 1.05rem 1.2rem;
    border-radius: var(--shell-radius-sm);
    background: var(--shell-bg);
    border: 1px solid var(--shell-panel-border);
}

.gp-section-title {
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--shell-muted);
    margin-bottom: 0.65rem;
}

.gp-structure-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.85rem;
}

.gp-structure-box {
    padding: 0.8rem 1rem;
    border-radius: var(--shell-radius-sm);
    background: var(--shell-card);
    border-left: 3px solid var(--shell-accent);
    font-size: 0.98rem;
    line-height: 1.65;
}

.gp-writeup-body {
    font-size: 0.98rem;
    line-height: 1.75;
    color: var(--shell-text);
}

.gp-writeup-body p {
    margin-bottom: 0.75rem;
}

.gp-example-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.gp-example-card {
    padding: 0.85rem 1rem;
    border-radius: var(--shell-radius-sm);
    background: var(--shell-card);
    border: 1px solid var(--shell-panel-border);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.9rem;
}

.gp-example-jp {
    font-size: 1.08rem;
    line-height: 1.7;
    color: var(--shell-text);
}

.gp-example-jp .gp-answer-highlight,
.gp-example-jp strong,
.gp-writeup-body strong {
    color: var(--shell-accent);
    font-weight: 700;
}

.gp-example-en {
    font-size: 0.92rem;
    color: var(--shell-muted);
    margin-top: 0.25rem;
}

.gp-audio-btn {
    padding: 0.35rem 0.65rem;
    border-radius: var(--shell-radius-pill);
    border: 1px solid var(--shell-panel-border);
    background: var(--shell-bg);
    color: var(--shell-text);
    cursor: pointer;
    font-size: 0.8rem;
    white-space: nowrap;
}

.gp-audio-btn:hover {
    border-color: var(--shell-accent);
    color: var(--shell-accent);
}

/* ── Yomitan & Multi-Dictionary Cards ────────────────────────────────────── */
.ym-entry-card {
    padding: 1rem 1.15rem;
    border-radius: var(--shell-radius-sm);
    background: var(--shell-bg);
    border: 1px solid var(--shell-panel-border);
    margin-bottom: 0.85rem;
}

.ym-entry-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.55rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px dashed var(--shell-panel-border);
}

.ym-entry-word {
    font-size: 1.38rem;
    font-weight: 800;
    color: var(--shell-text);
}

.ym-entry-reading {
    font-size: 1rem;
    color: var(--shell-muted);
    margin-left: 0.45rem;
}

.ym-dict-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.16rem 0.55rem;
    border-radius: var(--shell-radius-pill);
    font-size: 0.74rem;
    font-weight: 700;
    background: color-mix(in srgb, var(--shell-accent) 16%, var(--shell-card));
    color: var(--shell-accent);
}

.ym-pitch-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.48rem;
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 700;
    background: rgba(59, 130, 246, 0.14);
    color: #2563eb;
}

.ym-freq-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.48rem;
    border-radius: 6px;
    font-size: 0.74rem;
    font-weight: 700;
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
}

.ym-sense-list {
    margin: 0.35rem 0 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.95rem;
    line-height: 1.65;
}

.ym-dict-image {
    max-width: 240px;
    max-height: 180px;
    border-radius: 8px;
    margin: 0.35rem 0;
}

/* ── KanjiCombi Unified Multi-Dictionary Sections ────────────────────────── */
.kc-multidict-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 1rem;
}

.kc-dict-card {
    padding: 0.9rem 1.05rem;
    border-radius: var(--shell-radius-sm);
    background: var(--shell-bg);
    border: 1px solid var(--shell-panel-border);
}

.kc-dict-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 0.88rem;
    color: var(--shell-text);
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.kc-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: var(--shell-radius-pill);
    font-size: 0.75rem;
    font-weight: 700;
    background: color-mix(in srgb, var(--shell-accent) 18%, var(--shell-card));
    color: var(--shell-accent);
}

.kc-badge-vn {
    background: rgba(234, 88, 12, 0.16);
    color: #ea580c;
    font-size: 0.82rem;
}

.kc-stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.55rem;
}

.kc-stat-pill {
    font-size: 0.76rem;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    background: var(--shell-card);
    border: 1px solid var(--shell-panel-border);
}

.kc-mnemonic {
    padding: 0.6rem 0.8rem;
    border-radius: 8px;
    background: var(--shell-card);
    border-left: 3px solid var(--shell-accent);
    font-size: 0.9rem;
    line-height: 1.55;
    margin-bottom: 0.65rem;
}

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

.kc-vocab-table th,
.kc-vocab-table td {
    padding: 0.38rem 0.5rem;
    border-bottom: 1px solid var(--shell-panel-border);
    text-align: left;
}

.kc-vocab-word {
    font-weight: 700;
    font-size: 0.96rem;
}

.kc-decomp-box {
    font-family: monospace;
    font-size: 0.88rem;
    padding: 0.55rem 0.75rem;
    background: var(--shell-card);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
}

.kc-dict-body,
.kc-dict-list {
    font-size: 0.9rem;
    line-height: 1.65;
    color: var(--shell-text);
}

.kc-dict-list {
    padding-left: 1.25rem;
}

.kc-yoji-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.kc-yoji-item {
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    background: var(--shell-card);
    border: 1px solid var(--shell-panel-border);
}

.kc-yoji-word {
    font-weight: 800;
    font-size: 1.02rem;
    color: var(--shell-accent);
}

.kc-yoji-reading {
    font-size: 0.86rem;
    color: var(--shell-muted);
}

.kc-yoji-en {
    font-size: 0.88rem;
    font-weight: 600;
    margin-top: 0.18rem;
}

.kc-yoji-jp {
    font-size: 0.83rem;
    color: var(--shell-muted);
    margin-top: 0.12rem;
}

/* ── Parser Page & Reader Ad-Hoc Tools Bar ───────────────────────────────── */
.parser-input-box {
    width: 100%;
    min-height: 120px;
    padding: 0.9rem 1rem;
    border-radius: var(--shell-radius-sm);
    border: 1px solid var(--shell-border);
    background: var(--shell-bg);
    color: var(--shell-text);
    font-size: 1.05rem;
    line-height: 1.65;
    resize: vertical;
}

.parser-token-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.85rem 1rem;
    border-radius: var(--shell-radius-sm);
    background: var(--shell-bg);
    border: 1px solid var(--shell-panel-border);
    line-height: 2;
}

.parser-token-chip {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 0.18rem 0.42rem;
    border-radius: 6px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.12s ease;
    font-size: 1.12rem;
}

.parser-token-chip:hover,
.parser-token-chip.active {
    background: color-mix(in srgb, var(--shell-accent) 18%, var(--shell-card));
    border-bottom-color: var(--shell-accent);
}

.parser-token-chip.has-grammar {
    border-bottom-color: #f59e0b;
}

.reader-adhoc-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    background: var(--shell-card);
    border-bottom: 1px solid var(--shell-panel-border);
    border-radius: var(--shell-radius-sm);
    margin-bottom: 0.75rem;
}

.reader-adhoc-drawer {
    padding: 1rem 1.25rem;
    background: var(--shell-card);
    border: 1px solid var(--shell-panel-border);
    border-radius: var(--shell-radius-sm);
    box-shadow: var(--shell-shadow);
    margin-bottom: 1rem;
}

.reader-adhoc-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1.15rem;
}

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

.reader-bunpo-writeup-box {
    margin-top: 0.65rem;
    padding: 0.85rem 1rem;
    border-radius: var(--shell-radius-sm);
    background: color-mix(in srgb, var(--shell-bg) 82%, transparent);
    border: 1px solid var(--shell-panel-border);
    font-size: 0.9rem;
    line-height: 1.65;
}

.reader-bunpo-dict-section {
    margin-top: 0.85rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--shell-panel-border);
}

