:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #5f6b82;
  --line: #e2d9c8;
  --page: #f5f1ea;
  --panel: #ffffff;
  --blue: #0f766e;
  --blue-weak: #ccede9;
  --green: #14735a;
  --green-weak: #ddf4ea;
  --amber: #9b5c00;
  --amber-weak: #fff3d6;
  --teal-weak: #dff4f1;
  --surface-soft: #faf8f3;
  --rose: #ca3b58;
  --shadow: 0 18px 45px rgba(28, 40, 67, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: #faf8f3;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

/* ── App shell / sidebar ────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  width: 220px;
  height: 100vh;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
  background: #ffffff;
  transition: width 0.22s ease;
  overflow: hidden;
  z-index: 20;
}

.app-shell.sidebar-collapsed .sidebar {
  width: 60px;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-brand-text {
  transition: opacity 0.15s;
}

.app-shell.sidebar-collapsed .sidebar-brand-text {
  opacity: 0;
  pointer-events: none;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  background: #0f766e;
  color: white;
  font-weight: 900;
  font-size: 0.85rem;
}

.sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.sidebar-collapse-btn:hover {
  background: var(--blue-weak);
  color: #065f46;
}

.collapse-arrow {
  display: inline-block;
  transition: transform 0.22s;
  font-style: normal;
  line-height: 1;
}

.app-shell.sidebar-collapsed .collapse-arrow {
  transform: rotate(180deg);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 8px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  text-align: left;
}

.sidebar-item:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.sidebar-item.active {
  background: var(--blue-weak);
  color: #065f46;
}

.sidebar-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
}

.sidebar-label {
  transition: opacity 0.15s;
  overflow: hidden;
}

.app-shell.sidebar-collapsed .sidebar-label {
  opacity: 0;
  width: 0;
  pointer-events: none;
}

.sidebar-stats {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 8px 14px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-stats .stat-pill {
  justify-content: flex-start;
  border-radius: 8px;
  font-size: 0.8rem;
}

/* ── Sidebar groups ─────────────────────────────────────── */
.sidebar-group {
  display: flex;
  flex-direction: column;
}

.sidebar-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: background 0.12s, color 0.12s;
}

.sidebar-group-header:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.sidebar-group-header.group-active {
  color: var(--ink);
}

.sr-group.group-active {
  color: #065f46;
}

.mem-group.group-active {
  color: #4f46e5;
}

.group-chevron {
  margin-left: auto;
  display: inline-block;
  transition: transform 0.2s ease;
  font-style: normal;
}

.sidebar-group.group-open .group-chevron {
  transform: rotate(90deg);
}

.sidebar-group-items {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.22s ease;
}

.sidebar-group.group-open .sidebar-group-items {
  max-height: 400px;
}

.sidebar-group-items .sidebar-item {
  padding-left: 18px;
}

/* Hide group chevron in icon-only mode */
.app-shell.sidebar-collapsed .group-chevron {
  display: none;
}

/* In icon-only mode, show group header icon only */
.app-shell.sidebar-collapsed .sidebar-group-header {
  justify-content: center;
  padding: 9px 10px;
}

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding: 8px 8px 12px;
  flex-shrink: 0;
}

/* Main area (right of sidebar) */
.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Mobile topbar (hidden on desktop) */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.mobile-topbar .brand {
  flex: 1;
}

.hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* Backdrop for mobile drawer */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(23, 32, 51, 0.35);
  z-index: 19;
  backdrop-filter: blur(2px);
}

/* Shared stats pills */
.topbar-stats {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.stat-streak {
  background: #fff8eb;
  border: 1px solid #f0c060;
  color: #92400e;
}

.stat-sessions {
  background: var(--blue-weak);
  border: 1px solid var(--teal-weak);
  color: #065f46;
}

/* Buttons */
.ghost-button,
.primary-button,
.icon-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  background: transparent;
  color: var(--ink);
  white-space: nowrap;
}

.primary-button {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
  font-weight: 750;
}

.ghost-button {
  border-color: var(--line);
  background: white;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
  border-color: var(--line);
  background: white;
}

.main {
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 28px clamp(18px, 3vw, 44px) 56px;
}

/* ── Listen ─────────────────────────────────────────────── */
.listen-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.listen-method-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  gap: 18px;
  padding: clamp(16px, 2vw, 22px);
  border: 1px solid #c7e3df;
  border-radius: 8px;
  background: #eef8f7;
}

.listen-method-copy h3 {
  margin: 10px 0 8px;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
}

.listen-method-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.listen-benefits {
  display: grid;
  gap: 10px;
}

.listen-benefits div {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid #c7e3df;
  border-radius: 8px;
  background: #ffffff;
}

.listen-benefits span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.listen-selectors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.listen-select-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.listen-select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 0.92rem;
  color: var(--ink);
}

.listen-text-wrap {
  max-height: 380px;
  overflow-y: auto;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  line-height: 2;
  font-size: 1.05rem;
  color: var(--ink);
}

.listen-word {
  display: inline;
  border-radius: 3px;
  padding: 1px 2px;
  transition: background 0.08s, color 0.08s;
}

.listen-word.word-active {
  background: var(--blue);
  color: #ffffff;
  border-radius: 4px;
}

.listen-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
}

.listen-btns {
  display: flex;
  gap: 10px;
}

.listen-speed-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-left: auto;
}

@media (max-width: 600px) {
  .listen-method-panel {
    grid-template-columns: 1fr;
  }
  .listen-selectors {
    grid-template-columns: 1fr;
  }
  .listen-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .listen-speed-row {
    margin-left: 0;
  }
  .listen-btns {
    width: 100%;
  }
  .listen-btns .primary-button,
  .listen-btns .ghost-button {
    flex: 1;
  }
}

.listen-speed-btn {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.listen-speed-btn:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.listen-speed-btn.active {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

/* ── Speaking ───────────────────────────────────────────── */
.speaking-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.speaking-intro-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.9fr);
  gap: 18px;
  padding: clamp(16px, 2vw, 22px);
  border: 1px solid #d7c7ff;
  border-radius: 8px;
  background: #f6f2ff;
}

.speaking-method-copy h3 {
  margin: 10px 0 8px;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
}

.speaking-method-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.speaking-benefits,
.speaking-steps {
  display: grid;
  gap: 10px;
}

.speaking-benefits div {
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 1px solid #d7c7ff;
  border-radius: 8px;
  background: #ffffff;
}

.speaking-benefits span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.speaking-practice {
  display: grid;
  gap: 16px;
  padding: clamp(16px, 2vw, 22px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

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

.speaking-prompt {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid #d7c7ff;
  border-radius: 8px;
  background: #ffffff;
}

@media (max-width: 860px) {
  .speaking-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .speaking-intro-panel,
  .speaking-steps {
    grid-template-columns: 1fr;
  }
}


.speaking-techniques-panel {
  display: grid;
  gap: 16px;
  padding: clamp(16px, 2vw, 22px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.speaking-tech-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.tech-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  transition: transform 0.2s, box-shadow 0.2s;
}

.tech-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(23, 32, 51, 0.05);
}

.tech-card h4 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tech-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.tech-card .example {
  font-size: 0.85rem;
  font-style: italic;
  background: var(--panel);
  padding: 8px;
  border-radius: 6px;
  border-left: 3px solid var(--blue);
  margin-top: auto;
}

/* ── Home page ──────────────────────────────────────────── */
.home-hero {
  text-align: center;
  padding: clamp(32px, 6vw, 64px) clamp(16px, 4vw, 48px);
  margin-bottom: 20px;
}

.home-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.home-sub {
  margin: 0 0 24px;
  font-size: clamp(0.95rem, 2vw, 1.15rem);
}

.home-privacy-strip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 720px;
  padding: 10px 14px;
  border: 1px solid #bfe8d8;
  border-radius: 8px;
  background: var(--green-weak);
  color: #0d513b;
  font-size: 0.95rem;
  font-weight: 750;
  line-height: 1.4;
}

.privacy-setup {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(360px, 1.2fr);
  gap: 28px;
  align-items: start;
  margin-bottom: 20px;
}

.setup-copy h2 {
  margin: 12px 0 8px;
}

.setup-benefits {
  display: grid;
  gap: 9px;
  margin: 18px 0 0;
  padding: 0;
  list-style: none;
}

.setup-benefits li {
  position: relative;
  padding-left: 24px;
  color: var(--ink);
  font-weight: 750;
  line-height: 1.35;
}

.setup-benefits li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.45em;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--blue);
}

.preference-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field-hint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.privacy-note {
  grid-column: 1 / -1;
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid #c7e3df;
  border-radius: 8px;
  background: #eef8f7;
  color: #0f4f48;
  line-height: 1.45;
}

.privacy-note strong {
  color: #073f39;
}

.privacy-note span {
  font-size: 0.92rem;
}

.preference-form .session-actions {
  grid-column: 1 / -1;
  margin-top: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
  max-width: 780px;
}

.settings-note {
  background: #fbf8ef;
  border-color: #eadfca;
}

.home-pillars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}

@media (max-width: 600px) {
  .home-pillars {
    grid-template-columns: 1fr;
  }

  .privacy-setup,
  .preference-form,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.pillar-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: clamp(20px, 3vw, 32px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(23, 32, 51, 0.03);
}

.pillar-sr {
  border-left: 4px solid var(--blue);
}

.pillar-listen {
  border-left: 4px solid #b45309;
}

.pillar-speak {
  border-left: 4px solid #7c3aed;
}

.pillar-mem {
  border-left: 4px solid #4f46e5;
}

.pillar-icon {
  font-size: 2rem;
  line-height: 1;
}

.pillar-title {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--ink);
}

.pillar-desc {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
  flex: 1;
}

.pillar-btn {
  align-self: flex-start;
  margin-top: 4px;
}

/* ── Tablet: sidebar collapsed by default ───────────────── */
@media (max-width: 1023px) and (min-width: 640px) {
  .sidebar {
    width: 60px;
  }
  .app-shell.sidebar-collapsed .sidebar {
    width: 60px;
  }
  .sidebar-brand-text,
  .sidebar-label {
    opacity: 0;
    width: 0;
    pointer-events: none;
  }
  .collapse-arrow {
    transform: rotate(180deg);
  }
  .app-shell:not(.sidebar-collapsed) .sidebar {
    width: 220px;
  }
  .app-shell:not(.sidebar-collapsed) .sidebar-brand-text,
  .app-shell:not(.sidebar-collapsed) .sidebar-label {
    opacity: 1;
    width: auto;
  }
  .app-shell:not(.sidebar-collapsed) .collapse-arrow {
    transform: rotate(0deg);
  }
}

/* ── Mobile: overlay drawer ─────────────────────────────── */
@media (max-width: 639px) {
  .sidebar {
    position: fixed;
    left: -220px;
    top: 0;
    height: 100vh;
    width: 220px !important;
    transition: left 0.25s ease;
    box-shadow: none;
  }

  .app-shell.sidebar-mobile-open .sidebar {
    left: 0;
    box-shadow: var(--shadow);
  }

  .app-shell.sidebar-mobile-open .sidebar-backdrop {
    display: block;
  }

  .sidebar-brand-text,
  .sidebar-label {
    opacity: 1 !important;
    width: auto !important;
  }

  .sidebar-collapse-btn {
    display: none;
  }

  .mobile-topbar {
    display: flex;
  }
}


.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 330px);
  gap: 24px;
  align-items: start;
}

.panel,
.passage-card,
.stat-card,
.setup-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(23, 32, 51, 0.03);
}

.panel {
  padding: clamp(16px, 2vw, 24px);
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-title h2,
.panel h2,
.setup-card h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2.4vw, 1.9rem);
  letter-spacing: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.9rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: white;
  color: var(--ink);
}

.field textarea {
  min-height: 150px;
  padding: 12px;
  line-height: 1.5;
  resize: vertical;
}

.field input[type="range"] {
  padding: 0;
}

.toggle-field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  align-self: end;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-weight: 750;
}

.toggle-field input {
  width: 18px;
  height: 18px;
}

.reader-stage {
  min-height: 260px;
  padding: clamp(22px, 3vw, 42px);
  border-radius: 8px;
  background: #fbf8ef;
  border: 1px solid #eadfca;
  font-size: clamp(1.35rem, 2.2vw, 2.25rem);
  line-height: 1.75;
}

.reader-stage.small-font {
  font-size: clamp(1.05rem, 1.6vw, 1.55rem);
}

.reader-stage.large-font {
  font-size: clamp(1.65rem, 2.8vw, 3rem);
}

.reader-stage.cool-theme {
  background: #eef8f7;
  border-color: #c7e3df;
}

.reader-stage.sepia-theme {
  background: #f7ecd8;
  border-color: #e3ccb0;
}

.reader-stage.dark-theme {
  background: #172033;
  border-color: #2e3a52;
  color: #f7fbfd;
}

.focus-stage {
  display: grid;
  place-items: center;
  text-align: center;
  background: #eef8f7;
  border-color: #c7e3df;
}

.focus-label {
  align-self: end;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
}

.focus-chunk {
  align-self: start;
  max-width: 760px;
  padding: 16px 18px;
  border-radius: 8px;
  background: white;
  color: #102044;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.14);
  font-size: clamp(2rem, 5vw, 4.4rem);
  font-weight: 900;
  line-height: 1.12;
}

.focus-stage.small-font .focus-chunk {
  font-size: clamp(1.5rem, 4vw, 3rem);
}

.focus-stage.large-font .focus-chunk {
  font-size: clamp(2.4rem, 6vw, 5.4rem);
}

.focus-stage.dark-theme .focus-chunk {
  background: #222d44;
  color: #f7fbfd;
}

.focus-stage.sepia-theme .focus-chunk {
  background: #fff8eb;
}

.orp {
  color: var(--rose);
}

.word {
  display: inline;
  padding: 3px 4px;
  border-radius: 6px;
  transition: background 180ms ease, color 180ms ease;
}

.word.active {
  background: #ffe08a;
  color: #1b2538;
  box-shadow: 0 0 0 2px rgba(185, 106, 0, 0.14);
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.passage-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.custom-import {
  display: grid;
  gap: 14px;
  margin: 4px 0 20px;
  padding: 16px;
  border: 1px solid #cbd8e6;
  border-radius: 8px;
  background: var(--surface-soft);
}

.custom-import h3 {
  margin: 0 0 5px;
}

.custom-grid {
  display: grid;
  grid-template-columns: 1fr 190px 220px;
  gap: 12px;
}

.url-import-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.baseline-reader {
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbf8ef;
  font-size: clamp(1.1rem, 2.2vw, 1.45rem);
  line-height: 1.75;
}

.baseline-reader h3 {
  margin: 0 0 12px;
}

.baseline-reader p {
  margin: 0;
}

.active-baseline {
  border-color: #9acdc5;
  box-shadow: 0 0 0 4px rgba(20, 115, 90, 0.12);
}

.vocab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.vocab-chip {
  min-height: 34px;
  padding: 0 10px;
  text-transform: capitalize;
}

.vocab-chip:disabled {
  cursor: default;
  opacity: 0.62;
}

.saved-vocab {
  margin-top: 16px;
  box-shadow: none;
}

.passage-card {
  padding: 14px;
}

.passage-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.tag {
  border-radius: 999px;
  padding: 4px 9px;
  background: #ccede9;
  color: #065f46;
  font-size: 0.78rem;
  font-weight: 800;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 15px;
}

.stat-card strong {
  display: block;
  margin-top: 5px;
  font-size: clamp(1.35rem, 3vw, 2.1rem);
}

.chart {
  width: 100%;
  min-height: 260px;
}

.quiz-options {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.quiz-options button {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  text-align: left;
  padding: 10px 12px;
}

.quiz-options button.selected {
  border-color: var(--blue);
  background: var(--blue-weak);
}

.reward {
  margin-top: 14px;
  padding: 14px;
  border-radius: 8px;
  background: var(--green-weak);
  color: #0d513b;
  font-weight: 800;
}

.level-up {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 14px;
  align-items: center;
  margin: 12px 0 16px;
  padding: 14px;
  border: 1px solid #bfe8d8;
  border-radius: 8px;
  background: var(--green-weak);
  color: #0d513b;
}

.level-up span {
  color: #22634d;
}

.level-up button {
  grid-row: 1 / span 2;
  grid-column: 2;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge {
  border-radius: 8px;
  padding: 9px 10px;
  background: #eef6ff;
  border: 1px solid #cfe5ff;
  color: #163c76;
  font-weight: 800;
}

.tutorial-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.techniques-layout {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.technique-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 20px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.technique-tab {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0 13px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.technique-tab:hover {
  background: #ffffff;
  color: var(--ink);
}

.technique-tab.active {
  background: var(--blue);
  color: #ffffff;
  border-color: var(--blue);
}

.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.concept-card {
  display: grid;
  gap: 12px;
  padding: clamp(18px, 2.4vw, 26px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.concept-speed {
  border-left: 5px solid var(--blue);
}

.concept-memory {
  border-left: 5px solid #4f46e5;
}

.concept-listening {
  border-left: 5px solid #b45309;
}

.concept-speaking {
  border-left: 5px solid #7c3aed;
}

.concept-kicker {
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--blue-weak);
  color: #065f46;
  font-size: 0.78rem;
  font-weight: 900;
}

.concept-memory .concept-kicker {
  background: #e8e7ff;
  color: #4338ca;
}

.concept-listening .concept-kicker {
  background: #fff3d6;
  color: #92400e;
}

.concept-speaking .concept-kicker {
  background: #f1e8ff;
  color: #6d28d9;
}

.concept-card h3,
.method-panel h3 {
  margin: 0;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
}

.concept-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.concept-why {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--surface-soft);
  line-height: 1.45;
}

.concept-why span {
  color: var(--muted);
}

.method-panel {
  display: grid;
  gap: 16px;
  padding: clamp(16px, 2vw, 22px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.memory-method-panel {
  background: #f7f7ff;
}

.listening-method-panel {
  background: #fff8eb;
}

.speaking-method-panel {
  background: #f6f2ff;
}

.method-panel-title {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.method-panel-title p {
  margin: 5px 0 0;
}

.method-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.method-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.method-card h4 {
  margin: 0;
  font-size: 1rem;
}

.method-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

.method-card span {
  display: block;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: #0f4f48;
  font-size: 0.84rem;
  font-weight: 800;
  line-height: 1.4;
}

/* ── Techniques accordion ───────────────────────────────── */
.accordion {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.accordion-item {
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.accordion-header {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}

.accordion-header:hover {
  background: var(--surface-soft);
}

.accordion-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}

.accordion-chevron {
  font-size: 1.1rem;
  color: var(--muted);
  display: inline-block;
  transition: transform 0.2s ease;
}

.accordion-item.open .accordion-chevron {
  transform: rotate(90deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.accordion-item.open .accordion-body {
  max-height: 600px;
}

.accordion-body-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 16px 18px;
  border-top: 1px solid var(--line);
}

.technique-emoji {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.technique-desc {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.9rem;
  padding-top: 4px;
}

.technique-steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.5;
}

.technique-steps li::marker {
  color: var(--muted);
  font-weight: 700;
}

.technique-bodhaspace {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--blue-weak);
  border-left: 3px solid var(--blue);
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--ink);
}

.bodhaspace-label {
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #065f46;
}

.technique-ideal {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.87rem;
}

/* Accent left borders for accordion items */
.red-accent-item    { border-left-color: #d65555; }
.blue-accent-item   { border-left-color: var(--blue); }
.green-accent-item  { border-left-color: var(--green); }
.amber-accent-item  { border-left-color: var(--amber); }
.purple-accent-item { border-left-color: #7c5cc4; }
.teal-accent-item   { border-left-color: #0f766e; }
.orange-accent-item { border-left-color: #ea7c1a; }
.slate-accent-item  { border-left-color: #49647f; }

/* Keep old accent classes for any other usage */
.red-accent    { border-left-color: #d65555; }
.blue-accent   { border-left-color: var(--blue); }
.green-accent  { border-left-color: var(--green); }
.amber-accent  { border-left-color: var(--amber); }
.purple-accent { border-left-color: #7c5cc4; }
.teal-accent   { border-left-color: #0f766e; }
.orange-accent { border-left-color: #ea7c1a; }
.slate-accent  { border-left-color: #49647f; }

.mind-map-panel {
  display: grid;
  gap: 16px;
  padding: clamp(16px, 2vw, 22px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.mind-map-panel h3 {
  margin: 0 0 5px;
}

#toggle-workflow {
  padding: 8px 12px;
  margin: -8px -12px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

#toggle-workflow:hover {
  background-color: rgba(23, 32, 51, 0.05);
}

.workflow-chevron {
  transition: transform 0.2s ease, color 0.2s ease;
}

#toggle-workflow:hover .workflow-chevron {
  color: var(--ink) !important;
}

.flowchart-wrap {
  overflow-x: visible;
  padding: clamp(14px, 2vw, 22px);
  border: 1px solid #d5e0eb;
  border-radius: 8px;
  background: #ffffff;
}

.clear-flowchart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.flow-card-v {
  width: 100%;
  max-width: 480px;
}

.flow-connector-v {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 44px;
  padding-bottom: 6px;
  color: #065f46;
  font-size: 0.82rem;
  font-weight: 900;
}

.flow-connector-v::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 6px;
  left: 50%;
  width: 3px;
  background: #49647f;
  transform: translateX(-50%);
}

.flow-connector-v::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-top: 11px solid #49647f;
  border-right: 8px solid transparent;
  border-left: 8px solid transparent;
}

.flow-card,
.flow-result {
  display: grid;
  gap: 8px;
  min-height: 128px;
  padding: 16px;
  border: 2px solid #b8c7d8;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(28, 40, 67, 0.06);
}

.flow-card strong,
.flow-result strong,
.flow-diamond strong {
  color: var(--ink);
  font-size: clamp(1rem, 1.4vw, 1.2rem);
}

.flow-card p,
.flow-result p,
.flow-diamond span {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.flow-step {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-weak);
  color: #065f46;
  font-weight: 900;
}

.source-card {
  background: #ecf8f6;
  border-color: #7bbdb4;
}

.image-card,
.create-card {
  background: #fff8eb;
  border-color: var(--amber);
}

.attach-card,
.flow-result {
  background: #f3fbf8;
  border-color: var(--green);
}

.flow-connector {
  position: relative;
  color: #065f46;
  font-size: 0.82rem;
  font-weight: 900;
  text-align: center;
}

.flow-connector::before {
  content: "";
  position: absolute;
  top: -12px;
  right: 0;
  left: 0;
  height: 3px;
  background: #49647f;
}

.flow-connector::after {
  content: "";
  position: absolute;
  top: -18px;
  right: -1px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 11px solid #49647f;
}

.flow-diamond {
  display: grid;
  width: 150px;
  height: 150px;
  place-items: center;
  justify-self: center;
  padding: 24px;
  border: 2px solid #7c5cc4;
  background: #f4efff;
  text-align: center;
  transform: rotate(45deg);
}

.flow-diamond strong,
.flow-diamond span {
  display: block;
  transform: rotate(-45deg);
}

.branch-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  width: 100%;
  max-width: 560px;
}

.branch-path {
  display: grid;
  gap: 8px;
}

.branch-label {
  width: fit-content;
  padding: 5px 11px;
  border-radius: 999px;
  color: white;
  font-size: 0.85rem;
  font-weight: 900;
}

.yes-path .branch-label {
  background: var(--green);
}

.no-path .branch-label {
  background: var(--amber);
}

.flow-result {
  width: 100%;
  max-width: 560px;
  min-height: 0;
  text-align: center;
}

.example-box {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-left: 5px solid var(--green);
  border-radius: 8px;
  background: white;
  line-height: 1.55;
}

.example-box span {
  color: var(--muted);
}

.tutorial-step {
  min-height: 260px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.tutorial-step h3 {
  margin: 12px 0 8px;
  font-size: 1.15rem;
}

.tutorial-step p {
  color: var(--muted);
  line-height: 1.55;
}

.step-number {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-weak);
  color: #065f46;
  font-weight: 900;
}

.phrase-demo {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.phrase-demo span {
  width: fit-content;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--amber-weak);
  color: #5f3700;
  font-weight: 900;
}

.meter-demo {
  height: 16px;
  margin-top: 28px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6edf8;
}

.meter-demo span {
  display: block;
  width: 68%;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.score-demo {
  display: grid;
  width: 110px;
  height: 110px;
  margin-top: 18px;
  place-items: center;
  border-radius: 50%;
  background: var(--green-weak);
  color: var(--green);
  font-size: 1.7rem;
  font-weight: 900;
}

.setup-overlay {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
  background: linear-gradient(135deg, #e4f3f1 0%, #f8fbfd 52%, #eef4fb 100%);
}

.setup-card {
  width: min(560px, 100%);
  padding: clamp(20px, 4vw, 34px);
  box-shadow: var(--shadow);
}

.setup-card form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.empty {
  padding: 22px;
  border: 1px dashed #b8c2d4;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1320px) {
  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

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

  .controls,
  .stats-grid,
  .tutorial-grid,
  .technique-grid,
  .concept-grid,
  .method-grid,
  .memory-method-grid,
  .custom-grid,
  .url-import-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .method-panel-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .level-up {
    grid-template-columns: 1fr;
  }

  .flow-row,
  .branch-row {
    grid-template-columns: 1fr;
  }

  .flow-connector {
    min-height: 34px;
  }

  .flow-connector::before {
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    height: auto;
    transform: translateX(-50%);
  }

  .flow-connector::after {
    top: auto;
    right: auto;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    border-top: 11px solid #49647f;
    border-right: 8px solid transparent;
    border-left: 8px solid transparent;
    border-bottom: 0;
  }

  .flow-diamond {
    width: 170px;
    height: 170px;
  }

  .level-up button {
    grid-column: auto;
    grid-row: auto;
    width: fit-content;
  }
}

@media (max-width: 560px) {
  .controls,
  .stats-grid,
  .tutorial-grid,
  .technique-grid,
  .concept-grid,
  .method-grid,
  .memory-method-grid,
  .custom-grid,
  .url-import-row {
    grid-template-columns: 1fr;
  }

  .reader-stage {
    min-height: 220px;
  }

}


/* ── Memory ─────────────────────────────────────────────── */
.memory-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.memory-tab {
  flex: 1;
  padding: 9px 0;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.memory-tab.active {
  border-color: var(--blue);
  background: var(--blue-weak);
  color: #065f46;
}

.memory-hub {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 720px) {
  .memory-hub {
    grid-template-columns: 1fr;
  }
}

.memory-game-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.memory-scores {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.memory-scores h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.memory-score-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
}

.memory-difficulty {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.difficulty-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.difficulty-btn.active {
  border-color: var(--blue);
  background: var(--blue-weak);
  color: #065f46;
}

.diff-meta {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

.matrix-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-size), 1fr);
  gap: 6px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.matrix-cell {
  aspect-ratio: 1;
  border-radius: 6px;
  background: var(--surface-soft);
  border: 2px solid var(--line);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.matrix-cell.target {
  background: var(--blue);
  border-color: var(--blue);
}

.matrix-cell.selected {
  background: #ccede9;
  border-color: var(--blue);
}

.matrix-cell.correct {
  background: var(--green);
  border-color: var(--green);
}

.matrix-cell.missed {
  background: var(--amber);
  border-color: var(--amber);
}

.matrix-cell.wrong {
  background: #f87171;
  border-color: #ef4444;
}

.snapshot-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  border-radius: 10px;
  background: #fff;
  border: 2px solid var(--line);
}

.snapshot-word {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 900;
  color: var(--ink);
  letter-spacing: 0.02em;
}

.snapshot-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.snapshot-choice {
  padding: 8px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.snapshot-choice.selected {
  border-color: var(--blue);
  background: var(--blue-weak);
  color: #065f46;
}

.snapshot-choice.correct {
  border-color: var(--green);
  background: #d1fae5;
  color: #065f46;
}

.snapshot-choice.missed {
  border-color: var(--amber);
  background: #fff8eb;
  color: #92400e;
}

.snapshot-choice.wrong {
  border-color: #ef4444;
  background: #fee2e2;
  color: #7f1d1d;
}

.memory-result-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px;
  border-radius: 10px;
  text-align: center;
}

.memory-result-badge strong {
  font-size: 2.2rem;
}

.result-good {
  background: #d1fae5;
  border: 2px solid var(--green);
  color: #065f46;
}

.result-ok {
  background: #fff8eb;
  border: 2px solid var(--amber);
  color: #92400e;
}

.result-low {
  background: #fee2e2;
  border: 2px solid #ef4444;
  color: #7f1d1d;
}

.memory-instruction {
  font-size: 1rem;
  color: var(--muted);
  text-align: center;
  margin: 0;
}

/* ── Word Hunt ──────────────────────────────────────────── */
.wh-passage-block {
  margin: 16px 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: var(--surface-soft);
}

.wh-passage-label {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--blue);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wh-passage-title {
  margin-bottom: 8px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--ink);
}

.wh-passage-text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--ink);
}

.wordhunt-grid {
  display: grid;
  grid-template-columns: repeat(var(--wh-cols), 1fr);
  gap: 6px;
  width: 100%;
}

.wh-cell {
  padding: 8px 4px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wh-cell.found {
  background: #d1fae5;
  border-color: var(--green);
  color: #065f46;
  cursor: default;
}

.wh-cell.missed {
  background: #fff8eb;
  border-color: var(--amber);
  color: #92400e;
}

@keyframes wrong-flash {
  0%   { background: #fee2e2; border-color: #ef4444; }
  100% { background: var(--surface-soft); border-color: var(--line); }
}

.wh-cell.wrong-flash {
  animation: wrong-flash 0.3s ease-out forwards;
}

.wh-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.wh-header .memory-instruction {
  margin: 0;
}

.wh-timer {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--ink);
  flex-shrink: 0;
}

.wh-timer-urgent {
  color: #ef4444;
}

/* ── Manifestation ───────────────────────────────────────── */
.pillar-manifest {
  border-left: 4px solid #db2777;
}

.concept-manifestation {
  border-left: 5px solid #db2777;
}

.concept-manifestation .concept-kicker {
  background: #fdf2f8;
  color: #be185d;
}

.manifestation-layout {
  display: grid;
  gap: 24px;
}

.manifest-intro {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.manifest-copy {
  line-height: 1.6;
}

.manifest-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.manifest-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  transition: transform 0.2s, box-shadow 0.2s;
}

.manifest-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(23, 32, 51, 0.05);
}

.manifest-card .card-icon {
  font-size: 1.8rem;
}

.manifest-card h4 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--ink);
}

.manifest-card p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.55;
}

.manifest-calculator {
  display: grid;
  gap: 16px;
  padding: clamp(16px, 2vw, 24px);
  border: 1px solid #fbcfe8;
  border-radius: 8px;
  background: #fdf2f8;
}

.manifest-calculator h3 {
  margin: 0;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.calc-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.calc-field label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
}

.calc-field input[type="range"] {
  accent-color: #db2777;
  height: 6px;
  border-radius: 3px;
  background: #f472b6;
}

.manifest-score-display {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 16px;
  background: #ffffff;
  border: 1px solid #fbcfe8;
  border-radius: 8px;
  margin-top: 10px;
}

.score-circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #db2777;
  color: #ffffff;
  flex-shrink: 0;
}

.score-circle strong {
  font-size: 1.8rem;
  font-weight: 900;
}

.score-circle span {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.9;
}

.score-feedback h4 {
  margin: 0 0 4px 0;
  font-size: 1.05rem;
  color: #be185d;
}

.score-feedback p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 600px) {
  .manifest-score-display {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }
}

/* ── EBNE View Styling ────────────────────────────────────── */
.pillar-ebne {
  border-left: 4px solid #7c5cc4;
}

.ebne-layout {
  display: grid;
  gap: 24px;
}

.ebne-explain-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.ebne-explain-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ebne-explain-card h4 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}

.ebne-explain-card.ebne-trad {
  border-top: 4px solid var(--rose);
}

.ebne-explain-card.ebne-bono {
  border-top: 4px solid var(--green);
}

.ebne-workspace-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ebne-form {
  display: grid;
  gap: 16px;
}

.ebne-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ebne-form-group label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--ink);
}

.ebne-input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.ebne-input:focus {
  border-color: var(--blue);
}

.ebne-textarea {
  min-height: 80px;
  resize: vertical;
}

.ebne-submit-btn {
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  align-self: flex-start;
}

.ebne-submit-btn:hover {
  background-color: #0d635c;
}

.ebne-submit-btn:active {
  transform: scale(0.98);
}

.ebne-logs-section {
  margin-top: 16px;
}

.ebne-logs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.ebne-clear-btn {
  background: transparent;
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ebne-clear-btn:hover {
  background: var(--surface-soft);
  color: var(--ink);
}

.ebne-logs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.ebne-log-card {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  box-shadow: 0 2px 6px rgba(28, 40, 67, 0.03);
}

.ebne-log-card h4 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--ink);
  padding-right: 24px;
}

.ebne-log-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ebne-log-step {
  font-size: 0.9rem;
  line-height: 1.5;
}

.ebne-log-step strong {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  margin-right: 6px;
}

.ebne-log-step-e strong {
  background: var(--green-weak);
  color: var(--green);
}

.ebne-log-step-bne strong {
  background: var(--amber-weak);
  color: var(--amber);
}

.ebne-log-step-add strong {
  background: var(--teal-weak);
  color: var(--blue);
}

.ebne-delete-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  font-size: 1.1rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.ebne-delete-btn:hover {
  color: var(--rose);
}

