:root {
    color-scheme: light;
    --bg: #f8efe1;
    --surface: #fff8ee;
    --surface-strong: #ffffff;
    --ink: #211915;
    --muted: #6f625b;
    --line: #e3d2c0;
    --de: #5f6570;
    --es: #b94132;
    --gn: #2f7a53;
    --blue: #28608f;
    --yellow: #e5b84b;
    --shadow: 0 18px 42px rgba(63, 41, 28, 0.13);
    --shadow-soft: 0 8px 22px rgba(63, 41, 28, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 100%;
    overflow-x: hidden;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        linear-gradient(135deg, rgba(185, 65, 50, 0.1), transparent 34%),
        linear-gradient(315deg, rgba(47, 122, 83, 0.12), transparent 32%),
        var(--bg);
}

a {
    color: inherit;
}

button,
input,
select {
    font: inherit;
}

button,
.button {
    max-width: 100%;
    min-width: 0;
    min-height: 48px;
    border: 0;
    border-radius: var(--radius);
    background: var(--es);
    color: #fff;
    font-weight: 800;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    cursor: pointer;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
}

button:focus-visible,
a:focus-visible,
.flash-card:focus-visible {
    outline: 3px solid rgba(40, 96, 143, 0.36);
    outline-offset: 3px;
}

button.secondary {
    background: #efe3d4;
    color: var(--ink);
}

.button.secondary {
    background: #efe3d4;
    color: var(--ink);
}

.full-width {
    width: 100%;
}

.app-shell {
    width: min(940px, 100%);
    max-width: 100%;
    margin: 0 auto;
    padding: 12px 14px 96px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 8px 0 12px;
    background: linear-gradient(to bottom, var(--bg) 75%, rgba(247, 239, 227, 0));
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-mark,
.lesson-icon {
    width: 48px;
    min-width: 48px;
    height: 48px;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--es), var(--blue));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 2px;
}

.main-content {
    display: grid;
    gap: 16px;
    min-width: 0;
}

.hero-panel,
.today-card,
.quick-actions a,
.lesson-card,
.course-row,
.phrase-card,
.content-block,
.note-block,
.mini-test,
.flash-card,
.quiz-box,
.empty-state,
.progress-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 250, 243, 0.92);
    box-shadow: var(--shadow);
}

.hero-panel {
    display: grid;
    gap: 18px;
    padding: 24px 20px;
    background:
        linear-gradient(160deg, rgba(255, 250, 243, 0.96), rgba(255, 246, 232, 0.88)),
        url("../hero-paraguay-market.png");
    background-size: cover;
    background-position: center;
}

.kicker {
    margin: 0 0 7px;
    color: var(--es);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p,
strong,
small,
a,
span {
    overflow-wrap: anywhere;
}

h1 {
    margin: 0;
    font-size: clamp(2.05rem, 9vw, 3.7rem);
    line-height: 1.04;
    letter-spacing: 0;
}

h2 {
    margin: 0;
    font-size: 1.35rem;
}

h3 {
    margin: 0;
    font-size: 1.12rem;
}

p {
    line-height: 1.55;
}

.hero-panel p,
.lesson-card p,
.lesson-title p,
.empty-state p {
    color: var(--muted);
}

.progress-card {
    padding: 16px;
    background: var(--surface-strong);
}

.progress-number {
    display: block;
    font-size: 2rem;
    font-weight: 900;
    color: var(--gn);
}

.progress-label {
    display: block;
    color: var(--muted);
}

.progress-prepared {
    display: block;
    margin-top: 6px;
    color: var(--blue);
    font-size: 0.86rem;
    font-weight: 800;
}

.progress-bar {
    height: 10px;
    border-radius: 999px;
    background: #eadcca;
    margin-top: 14px;
    overflow: hidden;
}

.progress-bar span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--gn), var(--yellow));
}

.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 12px;
    margin-top: 8px;
    min-width: 0;
}

.section-head > * {
    min-width: 0;
}

.today-card {
    display: grid;
    gap: 14px;
    padding: 18px;
    background: linear-gradient(135deg, #fffaf2, #fff0dd);
}

.today-copy p:last-child {
    margin-bottom: 0;
    color: var(--muted);
}

.info-strip {
    display: grid;
    gap: 10px;
}

.info-strip article {
    min-width: 0;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 250, 243, 0.9);
    box-shadow: var(--shadow-soft);
}

.info-strip span {
    display: inline-flex;
    width: fit-content;
    min-height: 28px;
    align-items: center;
    padding: 0 9px;
    border-radius: var(--radius);
    background: #eef8f1;
    color: var(--gn);
    font-size: 0.76rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.info-strip p {
    margin: 8px 0 0;
    color: var(--muted);
    font-weight: 750;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.quick-actions a {
    min-height: 86px;
    padding: 14px;
    text-decoration: none;
    background: var(--surface-strong);
    min-width: 0;
}

.quick-actions span {
    display: block;
    color: var(--es);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.quick-actions strong {
    display: block;
    margin-top: 6px;
    font-size: 1rem;
}

.text-link {
    color: var(--blue);
    font-weight: 800;
}

.lesson-grid,
.cards-list,
.phrase-stack {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.lesson-card,
.flash-card,
.empty-state {
    padding: 18px;
    min-width: 0;
    max-width: 100%;
}

.lesson-card {
    display: grid;
    gap: 12px;
    align-content: start;
}

.course-list {
    display: grid;
    gap: 8px;
}

.course-row {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    padding: 14px 12px;
    text-decoration: none;
    background: rgba(255, 250, 243, 0.86);
    min-width: 0;
}

.course-number {
    color: var(--es);
    font-weight: 900;
}

.course-main small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

.course-main {
    min-width: 0;
}

.course-status {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.is-read .course-status,
.is-read [data-status-label] {
    color: var(--gn);
}

.lesson-title {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 4px 0;
    min-width: 0;
    max-width: 100%;
}

.lesson-title > div {
    min-width: 0;
}

.lesson-detail {
    display: grid;
    gap: 16px;
    min-width: 0;
    max-width: 100%;
}

.phrase-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    background: var(--surface-strong);
    min-width: 0;
    max-width: 100%;
}

.language-line {
    display: grid;
    gap: 4px;
    padding: 12px;
    border-left: 5px solid var(--de);
    border-radius: var(--radius);
    background: #f6f2ec;
    min-width: 0;
    max-width: 100%;
}

.language-line span {
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 800;
}

.language-line strong {
    font-size: 1.05rem;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.lang-es {
    border-color: var(--es);
    background: #fff0ec;
}

.lang-gn {
    border-color: var(--gn);
    background: #eef8f1;
}

.favorite-toggle {
    background: #efe3d4;
    color: var(--ink);
}

.favorite-toggle.is-saved {
    background: var(--gn);
    color: #fff;
}

.section-mini-head {
    padding: 2px 0 4px;
}

.section-mini-head h2 {
    color: var(--ink);
    font-size: 1.05rem;
    line-height: 1.35;
}

.review-note {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.content-block,
.note-block,
.mini-test {
    padding: 18px;
    min-width: 0;
    max-width: 100%;
}

.note-block {
    background: #fff5d8;
}

.dialogue p {
    margin: 10px 0;
    padding: 12px;
    border-radius: var(--radius);
    background: #f6f0e8;
    max-width: 100%;
}

.test-item {
    border-top: 1px solid var(--line);
    padding-top: 12px;
    margin-top: 12px;
}

.test-item strong {
    display: block;
    margin-top: 10px;
    color: var(--gn);
    overflow-wrap: anywhere;
}

.lesson-pager {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    min-width: 0;
    max-width: 100%;
}

.lesson-pager-top {
    margin-bottom: -4px;
}

.pager-link {
    min-height: 46px;
    min-width: 0;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-strong);
    color: var(--blue);
    font-weight: 900;
    text-decoration: none;
    padding: 8px 10px;
    text-align: center;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
}

.pager-link.is-disabled {
    pointer-events: none;
    color: var(--muted);
    opacity: 0.48;
}

.flash-card {
    display: grid;
    gap: 12px;
    cursor: pointer;
    transition: transform 160ms ease, box-shadow 160ms ease;
    min-width: 0;
    max-width: 100%;
}

.flash-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-soft);
}

.card-answer {
    display: none;
    gap: 8px;
    min-width: 0;
}

.flash-card.is-open .card-answer {
    display: grid;
}

.flash-card.is-filtered-out {
    display: none !important;
}

.card-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
}

.filter-row {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: thin;
}

.filter-row button {
    min-height: 42px;
    flex: 0 0 auto;
    background: var(--surface-strong);
    border: 1px solid var(--line);
    color: var(--muted);
}

.filter-row button.is-active {
    background: var(--ink);
    color: #fff;
}

.quiz-box {
    padding: 18px;
    min-width: 0;
    max-width: 100%;
}

.quiz-options {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.quiz-options button {
    background: var(--surface-strong);
    border: 1px solid var(--line);
    color: var(--ink);
    justify-content: flex-start;
    text-align: left;
    min-width: 0;
}

.quiz-options button.is-correct {
    background: var(--gn);
    color: #fff;
}

.quiz-options button.is-wrong {
    background: var(--es);
    color: #fff;
}

.quiz-feedback {
    min-height: 28px;
    color: var(--muted);
    font-weight: 800;
}

.quiz-last-result {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #eef8f1;
    color: var(--gn);
    font-weight: 900;
}

.review-hero,
.review-card,
.review-stats article {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 250, 243, 0.94);
    box-shadow: var(--shadow);
}

.review-hero {
    display: grid;
    gap: 14px;
    padding: 22px;
    background: linear-gradient(135deg, #fff8ed, #fff1dc);
    min-width: 0;
    max-width: 100%;
}

.review-hero p:last-child {
    color: var(--muted);
    margin-bottom: 0;
}

.review-badge,
.warning-badge,
.review-source {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 30px;
    padding: 0 10px;
    border-radius: var(--radius);
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.review-badge {
    background: var(--ink);
    color: #fff;
}

.review-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
}

.warning-badge {
    background: #ffe0b8;
    color: #8a3d00;
}

.review-source {
    background: #eef8f1;
    color: var(--gn);
}

.review-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.review-stats article {
    padding: 14px 10px;
}

.review-stats strong {
    display: block;
    color: var(--es);
    font-size: 1.55rem;
    line-height: 1;
}

.review-stats span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
}

.review-list {
    display: grid;
    gap: 12px;
    min-width: 0;
}

.review-group {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 250, 243, 0.9);
    box-shadow: var(--shadow);
    overflow: hidden;
    min-width: 0;
    max-width: 100%;
}

.review-group summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    min-height: 58px;
    padding: 0 16px;
    cursor: pointer;
    font-weight: 900;
    min-width: 0;
}

.review-group summary strong {
    min-width: 38px;
    min-height: 30px;
    border-radius: var(--radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--es);
    color: #fff;
}

.review-group-body {
    display: grid;
    gap: 12px;
    padding: 0 14px 14px;
    min-width: 0;
}

.review-group-body > p {
    margin: 0;
    color: var(--muted);
}

.review-card {
    display: grid;
    gap: 12px;
    padding: 16px;
    min-width: 0;
    max-width: 100%;
}

.review-card-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    min-width: 0;
}

.review-card-head > div {
    min-width: 0;
}

.review-card h2 {
    margin-top: 8px;
    font-size: 1.08rem;
}

.review-card-head p {
    margin: 6px 0 0;
    color: var(--muted);
    font-weight: 700;
}

.review-gn {
    border-color: var(--gn);
    background: #e7f7eb;
}

.review-gn strong {
    color: #155f39;
    font-size: 1.16rem;
}

.review-status {
    margin: 0;
    color: #8a3d00;
    font-weight: 900;
}

.correction-box {
    display: grid;
    gap: 8px;
}

.correction-box span,
.copy-fallback span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 900;
}

.correction-box div {
    min-height: 72px;
    border: 1px dashed rgba(138, 61, 0, 0.45);
    border-radius: var(--radius);
    background: #fffdf8;
}

.copy-fallback {
    display: none;
    gap: 6px;
}

.copy-fallback textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
    resize: vertical;
    color: var(--ink);
    background: #fffdf8;
}

.no-clipboard .copy-fallback {
    display: grid;
}

.utility-footer {
    padding: 14px 0 4px;
    text-align: center;
}

.utility-footer a {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 800;
}

.bottom-nav {
    position: fixed;
    left: 50%;
    bottom: 10px;
    z-index: 10;
    width: min(940px, calc(100% - 20px));
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 250, 243, 0.96);
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.bottom-nav a {
    min-height: 48px;
    min-width: 0;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 900;
    padding: 6px 4px;
    text-align: center;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

@media (max-width: 380px) {
    .app-shell {
        padding-left: 10px;
        padding-right: 10px;
    }

    .lesson-pager {
        gap: 8px;
    }

    .pager-link {
        font-size: 0.92rem;
        padding-left: 8px;
        padding-right: 8px;
    }

    .bottom-nav {
        width: calc(100% - 12px);
        gap: 4px;
        padding: 5px;
    }

    .bottom-nav a {
        font-size: 0.8rem;
    }
}

.bottom-nav a.is-active {
    background: var(--ink);
    color: #fff;
}

@media (min-width: 720px) {
    .app-shell {
        padding-top: 24px;
    }

    .hero-panel {
        grid-template-columns: minmax(0, 1fr) 260px;
        align-items: end;
        min-height: 360px;
        padding: 34px;
    }

    .today-card {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

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

    .lesson-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .phrase-card {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .review-note {
        grid-column: 1 / -1;
    }

    .favorite-toggle {
        grid-column: 1 / -1;
        justify-self: start;
    }

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

    .review-hero {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: start;
    }

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

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

