/* Shared visual theme. Screen-only rules leave the existing print layouts intact. */
@media screen {
    :root {
        --primary: #32755d; --primary-dark: #235541; --primary-light: #9dc9af;
        --success: #367c60; --error: #c6564e; --warning: #ad741c; --info: #467c9e;
        --bg-primary: #f0f5ed; --bg-secondary: #fffefa; --bg-accent: #fff2d9;
        --text-primary: #2d4036; --text-secondary: #667168; --text-light: #717d72;
        --border: #dfe6d9; --shadow: 0 3px 16px #38543b06;
        --shadow-hover: 0 8px 24px #38543b12;
        --rainbow-1: #df8c75; --rainbow-2: #e6b66b; --rainbow-3: #d7b45c;
        --rainbow-4: #82b297; --rainbow-5: #8daebe;
    }
    html { scroll-behavior: smooth; scroll-padding-top: 24px; }
    body { background: #f7f8f2; color: var(--text-primary); font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif; font-size: 16px; line-height: 1.65; padding: 0; }
    button, input, textarea, select { font-family: inherit; }
    button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
    button:focus-visible, a:focus-visible, [tabindex]:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid #d39840; outline-offset: 4px; }
    .skip-link { position: fixed; top: -80px; left: 16px; padding: 12px 20px; background: white; color: var(--primary); z-index: 2000; border-radius: 12px; }
    .skip-link:focus { top: 12px; }
    .garden-page #app { max-width: 1600px; min-height: 100vh; display: grid; grid-template-columns: 230px minmax(0,1fr); grid-template-rows: auto 1fr auto; margin: 0 auto; }
    .garden-page .app-header { grid-column: 1; grid-row: 1 / 4; position: sticky; top: 0; align-self: start; height: 100vh; overflow-y: auto; padding: 34px 20px 24px; margin: 0; background: #fffef9; border-right: 1px solid #e7eadd; border-radius: 0; box-shadow: none; display: flex; flex-direction: column; }
    .app-header-top { margin-bottom: 34px; }
    .garden-brand { display: flex; gap: 10px; align-items: center; color: inherit; text-decoration: none; }
    .brand-mark { display: grid; place-items: center; width: 43px; height: 48px; border-radius: 16px 16px 18px 7px; background: #e8f0d9; font-size: 28px; flex-shrink: 0; }
    .app-header .garden-brand h1 { color: #2f614b; background: none; -webkit-text-fill-color: currentColor; font-size: 18px; letter-spacing: .5px; white-space: nowrap; }
    .garden-brand small { display: block; font-size: 9px; font-weight: 700; color: #7e8c72; letter-spacing: 2px; margin-top: 3px; }
    .nav-buttons { flex-direction: column; gap: 7px; }
    .nav-caption { color: #899180; font-size: 11px; letter-spacing: 1.4px; padding: 0 14px 7px; margin-top: 17px; }
    .nav-caption:first-child { margin-top: 0; }
    .nav-btn, .nav-audio { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 47px; padding: 11px 16px; border-radius: 11px; background: transparent; color: #617061; text-align: left; font-size: 14px; font-weight: 600; text-decoration: none; border: 1px solid transparent; transition: background .18s, color .18s; }
    .nav-btn > span, .nav-audio > span { width: 24px; text-align: center; font-size: 20px; line-height: 1; }
    .nav-btn:hover, .nav-audio:hover { background: #edf3e8; color: var(--primary); transform: none; }
    .nav-btn.active { background: #e6efdf; color: #326747; border-color: #e0e9d7; }
    .nav-btn.active::after { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #729864; margin-left: auto; }
    .sidebar-note { margin-top: auto; padding: 36px 10px 0; font-size: 12px; color: #818b77; text-align: center; }
    .sidebar-note > span { display: block; font-size: 31px; margin-bottom: 10px; }
    .sidebar-note strong { font-size: 12px; font-weight: 600; }
    .sidebar-note p { font-size: 10px; margin-top: 5px; }
    .garden-page .app-main { grid-column: 2; grid-row: 2; min-width: 0; padding: 0 40px 24px; }
    .garden-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 88px; color: #849079; font-size: 11px; font-weight: 650; letter-spacing: 1.4px; }
    .garden-topbar-note { font-size: 12px; font-weight: 400; letter-spacing: .3px; color: #7a8274; }
    .garden-topbar-note > span { margin-left: 12px; font-size: 20px; }
    .garden-page .alert { grid-column: 2; grid-row: 1; margin: 12px 40px 0; }
    #home-view.active { display: flex; flex-direction: column; }
    #manage-view.active, #starred-view.active, #wrong-view.active { display: flex; flex-direction: column; flex: 1; min-height: 0; }
    #manage-view.active > .card, #starred-view.active > .card, #wrong-view.active > .card { flex: 1; display: flex; flex-direction: column; min-height: 0; }
    #manage-view .word-list, #starred-view .word-list, #wrong-view .word-list { flex: 1; min-height: 0; max-height: none; overflow-y: auto; overflow-x: hidden; }
    .garden-page #app:has(#manage-view.active), .garden-page #app:has(#starred-view.active), .garden-page #app:has(#wrong-view.active) { height: 100vh; grid-template-rows: auto minmax(0, 1fr) auto; }
    .garden-page .app-main:has(#manage-view.active), .garden-page .app-main:has(#starred-view.active), .garden-page .app-main:has(#wrong-view.active) { overflow: hidden; }
    .garden-hero { order: 0; position: relative; display: flex; align-items: center; justify-content: space-between; min-height: 286px; background: #e7efdf; border: 1px solid #dfe7d5; border-radius: 24px; padding: 32px 34px; overflow: hidden; margin-bottom: 30px; }
    .hero-copy { position: relative; z-index: 1; flex: 1 0 52%; }
    .eyebrow { display: block; font-size: 10px; letter-spacing: 2px; color: #7f9274; font-weight: 700; margin-bottom: 8px; }
    .hero-copy h2 { font-size: clamp(25px,2.4vw,37px); line-height: 1.5; letter-spacing: 1px; font-weight: 750; color: #31553d; margin: 0 0 12px; }
    .hero-copy h2 > span { color: #d39850; }
    .hero-copy p { color: #70816c; font-size: 13px; line-height: 1.9; }
    .hero-link { display: inline-flex; align-items: center; gap: 23px; padding: 10px 18px; background: #397454; color: white; text-decoration: none; border-radius: 10px; font-size: 13px; font-weight: 600; margin-top: 19px; box-shadow: 0 3px 0 #2a5a40; transition: background .2s; }
    .hero-link:hover { background: #285d41; }
    .hero-art { width: 43%; height: auto; max-height: 285px; object-fit: contain; align-self: center; margin: -16px -8px -10px -20px; }
    .hero-sticker { position: absolute; bottom: 15px; right: 40px; font-size: 10px; color: #7d9675; letter-spacing: 1px; transform: rotate(-4deg); }
    .card { border: 1px solid #e4e8dc; box-shadow: var(--shadow); padding: 26px; border-radius: 20px; margin-bottom: 20px; }
    .card h2 { color: #36533e; font-size: 22px; }
    .card h3 { color: #4f6553; }
    .learning-overview { order: 1; padding: 0; border: 0; background: transparent; box-shadow: none; margin: 0 0 18px; }
    .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
    .section-heading h2 { font-size: 22px; margin: 0; }
    .text-link { color: #6b8066; font-size: 12px; text-decoration: none; border-bottom: 1px solid #b8c6ad; padding-bottom: 2px; white-space: nowrap; }
    .text-link:hover { color: var(--primary-dark); }
    .learning-overview .stats { display: grid; grid-template-columns: 1.35fr repeat(3,1fr); margin: 0; gap: 0; background: #fffefa; border: 1px solid #e4e8dc; border-radius: 14px; padding: 14px 6px; }
    .learning-overview .stat-item { padding: 0 18px; background: none; border-radius: 0; text-align: left; display: flex; flex-direction: column; justify-content: center; min-width: 0; border-right: 1px solid #e9ebdf; }
    .learning-overview .stat-item:last-child { border-right: 0; }
    .learning-overview .stat-item .number { font-size: 22px; line-height: 1.25; color: #3d6046; overflow-wrap: anywhere; }
    .learning-overview .stat-item:first-child .number { font-size: 17px; }
    .learning-overview .stat-item:nth-child(3) .number { color: #ac8537; }
    .learning-overview .stat-item:nth-child(4) .number { color: #be816b; }
    .learning-overview .stat-item .label { font-size: 11px; margin-top: 6px; color: #88907e; }
    .mode-cards { order: 2; gap: 14px; grid-template-columns: repeat(3,minmax(0,1fr)); margin-bottom: 30px; }
    .mode-card { --tile: #edf3e5; --tile-ink: #648258; position: relative; border: 1px solid #e4e8dc !important; border-radius: 17px; background: #fffefa; text-align: left; padding: 20px 21px 15px; color: var(--text-primary); box-shadow: none; font: inherit; overflow: hidden; }
    .mode-card:hover { transform: translateY(-3px); border-color: #bbcbb0 !important; box-shadow: var(--shadow-hover); }
    .mode-card:nth-child(2) { --tile: #fff0d8; --tile-ink: #a07f40; }
    .mode-card:nth-child(3) { --tile: #e7eff6; --tile-ink: #5e839f; }
    .mode-card:nth-child(4) { --tile: #f7e9e4; --tile-ink: #b67f69; }
    .mode-card:nth-child(5) { --tile: #f0ebf7; --tile-ink: #9381aa; }
    .mode-card:nth-child(6) { --tile: #e9f1eb; --tile-ink: #65927a; }
    .mode-card .icon { display: grid; place-items: center; background: var(--tile); border-radius: 13px; width: 45px; height: 45px; font-size: 25px; margin-bottom: 13px; }
    .mode-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 5px; }
    .mode-card p { font-size: 13px; line-height: 1.7; color: #727c6c; }
    .mode-action { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid #eeeee5; margin-top: 15px; padding-top: 11px; color: var(--tile-ink); font-size: 11px; }
    .mode-action > span { font-size: 18px; line-height: 1; }
    .group-list-container { order: 3; background: #fffefa; border-radius: 20px; border: 1px solid #e4e8dc; padding: 24px; box-shadow: none; margin: 0; scroll-margin-top: 24px; }
    .group-list-header { margin-bottom: 20px; gap: 18px; }
    .group-list-header h2 { font-size: 21px; color: #36533e; }
    .section-description { font-size: 12px; color: #89907e; margin-top: 5px; }
    .group-controls { width: 100%; gap: 8px; padding-top: 15px; border-top: 1px solid #eeeee5; }
    .group-controls select { flex: 1; max-width: 240px; min-width: 110px; min-height: 40px; border: 1px solid #dce5d5; border-radius: 9px; font-size: 13px; color: #4c654f; background: #f7f9f2; }
    .group-controls .group-btn { min-height: 40px; padding: 8px 12px; border-radius: 9px; background: #eaf1e1; color: #4d7350; font-size: 12px; }
    .group-controls .group-btn.rename { background: #eaf0f3; color: #5d7d8f; }
    .group-controls .group-btn.delete { background: #f9eeea; color: #af7864; }
    .group-grid { grid-template-columns: repeat(5,minmax(0,1fr)); gap: 10px; }
    .group-folder { border: 1px solid #e5e9dc; border-radius: 12px; background: #f8f9f3; padding: 14px 8px 12px; transition: background .18s, border-color .18s; }
    .group-folder:hover { background: #f0f5e9; border-color: #c2d1b5; box-shadow: none; transform: translateY(-2px); }
    .group-folder.active { background: #e8f1df; border-color: #8aac76; box-shadow: inset 0 0 0 1px #8aac76; }
    .group-folder .folder-icon { font-size: 25px; margin: 2px 0 7px; }
    .group-folder .folder-name { font-size: 13px; line-height: 1.5; color: #47603f; }
    .group-folder .folder-count { color: #88917b; font-size: 11px; margin-top: 3px; }
    .group-folder .folder-actions { top: 3px; right: 3px; }
    .group-folder:focus-within .folder-actions { opacity: 1; }
    .folder-action-btn { width: 27px; height: 27px; font-size: 11px; box-shadow: none; border: 1px solid #e1e6d8; }
    .pagination { border-top: 1px solid #eeeee5; padding-top: 20px; margin-top: 20px; gap: 7px; }
    .page-btn { border-radius: 8px; min-height: 36px; }
    .garden-footer { grid-column: 2; grid-row: 3; display: flex; justify-content: space-between; gap: 14px; padding: 12px 40px 28px; color: #909781; font-size: 11px; }
    .garden-footer > span { font-size: 9px; letter-spacing: 1px; }
    .btn { border-radius: 11px; font-size: 15px; padding: 11px 21px; min-height: 44px; box-shadow: none; }
    .btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px #304c3814; }
    input[type="text"], input[type="number"], textarea { border: 1px solid #cbd9bf; background: #fffffc; font-size: 16px; border-radius: 10px; }
    .word-item { background: #f3f6ed; border: 1px solid #e8eddf; }
    .word-item:hover { transform: none; background: #eef3e5; }
    .word-number { background: #c38c5a; }
    .options { gap: 14px; }
    .option-btn { background: #f3f6ed; border: 2px solid #e3ead9; color: #3b543b; }
    .option-btn.correct, .option-btn.wrong { color: white; }
    .progress-bar { height: 12px; }
    .progress-fill { background: #80af83; }
    .text-card { background: #f8faf2; border-color: #e0e7d6; box-shadow: none; border-radius: 14px; }
    .text-card:hover { background: #eff5e8; border-color: #a7bf91; box-shadow: var(--shadow); }
    .text-reader-content { background: #fffdf6; border: 1px solid #e8e8d9; }
    .yuxi-section-title { color: #3d6548; }
    .modal-content { max-height: 88vh; overflow: auto; border: 1px solid #e0e7d6; box-shadow: 0 20px 70px #20372724; }

    /* The independent listening page uses the same palette and spacing. */
    .garden-audio #app { max-width: 1080px; padding: 34px 32px; min-height: 100vh; }
    .garden-audio .app-header { padding: 0 0 24px; background: none; box-shadow: none; border-radius: 0; border-bottom: 1px solid #e0e6d7; margin-bottom: 24px; }
    .garden-audio .app-header h1 { font-size: 25px; color: #36533e; -webkit-text-fill-color: currentColor; background: none; }
    .audio-welcome { background: #e7efdf; border-radius: 20px; padding: 26px 30px; display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
    .audio-welcome h2 { font-size: 26px; color: #365b42; margin-bottom: 7px; }
    .audio-welcome p { font-size: 14px; color: #74806a; }
    .audio-welcome > span { font-size: 57px; padding-left: 20px; }
    .audio-card { border: 1px solid #e0e6d7; padding: 23px; border-radius: 16px; }
    .audio-card.active { background: #eaf3e3; border-color: #89ad77; }
    .audio-card-icon { background: #eef3e5; }
    .audio-card-body { min-width: 0; }
    .audio-card-name { overflow-wrap: anywhere; }
    .garden-audio .player-bar { max-width: 1016px; border: 1px solid #dae3d1; box-shadow: 0 8px 35px #2a472518; border-radius: 18px; }
    .back-link { background: #edf2e5; color: #4f734b; }
    .back-link:hover { background: #3d7655; }
    @media (min-width: 1601px) { .garden-page #app { border-left: 1px solid #e7eadd; border-right: 1px solid #e7eadd; } }
    @media (max-width: 1150px) {
        .garden-page #app { grid-template-columns: 200px minmax(0,1fr); }
        .garden-page .app-header { padding: 28px 14px 20px; }
        .app-header .garden-brand h1 { font-size: 16px; }
        .brand-mark { width: 36px; font-size: 24px; }
        .garden-page .app-main { padding: 0 25px 24px; }
        .hero-copy h2 { font-size: 27px; }
        .garden-hero { padding: 26px; min-height: 270px; }
        .hero-art { width: 42%; }
        .garden-footer { padding-left: 25px; padding-right: 25px; }
        .group-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
        .mode-card { padding: 17px 16px 13px; }
    }
    @media (max-width: 850px) {
        .garden-page #app { display: flex; }
        .garden-page .app-header { position: relative; width: 100%; height: auto; overflow: visible; border-right: 0; border-bottom: 1px solid #e7eadd; padding: 18px 24px 14px; }
        .app-header-top { margin-bottom: 15px; }
        .garden-brand { gap: 12px; }
        .app-header .garden-brand h1 { font-size: 19px; }
        .brand-mark { width: 40px; height: 43px; }
        .garden-brand small { font-size: 8px; }
        .nav-buttons { flex-direction: row; display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 5px; }
        .nav-caption, .sidebar-note { display: none; }
        /* Keep the full lesson names on one line, including landscape phones. */
        .nav-btn, .nav-audio { flex-direction: column; min-width: 0; padding: 9px 4px; font-size: 13px; line-height: 1.4; min-height: 58px; gap: 6px; justify-content: center; text-align: center; white-space: nowrap; }
        .nav-btn > span, .nav-audio > span { font-size: 17px; width: 19px; flex-shrink: 0; }
        .nav-btn.active::after { display: none; }
        .garden-page .app-main { padding: 0 24px 24px; }
        .garden-topbar { min-height: 65px; }
        .garden-topbar-note { font-size: 11px; }
        .garden-topbar > span:first-child { font-size: 10px; }
        .garden-hero { min-height: 252px; }
        .hero-art { max-width: 290px; }
        .hero-copy h2 { font-size: 28px; }
        .garden-footer { padding: 0 24px 24px; }
        .garden-page .alert { margin: 12px 24px 0; }
    }
    @media (max-width: 600px) {
        .garden-page .app-header { padding: 15px 13px 12px; }
        .app-header-top { margin: 0 4px 13px; }
        .nav-btn, .nav-audio { font-size: clamp(11px, 3vw, 12px); padding: 8px 2px; min-height: 54px; gap: 5px; border-radius: 8px; }
        .nav-btn > span, .nav-audio > span { width: 15px; font-size: 15px; }
        .garden-page .app-main { padding: 0 15px 20px; }
        .garden-topbar { min-height: 49px; }
        .garden-topbar-note { display: none; }
        .garden-hero { padding: 24px 20px; min-height: 235px; margin-bottom: 23px; border-radius: 18px; }
        .hero-copy { flex-basis: 100%; }
        .hero-copy h2 { font-size: 24px; line-height: 1.5; letter-spacing: 0; }
        .hero-copy p { font-size: 12px; max-width: 76%; }
        .hero-copy .eyebrow { font-size: 8px; letter-spacing: 1.8px; }
        .hero-link { font-size: 12px; gap: 10px; padding: 10px 12px; margin-top: 15px; }
        .hero-art { position: absolute; width: 42%; right: -9px; bottom: 4px; margin: 0; }
        .hero-sticker { display: none; }
        .eyebrow { font-size: 8px; letter-spacing: 1.5px; }
        .section-heading { gap: 8px; }
        .section-heading h2 { font-size: 20px; }
        .text-link { font-size: 11px; }
        .learning-overview .stats { padding: 13px 0; grid-template-columns: 1.25fr repeat(3,1fr); }
        .learning-overview .stat-item { padding: 0 10px; }
        .learning-overview .stat-item .number { font-size: 20px; }
        .learning-overview .stat-item:first-child .number { font-size: 13px; }
        .learning-overview .stat-item .label { font-size: 10px; }
        .mode-cards { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; margin-bottom: 23px; }
        .mode-card { border-radius: 14px; padding: 15px 13px 12px; }
        .mode-card .icon { width: 39px; height: 39px; font-size: 23px; margin-bottom: 10px; }
        .mode-card h3 { font-size: 15px; }
        .mode-card p { font-size: 12px; min-height: 41px; }
        .mode-action { margin-top: 10px; padding-top: 9px; font-size: 10px; }
        .group-list-container { padding: 18px 13px; border-radius: 16px; }
        .group-list-header h2 { font-size: 19px; }
        .section-description { font-size: 11px; }
        .group-controls { gap: 7px; }
        .group-controls > label { font-size: 12px; }
        .group-controls select { max-width: none; }
        .group-controls .group-btn { padding: 8px; font-size: 11px; }
        .group-grid { grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; }
        .group-folder { padding: 20px 6px 12px; }
        .group-folder .folder-name { font-size: 12px; }
        .group-folder .folder-count { font-size: 10px; }
        .card { padding: 20px 16px; border-radius: 16px; }
        .learning-overview { padding: 0; border-radius: 0; }
        .btn-group { gap: 8px; }
        .btn { font-size: 13px; padding: 10px 13px; }
        .word-item { flex-wrap: wrap; }
        .word-item .english { overflow-wrap: anywhere; }
        .garden-footer { padding: 0 15px 24px; flex-direction: column; text-align: center; gap: 5px; }
        .garden-audio #app { padding: 22px 16px; }
        .garden-audio .app-header h1 { font-size: 21px; }
        .audio-welcome { padding: 22px 20px; }
        .audio-welcome h2 { font-size: 23px; }
        .audio-welcome p { font-size: 12px; }
        .audio-welcome > span { font-size: 40px; }
        .audio-list { grid-template-columns: minmax(0,1fr); }
        .garden-audio .player-bar { padding: 12px 14px; }
    }
    @media (hover: none) { .group-folder .folder-actions, .text-card .text-card-actions { opacity: 1; } }
    @media (prefers-reduced-motion: reduce) {
        html { scroll-behavior: auto; }
        *, *::before, *::after { animation: none !important; transition: none !important; }
    }
}
@media print {
    .skip-link, .garden-hero { display: none !important; }
}
