

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1f2937;
    background: #f3f4f6;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

.page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem 4rem;
}

.nav {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 2.5rem;
}

.nav__inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav__brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: #111827;
}

.nav__logo {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.nav__spacer { flex: 1; }

.nav__back {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: #6b7280;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
}
.nav__back:hover { background: #f3f4f6; color: #111827; }

.welcome {
    margin-bottom: 2rem;
}

.welcome__title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.35rem;
}

.welcome__sub {
    color: #6b7280;
    font-size: 0.975rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    border: 1px solid #e5e7eb;
    transition: box-shadow 0.2s;
}
.stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.07); }

.stat-card__value {
    font-size: 2rem;
    font-weight: 800;
    color: #111827;
    line-height: 1;
    margin-bottom: 0.35rem;
    display: block;
}

.stat-card__label {
    font-size: 0.825rem;
    color: #6b7280;
    font-weight: 500;
}

.stat-card--mastered .stat-card__value { color: #10b981; }
.stat-card--learning .stat-card__value { color: #3b82f6; }
.stat-card--new      .stat-card__value { color: #8b5cf6; }
.stat-card--decks    .stat-card__value { color: #f59e0b; }

.section-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.section-header__title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #111827;
    flex: 1;
}

.search-input {
    flex: 0 1 240px;
    height: 38px;
    padding: 0 0.85rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    font-family: inherit;
    color: #374151;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
}
.search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.deck-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

.deck-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s, transform 0.2s;
}
.deck-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,0.10); transform: translateY(-3px); }

.deck-card__header {
    padding: 1.5rem 1.5rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}

.deck-card__flag {
    display: inline-block;
    width: 3rem;
    height: 2.25rem;
    border-radius: 6px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
    overflow: hidden;
}

.deck-card__flag.fi {
    width: 3rem;
    height: 2.25rem;
    border-radius: 6px;
}

.flag-split {
    position: relative;
    
}

.flag-split .fi {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 0;
    background-size: cover;
    background-position: center;
}

.flag-split__from {
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

.flag-split__to {
    clip-path: polygon(100% 0, 100% 100%, 0 100%);
}

.deck-card__meta {
    flex: 1;
    min-width: 0;
}

.deck-card__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.deck-card__desc {
    font-size: 0.825rem;
    color: #6b7280;
}

.deck-card__body {
    padding: 0 1.5rem 0.75rem;
    flex: 1;
}

.deck-progress {
    margin-bottom: 0.6rem;
}

.deck-progress__bar {
    height: 6px;
    background: #f3f4f6;
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.4rem;
}

.deck-progress__fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #10b981);
    border-radius: 3px;
    transition: width 0.6s ease;
}

.deck-progress__labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.775rem;
    color: #9ca3af;
}

.deck-card__stats {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    color: #6b7280;
}

.deck-card__stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.deck-card__stat--mastered { color: #10b981; font-weight: 600; }
.deck-card__stat--review   { color: #f59e0b; font-weight: 600; }

.deck-card__footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #f3f4f6;
    display: flex;
    gap: 0.75rem;
}

.deck-card__footer .btn {
    flex: 1;
    justify-content: center;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    border-radius: 9px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    font-weight: 600;
    border-radius: 10px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn--primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.btn--primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

.btn--ghost {
    background: transparent;
    color: #374151;
    border-color: #d1d5db;
}
.btn--ghost:hover { background: #f9fafb; border-color: #9ca3af; }

.loading-msg,
.empty-msg {
    text-align: center;
    padding: 3rem;
    color: #9ca3af;
    font-size: 0.975rem;
    grid-column: 1 / -1;
}

.deck-card__color-bar {
    height: 5px;
    width: 100%;
}

@media (max-width: 900px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .deck-grid  { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 580px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .deck-grid  { grid-template-columns: 1fr; }
    .section-header { flex-direction: column; align-items: flex-start; }
    .search-input  { flex: 1 1 auto; width: 100%; }
}

.dash-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0;
}

.dash-tab {
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: #6b7280;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.55rem 1.1rem;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
    transition: color 0.15s, border-color 0.15s;
}
.dash-tab:hover { color: #111827; }
.dash-tab.is-active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.dash-view { display: none; }
.dash-view.is-active { display: block; }

.collection-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

.collection-card {
    background: #fff;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.2s, transform 0.2s;
}
.collection-card:hover { box-shadow: 0 8px 28px rgba(0,0,0,0.10); transform: translateY(-3px); }

.collection-card__color-bar {
    height: 5px;
    width: 100%;
}

.collection-card__header {
    padding: 1.5rem 1.5rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}

.collection-card__flag {
    display: inline-block;
    width: 3.5rem;
    height: 2.625rem;
    border-radius: 8px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
    overflow: hidden;
}

.collection-card__flag.fi {
    width: 3.5rem;
    height: 2.625rem;
    border-radius: 8px;
}

.collection-card__meta { flex: 1; min-width: 0; }

.collection-card__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 0.2rem;
}

.collection-card__desc {
    font-size: 0.825rem;
    color: #6b7280;
}

.collection-card__body {
    padding: 0 1.5rem 0.75rem;
    flex: 1;
}

.collection-card__stats {
    display: flex;
    gap: 1rem;
    font-size: 0.8rem;
    margin-top: 0.5rem;
}

.collection-card__footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #f3f4f6;
    display: flex;
    gap: 0.75rem;
}

.collection-card__footer .btn {
    flex: 1;
    justify-content: center;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    border-radius: 9px;
}

.btn--list {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: #6b7280;
    border-radius: 9px;
    text-decoration: none;
    background: transparent;
    border: 1.5px solid #e5e7eb;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    cursor: pointer;
}

.btn--list:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #374151;
    text-decoration: none;
}

.collection-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.breadcrumb-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
}

.btn--sm {
    padding: 0.35rem 0.85rem;
    font-size: 0.825rem;
    border-radius: 8px;
}

.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.filter-chips--dir {
    margin-top: -0.75rem;
}

.filter-chip {
    font-family: inherit;
    font-size: 0.825rem;
    font-weight: 600;
    color: #374151;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 20px;
    padding: 0.3rem 0.9rem;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}
.filter-chip:hover {
    border-color: #2563eb;
    color: #2563eb;
}
.filter-chip.is-active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

.filter-chip--dir:hover {
    border-color: #0d9488;
    color: #0d9488;
}
.filter-chip--dir.is-active {
    background: #0d9488;
    border-color: #0d9488;
    color: #fff;
}

.dir-badge {
    font-size: 0.7rem;
    font-weight: 700;
    color: #9ca3af;
    letter-spacing: 0.03em;
}

.beta-banner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 1.25rem;
    background: #fefce8;
    border-bottom: 1px solid #fde68a;
    font-size: 0.78rem;
    color: #78350f;
    flex-wrap: wrap;
    line-height: 1.4;
}
.beta-banner__badge {
    display: inline-block;
    background: #f59e0b;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    flex-shrink: 0;
}
.beta-banner__text { flex: 1; min-width: 200px; }
.beta-banner__text a { color: #92400e; text-decoration: underline; }
.beta-banner__text a:hover { color: #78350f; }
.beta-banner__close {
    background: none;
    border: none;
    cursor: pointer;
    color: #92400e;
    font-size: 1rem;
    padding: 0.2rem 0.4rem;
    line-height: 1;
    flex-shrink: 0;
    opacity: 0.6;
    border-radius: 4px;
}
.beta-banner__close:hover { opacity: 1; background: rgba(0,0,0,0.06); }

.page-footer {
    margin-top: 3rem;
    padding: 1.25rem 1.5rem;
    text-align: center;
    border-top: 1px solid #f3f4f6;
}
.page-footer__credit {
    font-size: 0.75rem;
    color: #9ca3af;
}
.page-footer__credit a { color: #9ca3af; text-decoration: underline; }
.page-footer__credit a:hover { color: #6b7280; }

.page-footer__links {
    font-size: 0.78rem;
    color: #9ca3af;
    margin-top: 0.35rem;
}

.page-footer__links a {
    color: #9ca3af;
    text-decoration: underline;
}

.page-footer__links a:hover { color: #6b7280; }

.build-version {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-top: 0.25rem;
}

@media (max-width: 900px) {
    .collection-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 580px) {
    .collection-grid { grid-template-columns: 1fr; }
}

.lang-picker {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.lang-picker__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
    font-family: inherit;
}
.lang-picker__btn:hover { background: #f3f4f6; color: #111827; }
.lang-picker__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    min-width: 164px;
    z-index: 200;
    overflow: hidden;
}
.lang-picker__dropdown[hidden] { display: none; }
.lang-picker__option {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 0.5rem 0.875rem;
    font-size: 0.875rem;
    color: #374151;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background-color 0.12s;
}
.lang-picker__option:hover,
.lang-picker__option[aria-current="true"] { background: #f3f4f6; }
.lang-picker__option[aria-current="true"] { font-weight: 600; color: #2563eb; }
.lang-picker__flag {
    display: inline-block;
    width: 22px;
    height: 16px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
    flex-shrink: 0;
    overflow: hidden;
}
