/* COSYpractice modern layer: loaded last, overrides legacy hub styles. */
.page { max-width: 1180px; padding: 1.5rem clamp(1rem, 4vw, 2rem) 4rem; margin-inline: auto; }
.daily-challenge-page, .daily-challenge-page .page { background: transparent; }
.daily-challenge-page .page { max-width: 1180px; }

[hidden], .setup-error-banner[hidden], .error-banner-hidden { display: none !important; }
.pe-bottom-bar:not(.active) { visibility: hidden; }

.pm-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 1.5rem; padding: clamp(1.25rem, 4vw, 2.5rem) 0 1.5rem; text-align: left; }
.pm-kicker { margin: 0 0 .4rem; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--ink-muted, #5a5a50); }
.pm-title { margin: 0; font-family: var(--font-serif, Georgia, serif); font-size: clamp(2rem, 5vw, 3.2rem); line-height: 1.08; font-weight: 600; color: var(--ink, #1c1917); text-align: left; }
.pm-lede { margin: .75rem 0 0; max-width: 56ch; font-size: 1.08rem; line-height: 1.55; color: var(--ink-soft, #44403c); }
.pm-streak { justify-self: end; display: flex; flex-direction: column; align-items: center; gap: .35rem; padding: .9rem 1.1rem; background: var(--warm-white, #fffdf8); border: 1px solid var(--border, rgba(74,107,80,.2)); border-radius: 22px; }
@media (max-width: 640px) {
  .pm-hero { grid-template-columns: 1fr; }
  .pm-streak { justify-self: start; flex-direction: row; gap: .9rem; }
}

.pm-details { border: 1px solid var(--border, rgba(74,107,80,.2)); border-radius: 18px; background: var(--warm-white, #fffdf8); padding: .25rem 1rem; }
.pm-details > summary { cursor: pointer; padding: .75rem 0; font-weight: 700; }
.pm-toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); max-width: calc(100vw - 2rem); padding: .65rem 1.1rem; border-radius: 999px; background: var(--ink, #1c1917); color: #fff; font-size: .95rem; z-index: 200; }
.pm-toast:empty { display: none; }
.pm-noscript { padding: 1rem; border-radius: 14px; background: #fff3cd; color: #5b4500; }
.stats-empty-banner { border-radius: 16px; }
.btn-retry-sm { border-radius: 999px; }

html[data-theme="dark"] .pm-title { color: #e8f0e9; }
html[data-theme="dark"] .pm-lede, html[data-theme="dark"] .pm-kicker { color: #b8c7bb; }
html[data-theme="dark"] .pm-streak, html[data-theme="dark"] .pm-details { background: #1a241d; border-color: rgba(255,255,255,.12); }
html[data-theme="dark"] .pm-toast { background: #e8f0e9; color: #141b16; }
html[data-theme="dark"] .daily-challenge-page { background: transparent; }

/* Dark mode: the legacy sheet defines its palette in :root; remap it. */
html[data-theme="dark"] {
  color-scheme: dark;
  --cream: #101712; --warm-white: #1a241d; --ink: #e8f0e9; --ink-muted: #b8c7bb; --ink-faint: #9fb0a3;
  --border: rgba(255,255,255,.13); --border-hover: rgba(255,255,255,.28);
  --teal: #6fd0bf; --teal-light: #173a34; --teal-dark: #8fe0d1;
  --gold: #f3c969; --gold-light: #3a3012; --coral: #ff9a76; --coral-light: #402219;
  --plum: #d3a8e6; --plum-light: #2d2036; --blue: #8fb6f0; --blue-light: #1b2a42;
  --green: #86d39a; --green-light: #1a3322;
}
html[data-theme="dark"] body, html[data-theme="dark"] .page { background: var(--cream); color: var(--ink); }
/* Surfaces that use --ink as a dark fill must stay dark when --ink turns light. */
html[data-theme="dark"] :is(.btn-start, .pe-topbar, .lang-pill.active, #toast, .daily-challenge, .pe-btn-next, .pe-bb-action-btn, .lang-more-wrap.active .lang-more-select) { background: #0b110d; color: #e8f0e9; border-color: rgba(255,255,255,.2); }
html[data-theme="dark"] .btn-start { background: #f3c969; color: #1c1917; border-color: #f3c969; font-weight: 700; }
html[data-theme="dark"] .lang-pill.active { background: #e8f0e9; color: #101712; }
html[data-theme="dark"] .dc-btn { background: #f3c969; color: #1c1917; font-weight: 700; }
html[data-theme="dark"] .task-tip { background: #3a3012; color: #f3dfa0; border-color: #f3c969; }
html[data-theme="dark"] .micro-block { background: #2d2036; border-color: rgba(255,255,255,.12); } html[data-theme="dark"] .micro-title { color: #e8d2f2; }

/* ── HUB CARDS & CONTAINERS DARK MODE OVERRIDES ── */

html[data-theme="dark"] .dash-stat {
  background: #1e2a21;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e8f0e9;
}
html[data-theme="dark"] .dash-stat:hover {
  border-color: rgba(255, 255, 255, 0.28);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] .setup-panel {
  background: #18221b;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e8f0e9;
}

html[data-theme="dark"] .info-card {
  background: #18221b;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e8f0e9;
}
html[data-theme="dark"] .speaking-bridge-card {
  background: linear-gradient(135deg, #162a24, #121d18);
  border-color: #26695e;
}
html[data-theme="dark"] .bridge-title {
  color: #e8f0e9;
}
html[data-theme="dark"] .styled-select {
  background-color: #1a261f;
  border-color: rgba(255, 255, 255, 0.16);
  color: #e8f0e9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23A8BAA9' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}
html[data-theme="dark"] .styled-select option {
  background: #1a261f;
  color: #e8f0e9;
}
html[data-theme="dark"] .lang-pill {
  background: #1a261f;
  border-color: rgba(255, 255, 255, 0.15);
  color: #c8d8c9;
}
html[data-theme="dark"] .lang-pill:hover {
  border-color: rgba(255, 255, 255, 0.35);
  color: #ffffff;
}
html[data-theme="dark"] .lang-more-select {
  background-color: #1a261f;
  border-color: rgba(255, 255, 255, 0.15);
  color: #c8d8c9;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23A8BAA9' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
}
html[data-theme="dark"] .lang-more-select option {
  background: #1a261f;
  color: #e8f0e9;
}
html[data-theme="dark"] .cat-pill {
  background: #1a261f;
  border-color: rgba(255, 255, 255, 0.15);
  color: #c8d8c9;
}
html[data-theme="dark"] .cat-pill:hover {
  border-color: rgba(255, 255, 255, 0.35);
  color: #ffffff;
}
html[data-theme="dark"] .btn-outline {
  border-color: rgba(255, 255, 255, 0.2);
  color: #c8d8c9;
}
html[data-theme="dark"] .btn-outline:hover {
  border-color: rgba(255, 255, 255, 0.4);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}
html[data-theme="dark"] .setup-error-banner {
  background-color: #381b16;
  border-color: rgba(248, 113, 113, 0.3);
  color: #fca5a5;
}

.sec-title > span:first-child { font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; }

/* ── EXERCISE ENGINE & QUESTION CONTRAST ── */
html[data-theme="dark"] .practice-engine {
  background: #18221b;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e8f0e9;
}
html[data-theme="dark"] .pe-question-card {
  background: #1e2a21;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e8f0e9;
}
html[data-theme="dark"] .pe-question .q-word {
  background: #19382e;
  color: #79ddcb;
  border-color: #3b8e7e;
}
html[data-theme="dark"] .pe-question .q-target {
  background: rgba(255, 255, 255, 0.06);
  color: #c8d8c9;
  border-color: rgba(255, 255, 255, 0.2);
}
html[data-theme="dark"] .pe-question .q-definition {
  color: #c8d8c9;
}
html[data-theme="dark"] .mc-opt {
  background: #1e2a21;
  border-color: rgba(255, 255, 255, 0.15);
  color: #e8f0e9;
}
html[data-theme="dark"] .mc-opt:hover:not(:disabled) {
  background: #183329;
  border-color: #6fd0bf;
  color: #6fd0bf;
}
html[data-theme="dark"] .mc-opt.correct {
  background: #1a3322;
  border-color: #86d39a;
  color: #86d39a;
}
html[data-theme="dark"] .mc-opt.wrong {
  background: #3b1e19;
  border-color: #ff9a76;
  color: #ff9a76;
}
html[data-theme="dark"] .type-input {
  background: #1e2a21;
  border-color: rgba(255, 255, 255, 0.18);
  color: #e8f0e9;
}
html[data-theme="dark"] .type-input:focus {
  border-color: #6fd0bf;
  outline: none;
}
html[data-theme="dark"] .type-input.correct {
  background: #1a3322;
  border-color: #86d39a;
  color: #86d39a;
}
html[data-theme="dark"] .type-input.wrong {
  background: #3b1e19;
  border-color: #ff9a76;
  color: #ff9a76;
}
html[data-theme="dark"] .tf-btn {
  background: #1e2a21;
  border-color: rgba(255, 255, 255, 0.15);
  color: #c8d8c9;
}
html[data-theme="dark"] .tf-btn-true:hover:not(:disabled) {
  background: #1a3322;
  border-color: #86d39a;
  color: #86d39a;
}
html[data-theme="dark"] .tf-btn-false:hover:not(:disabled) {
  background: #3b1e19;
  border-color: #ff9a76;
  color: #ff9a76;
}
html[data-theme="dark"] .tf-btn.correct {
  background: #1a3322;
  border-color: #86d39a;
  color: #86d39a;
}
html[data-theme="dark"] .tf-btn.wrong {
  background: #3b1e19;
  border-color: #ff9a76;
  color: #ff9a76;
}
html[data-theme="dark"] .pe-bottom-bar.correct {
  background-color: #12281a;
  border-top-color: #86d39a;
}
html[data-theme="dark"] .pe-bottom-bar.correct .pe-bb-title {
  color: #86d39a;
}
html[data-theme="dark"] .pe-bottom-bar.correct .pe-bb-desc {
  color: #c8e6d0;
}
html[data-theme="dark"] .pe-bottom-bar.incorrect {
  background-color: #331714;
  border-top-color: #ff9a76;
}
html[data-theme="dark"] .pe-bottom-bar.incorrect .pe-bb-title {
  color: #ff9a76;
}
html[data-theme="dark"] .pe-bottom-bar.incorrect .pe-bb-desc {
  color: #f7c3b5;
}
html[data-theme="dark"] .pe-bb-action-btn {
  background: #f3c969;
  color: #1c1917;
  font-weight: 700;
}

/* ── DAILY CHALLENGE STYLES & CONTRAST ── */
html[data-theme="dark"] .challenge-card {
  background: #18221b;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e8f0e9;
}
html[data-theme="dark"] .card-header {
  background: #1e2a21;
  border-color: rgba(255, 255, 255, 0.12);
  color: #e8f0e9;
}
html[data-theme="dark"] .challenge-title {
  color: #e8f0e9;
}
html[data-theme="dark"] .challenge-subtitle {
  color: #a8baa9;
}
html[data-theme="dark"] .level-tabs {
  background: #18221b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
html[data-theme="dark"] .ltab {
  color: #a8baa9;
}
html[data-theme="dark"] .ltab.on {
  background: #243528;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
html[data-theme="dark"] .day-badge {
  background: #16362d;
  color: #72dac6;
}
html[data-theme="dark"] .day-type-badge {
  background: #33233b;
  color: #e2b9f7;
}
html[data-theme="dark"] .micro-instruction {
  color: #e8f0e9;
}
html[data-theme="dark"] .micro-example {
  background: rgba(0, 0, 0, 0.25);
  color: #d8e5d9;
}

/* While a session is running, keep the screen focused: hide the recent-activity / weak-spots cards */
body:has(#practice-section:not(.hidden)) #activity-section,
body:has(#practice-section:not(.hidden)) #speaking-club-bridge-card{display:none !important}

/* Dark-mode contrast lifts */
html[data-theme="dark"] .tbtn.go { background: #2f6f55; color: #fff; }
html[data-theme="dark"] .tbtn.stop { background: transparent; color: #cfe3d2; border: 1px solid rgba(255,255,255,.25); }
html[data-theme="dark"] .pg-back, html[data-theme="dark"] .ccq-back { color: #9fd3aa; }
html[data-theme="dark"] .hero-badge, html[data-theme="dark"] .vac-translation, html[data-theme="dark"] .cognate-root { color: #cfe3d2; }
