* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #fff8fc 0%, #f8f4fb 100%);
  color: #3d2445;
}

.file-proto-banner {
  margin: 0;
  padding: 14px 40px;
  font-size: 0.9rem;
  line-height: 1.55;
  color: #4a1f24;
  background: #fff0f1;
  border-bottom: 2px solid #e8a8b0;
}

.file-proto-banner strong {
  color: #3d1218;
}

.file-proto-banner-actions {
  display: block;
  margin-top: 8px;
  font-weight: 600;
  color: #5c3038;
}

.file-proto-banner code {
  font-size: 0.82rem;
  padding: 2px 7px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #e8ccd0;
  word-break: break-all;
}

.file-proto-banner-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.file-proto-copy-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
  background: linear-gradient(90deg, #d96aa7, #b36ae2);
  color: #fff;
}

.file-proto-copy-btn:hover {
  filter: brightness(1.05);
}

.file-proto-copy-hint {
  font-size: 0.82rem;
  font-weight: 600;
  color: #3d6b45;
  max-width: 100%;
}

.file-proto-copy-hint code {
  font-size: 0.78rem;
}

@media (max-width: 640px) {
  .file-proto-banner {
    padding: 12px 16px;
    font-size: 0.85rem;
  }
  .hero h1 {
    font-size: 0.8rem;
  }
  .hero p {
    font-size: 0.5rem;
  }
}

.topbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 14px 40px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid #edddea;
  position: sticky;
  top: 0;
  backdrop-filter: blur(10px);
  z-index: 200;
}

.brand {
  font-size: 1.3rem;
  font-weight: 700;
  color: #6b2e62;
}

.brand-logo {
  height: 38px;
  width: auto;
  display: block;
}

.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #6b2e62;
  text-decoration: none;
  white-space: nowrap;
}
.brand-title:hover { color: #d96aa7; }

.nav {
  display: flex;
  gap: 6px;
  align-items: center;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nav > a {
  text-decoration: none;
  color: #5e4a63;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 8px;
  transition: background 0.13s, color 0.13s;
  font-size: 0.93rem;
}

.nav > a:hover,
.nav > a[aria-current="page"] {
  background: #f6d6ea;
  color: #7b2f61;
}

/* ── Dropdown nav ── */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #5e4a63;
  font-weight: 600;
  font-size: 0.93rem;
  cursor: pointer;
  user-select: none;
  padding: 7px 13px;
  border-radius: 8px;
  transition: background 0.13s, color 0.13s;
  white-space: nowrap;
}

.nav-dropdown-btn:hover,
.nav-dropdown.active .nav-dropdown-btn {
  background: #f6d6ea;
  color: #7b2f61;
}

.nav-chevron {
  width: 10px;
  height: 6px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.nav-dropdown.is-open .nav-chevron {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: #fff;
  border: 1px solid #edddea;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(95, 64, 92, 0.14);
  padding: 6px;
  min-width: 185px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 300;
}

.nav-dropdown.is-open .nav-dropdown-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.nav-dropdown-menu a {
  display: block;
  padding: 9px 14px;
  border-radius: 9px;
  color: #5e4a63;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav-dropdown-menu a:hover,
.nav-dropdown-menu a[aria-current="page"] {
  background: #f6d6ea;
  color: #7b2f61;
}

/* ── Dashboard ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 28px;
}

.stat-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(95, 64, 92, 0.1);
  padding: 24px;
  border: 1px solid #f0e3ef;
}

.stat-card-icon {
  font-size: 1.6rem;
  margin-bottom: 12px;
  display: block;
}

.stat-card-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #9b7eaa;
  margin-bottom: 6px;
}

.stat-card-value {
  font-size: 2.8rem;
  font-weight: 900;
  color: #58284f;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-card-sub {
  font-size: 0.83rem;
  color: #8a7194;
  margin-top: 4px;
}

.progress-bar-track {
  background: #f0e3ef;
  border-radius: 999px;
  height: 8px;
  margin-top: 12px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #d96aa7, #b36ae2);
  transition: width 0.7s ease;
}

.unit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.unit-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fcf9fd;
  border: 1px solid #ead9e7;
}

.unit-list-item .unit-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #4d3057;
}

.unit-badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
}

.unit-badge.needs-work {
  background: #fdeaea;
  color: #b83c3c;
}

.unit-badge.excels {
  background: #eafaf0;
  color: #2d7a50;
}

.dash-section {
  margin-top: 36px;
}

.dash-section-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: #58284f;
  margin: 0 0 14px;
}

.dash-empty {
  color: #9b7eaa;
  font-size: 0.93rem;
  text-align: center;
  padding: 24px;
  background: #fcf9fd;
  border-radius: 12px;
  border: 1px dashed #ead9e7;
}

/* ── Leaderboard ── */
.lb-tabs {
  display: flex;
  gap: 4px;
  background: #f0edf5;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 28px;
  width: fit-content;
}

.lb-tab {
  padding: 8px 22px;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #6a4c68;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.lb-tab.active {
  background: #fff;
  color: #58284f;
  box-shadow: 0 2px 8px rgba(95, 64, 92, 0.12);
}

.lb-panel { display: none; }
.lb-panel.active { display: block; }

.lb-table-wrap {
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid #ead9e7;
}

.lb-table {
  width: 100%;
  border-collapse: collapse;
}

.lb-table th {
  text-align: left;
  padding: 12px 18px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #9b7eaa;
  border-bottom: 2px solid #ead9e7;
  background: #fcf9fd;
}

.lb-table td {
  padding: 13px 18px;
  font-size: 0.92rem;
  color: #3d2445;
  border-bottom: 1px solid #f4eaf8;
}

.lb-table tr:last-child td {
  border-bottom: none;
}

.lb-table tbody tr:hover td {
  background: #fef6fc;
}

.lb-rank {
  font-weight: 900;
  color: #9b7eaa;
  min-width: 40px;
}

.lb-medal {
  font-size: 1.15rem;
}

.lb-name {
  font-weight: 700;
}

.lb-count {
  font-weight: 800;
  color: #7b2f61;
}

.lb-score {
  font-size: 0.83rem;
  color: #8a7194;
  font-weight: 500;
}

.lb-empty {
  text-align: center;
  color: #9b7eaa;
  font-size: 0.95rem;
  padding: 48px 0;
}

/* ── Home category bands ── */
.home-cat-band {
  margin-top: 48px;
}

.home-cat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.home-cat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.home-cat-icon.chess  { background: #f0e6fb; }
.home-cat-icon.school { background: #e6f4fb; }
.home-cat-icon.career { background: #fbf0e6; }

.home-cat-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  color: #58284f;
}

.home-cat-desc {
  margin: 0;
  font-size: 0.88rem;
  color: #9b7eaa;
}

.home-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 20px;
}

.home-quick-card {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 20px;
  background: #fcf9fd;
  border: 1px solid #ead9e7;
  border-radius: 18px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.home-quick-card:hover {
  transform: translateY(-3px);
  border-color: #d96aa7;
  box-shadow: 0 10px 26px rgba(95, 64, 92, 0.12);
}

.home-quick-icon {
  font-size: 1.5rem;
}

.home-quick-title {
  font-weight: 800;
  font-size: 0.97rem;
  color: #522548;
}

.home-quick-desc {
  font-size: 0.83rem;
  line-height: 1.45;
  color: #7a6b82;
}

.page {
  max-width: 1300px;
  margin: 0 auto;
  padding: 30px 24px 50px;
}

.hero {
  margin-bottom: 26px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 1.4rem;
  color: #58284f;
}

.hero p {
  margin: 0;
  font-size: 0.6rem;
  color: #6f6273;
}

/* —— Home landing (index.html) —— */
.home-page .home-hero h1 {
  font-size: clamp(1.85rem, 4vw, 2.6rem);
  line-height: 1.15;
}

.home-lead {
  margin: 0 0 22px !important;
  font-size: 1.05rem !important;
  line-height: 1.65 !important;
  max-width: 52rem;
  color: #5c4d66 !important;
}

.home-cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
}

a.home-cta,
a.home-cta-secondary {
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

a.home-cta:hover,
a.home-cta-secondary:hover {
  transform: translateY(-2px);
}

.home-section {
  margin-top: 42px;
}

.home-section-title {
  margin: 0 0 10px;
  font-size: 1.45rem;
  color: #58284f;
}

.home-section-lead {
  margin: 0 0 20px;
  max-width: 48rem;
  font-size: 0.98rem;
  line-height: 1.55;
  color: #6f6273;
}

.home-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  align-items: stretch;
}

.home-feature-card {
  display: flex;
  flex-direction: column;
  margin: 0;
}

.home-feature-card .card-header h3 {
  margin: 0;
  font-size: 1.15rem;
  color: #5a2a50;
}

.home-feature-card p {
  margin: 0 0 14px;
  flex: 1;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #654f69;
}

.home-card-link {
  font-weight: 800;
  font-size: 0.92rem;
  color: #7b2f61;
  text-decoration: none;
}

.home-card-link:hover {
  text-decoration: underline;
}

.home-external-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.home-external-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 18px;
  background: #fcf9fd;
  border: 1px solid #ead9e7;
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.home-external-card:hover {
  transform: translateY(-3px);
  border-color: #d96aa7;
  box-shadow: 0 10px 26px rgba(95, 64, 92, 0.12);
}

.home-external-name {
  font-weight: 800;
  font-size: 1rem;
  color: #522548;
}

.home-external-desc {
  font-size: 0.86rem;
  line-height: 1.45;
  color: #7a6b82;
}

.home-footnote {
  margin-top: 36px;
  padding: 18px 20px;
  background: #f8f4fc;
  border-color: #e5d8ef;
}

.home-footnote-text {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: #5a4a62;
}

.home-footnote-text code {
  font-size: 0.8rem;
  padding: 2px 6px;
  background: #fff;
  border-radius: 6px;
  border: 1px solid #ead9e7;
}

.analysis-layout {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 24px;
  align-items: start;
}

.card {
  background: #ffffff;
  border-radius: 24px;
  box-shadow: 0 14px 32px rgba(95, 64, 92, 0.12);
  padding: 20px;
  border: 1px solid #f0e3ef;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.card-header h2 {
  margin: 0;
  font-size: 1.2rem;
  color: #522548;
}

.pill {
  background: #f6d6ea;
  color: #7b2f61;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
}

.pill.soft {
  background: #eee7f7;
  color: #5a4385;
}

.board {
  width: 100%;
  max-width: 720px;
  margin: 0 auto 18px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 700;
  background: #f0edf5;
  color: #4d3753;
  transition: transform 0.15s ease, background 0.2s ease;
}

button:hover {
  transform: translateY(-2px);
  background: #e8dff0;
}

.primary-btn {
  background: linear-gradient(90deg, #d96aa7, #b36ae2);
  color: white;
}

.primary-btn:hover {
  background: linear-gradient(90deg, #cf5f9e, #a65fd5);
}

.ghost-btn {
  background: transparent;
  border: 2px solid #e0d4e8;
  color: #6a4c68;
}

.ghost-btn:hover {
  background: #fcf9fd;
  border-color: #d96aa7;
}

/* Links styled as buttons (home CTAs) — same pill shape as <button> */
a.primary-btn,
a.ghost-btn {
  box-sizing: border-box;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.meta-box {
  display: grid;
  gap: 8px;
}

.meta-box label {
  font-size: 0.9rem;
  font-weight: 700;
  color: #6a4c68;
}

.meta-box input,
.meta-box textarea {
  width: 100%;
  border: 1px solid #ead9e7;
  border-radius: 14px;
  padding: 12px;
  font-size: 0.95rem;
  background: #fcf9fd;
  color: #47314f;
  resize: vertical;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.info-block {
  background: #fcf9fd;
  border: 1px solid #f1e4ef;
  border-radius: 18px;
  padding: 16px;
}

.info-block h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  color: #5a2a50;
}

.info-block p {
  margin: 0;
  line-height: 1.55;
  color: #654f69;
}

#whyText {
  white-space: pre-line;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-block;
  background: #f7e8c8;
  color: #7a5a17;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
}

/* —— Stockfish mini panel (Analyze + Learn) —— */
.sf-mini {
  margin-top: 6px;
  padding: 14px 16px;
  background: linear-gradient(165deg, #f8f2fc 0%, #eef6fb 100%);
  border: 1px solid #e2d4ec;
  border-radius: 16px;
}

.sf-mini-learn {
  margin-top: 18px;
}

.sf-file-warning {
  margin: 0 0 12px;
  padding: 12px 14px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #5c2d32;
  background: #fdecef;
  border: 1px solid #f0b4bc;
  border-radius: 12px;
}

.sf-file-warning code {
  font-size: 0.78rem;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 6px;
  word-break: break-all;
}

.sf-mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.sf-mini-title {
  font-weight: 800;
  font-size: 0.95rem;
  color: #4a2750;
}

.sf-mini-note {
  margin: 0 0 12px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #6f5f78;
}

.sf-mini-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.sf-depth-label {
  font-size: 0.88rem;
  font-weight: 700;
  color: #522548;
  display: flex;
  align-items: center;
  gap: 8px;
}

.sf-depth-label select {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #e0d4e8;
  background: #fff;
  font-weight: 700;
  color: #42253d;
}

.sf-analyze-btn {
  padding: 10px 16px !important;
  font-size: 0.88rem !important;
}

.sf-mini-dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  font-size: 0.86rem;
}

.sf-mini-dl dt {
  margin: 0;
  font-weight: 700;
  color: #6a4c68;
}

.sf-mini-dl dd {
  margin: 0;
  font-weight: 600;
  color: #2d2433;
  word-break: break-word;
}

.sf-status {
  margin: 10px 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #8a7194;
  min-height: 1.2em;
}

@media (max-width: 1000px) {
  .analysis-layout {
    grid-template-columns: 1fr;
  }

  .board {
    max-width: 100%;
  }
}

@media (max-width: 700px) {
  .topbar {
    flex-direction: column;
    gap: 12px;
    padding: 16px 20px;
  }

  .nav {
    position: static;
    transform: none;
    flex-wrap: wrap;
    justify-content: center;
  }

  .cm-user-area {
    margin-left: 0;
  }

  .hero h1 {
    font-size: 0.95rem;
  }
  .hero p {
    font-size: 0.53rem;
  }
}

/* —— Learn page (subpagel.html) —— */
.brand-link {
  text-decoration: none;
  color: inherit;
}

.nav a[aria-current="page"] {
  color: #b14f8b;
  font-weight: 800;
}

.learn-page .learn-lead {
  margin: 0 0 18px;
  color: #6f6273;
  line-height: 1.5;
  font-size: 0.98rem;
}

.level-tracker {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.level-pill {
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 700;
  border: 1px solid #ead9e7;
  background: #fcf9fd;
  color: #6a4c68;
}

.level-pill-active {
  background: #f6d6ea;
  color: #7b2f61;
  border-color: #e8c4dc;
}

.level-pill-locked {
  opacity: 0.55;
  font-weight: 600;
}

.learn-section {
  margin-bottom: 24px;
}

.learn-section-hidden {
  display: none;
}

.learn-subhead {
  margin-top: 28px;
  padding-top: 8px;
  border-top: 1px solid #f1e4ef;
}

.video-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.video-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  background: #fcf9fd;
  border: 1px solid #f1e4ef;
  border-radius: 18px;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.video-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 28px rgba(95, 64, 92, 0.14);
}

.video-card:focus-visible {
  outline: 2px solid #d96aa7;
  outline-offset: 3px;
}

.video-card-thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #2d1f33;
}

.video-card-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #5a2a50 0%, #7b3d8a 45%, #b36ae2 100%);
}

.video-card-placeholder-icon {
  font-size: 3rem;
  opacity: 0.9;
}

.video-card-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-card-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.video-card-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.video-card-title {
  font-weight: 700;
  font-size: 0.98rem;
  color: #522548;
  line-height: 1.35;
}

.video-card-channel {
  font-size: 0.85rem;
  color: #8a7194;
  font-weight: 600;
}

.lichess-frame-wrap {
  position: relative;
  width: 100%;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid #ead9e7;
  background: #261c2e;
  min-height: 520px;
}

.lichess-frame-wrap iframe {
  display: block;
  width: 100%;
  min-height: 560px;
  height: 70vh;
  max-height: 720px;
  border: 0;
}

.unlock-panel {
  margin-top: 22px;
  padding: 18px;
  background: #fcf9fd;
  border: 1px solid #f1e4ef;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}

.unlock-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 0.95rem;
  color: #47314f;
  line-height: 1.45;
  font-weight: 600;
}

.unlock-check input {
  margin-top: 3px;
  width: 18px;
  height: 18px;
  accent-color: #b36ae2;
  flex-shrink: 0;
}

.unlock-panel-done {
  background: #f0faf4;
  border-color: #c5e6d4;
}

.learn-done-msg {
  margin: 0;
  color: #3d5c4a;
  line-height: 1.55;
  font-size: 0.95rem;
}

.learn-done-msg a {
  color: #7b2f61;
  font-weight: 700;
}

.level-pill-done {
  background: #e8f5ec;
  color: #2d6a45;
  border-color: #b8dfc8;
  font-weight: 700;
}

.puzzle-trainer-card .learn-lead {
  margin-bottom: 14px;
}

.learn-board-wrap {
  max-width: 520px;
  margin: 0 auto 14px;
}

.learn-board {
  width: 100%;
}

.learn-board-disabled {
  opacity: 0.85;
  pointer-events: none;
}

.puzzle-feedback {
  min-height: 1.4em;
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #3d7a4a;
  text-align: center;
}

.puzzle-feedback-error {
  color: #9b2d4a;
}

.learn-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}

@media (max-width: 960px) {
  .learn-split {
    grid-template-columns: 1fr;
  }
}

.learn-gallery-card {
  margin-bottom: 0;
}

.learn-gallery-scroll {
  max-height: min(72vh, 640px);
  overflow-y: auto;
  padding-right: 6px;
  align-content: start;
}

.puzzle-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 16px 0 8px;
}

.learn-choice-wrap {
  margin: 12px 0 16px;
}

.learn-choice-wrap[hidden] {
  display: none !important;
}

.learn-choice-lead {
  margin: 0 0 10px;
  font-size: 0.92rem;
  font-weight: 700;
  color: #522548;
}

.learn-choice-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.learn-choice-btn {
  width: 100%;
  text-align: left;
  border-radius: 14px !important;
  padding: 14px 16px !important;
  background: #fcf9fd;
  border: 2px solid #ead9e7 !important;
  color: #42253d;
  font-weight: 700;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.learn-choice-btn:hover {
  border-color: #d96aa7 !important;
  background: #fff;
}

.learn-choice-btn.is-selected {
  border-color: #b36ae2 !important;
  background: #f6e8fb;
  box-shadow: 0 0 0 1px rgba(179, 106, 226, 0.35);
}

/* —— Saved games / archive (subpagea.html) —— */
.archive-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .archive-layout {
    grid-template-columns: 1fr;
  }
}

.file-drop-wrap {
  position: relative;
  margin-bottom: 18px;
}

.file-input-screen-reader {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-drop {
  display: block;
  padding: 28px 20px;
  border: 2px dashed #d4c2d8;
  border-radius: 18px;
  background: #fcf9fd;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.file-drop:hover,
.file-drop-hover {
  border-color: #b36ae2;
  background: #f5effa;
}

.file-drop-label {
  font-weight: 700;
  color: #5a2a50;
}

.archive-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 700;
  color: #6a4c68;
  margin-bottom: 8px;
}

.archive-textarea {
  width: 100%;
  border: 1px solid #ead9e7;
  border-radius: 14px;
  padding: 12px;
  font-size: 0.9rem;
  font-family: ui-monospace, monospace;
  background: #fcf9fd;
  color: #47314f;
  margin-bottom: 12px;
  resize: vertical;
}

.archive-divider {
  height: 1px;
  background: #f1e4ef;
  margin: 22px 0;
}

.color-pick {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
  font-weight: 600;
  color: #47314f;
}

.color-pick label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.archive-scan-btn {
  width: 100%;
  margin-top: 4px;
}

.archive-note {
  margin: 12px 0 0;
  font-size: 0.88rem;
  color: #7a6585;
  min-height: 1.2em;
}

.archive-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  max-height: 320px;
  overflow-y: auto;
}

.archive-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid #f1e4ef;
  border-radius: 14px;
  margin-bottom: 8px;
  background: #fcf9fd;
}

.archive-item-title {
  font-weight: 700;
  color: #522548;
  font-size: 0.92rem;
}

.archive-item-meta {
  font-size: 0.8rem;
  color: #8a7194;
}

.archive-item-remove {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  padding: 0;
  line-height: 1;
  font-size: 1.2rem;
  background: #f5e8ec;
  color: #8b3a52;
}

.archive-item-remove:hover {
  background: #edd5dc;
}

.archive-item-empty {
  display: block;
  text-align: center;
  color: #8a7194;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: default;
  padding: 16px;
}

.archive-library-hint {
  margin: 0 0 14px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: #6f6273;
}

.archive-item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: stretch;
}

.archive-item-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.archive-item-main {
  min-width: 0;
}

.archive-item-colors {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding-top: 4px;
  border-top: 1px solid #f1e4ef;
}

.archive-color-heading {
  font-size: 0.82rem;
  font-weight: 700;
  color: #6a4c68;
  margin-right: 4px;
}

.archive-color-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #47314f;
  cursor: pointer;
}

.archive-color-opt input {
  width: 16px;
  height: 16px;
  accent-color: #b36ae2;
  margin: 0;
}

.archive-clear {
  background: transparent;
  color: #8b3a52;
  text-decoration: underline;
  font-size: 0.9rem;
  padding: 8px 0;
}

.archive-clear:hover {
  transform: none;
  background: transparent;
}

.report-blocks {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.report-block {
  background: #fcf9fd;
  border: 1px solid #f1e4ef;
  border-radius: 18px;
  padding: 18px 20px;
}

.report-block h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
  color: #522548;
}

.report-block-body {
  margin: 0;
  line-height: 1.6;
  color: #654f69;
  font-size: 0.95rem;
}

.archive-page .hero a {
  color: #7b2f61;
  font-weight: 700;
}

.claude-insight-wrap {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.claude-insights-box {
  background: #f6eefa;
  border: 1px solid #dac8e0;
  border-radius: 10px;
  padding: 16px 20px;
  font-size: 0.93rem;
  line-height: 1.65;
  color: #3d2445;
  white-space: pre-wrap;
}

/* —— Puzzle scanner (puzzle-scanner.html) —— */
.scanner-page .hero {
  margin-bottom: 28px;
}

.scanner-page .learn-lead {
  margin: 0 0 18px;
  color: #6f6273;
  line-height: 1.5;
  font-size: 0.98rem;
}

.scanner-tf-root {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.scanner-vision-status {
  margin: 12px 0 0;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1.45;
  color: #6a5575;
  min-height: 2.8em;
}

.scanner-side-select {
  width: 100%;
  max-width: 280px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid #e5d4e8;
  font-size: 0.95rem;
  font-weight: 600;
  color: #3d2445;
  background: #fff;
  cursor: pointer;
}

.scanner-side-select:focus {
  outline: 2px solid #d96aa7;
  outline-offset: 2px;
}

.scanner-disclaimer {
  margin: 18px 0 0;
  padding: 14px 18px;
  background: #faf5fc;
  border: 1px solid #ead8f0;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: #5c4860;
}

.scanner-disclaimer-warn {
  background: #fff8f0;
  border-color: #f0d4b8;
  color: #5c4030;
}

.scanner-disclaimer-warn strong {
  color: #3d2818;
}

.scanner-paste-first {
  margin: 0 0 16px;
  padding: 14px 18px;
  background: #f0faf3;
  border: 1px solid #c5e6d1;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.55;
  color: #2d4a38;
}

.scanner-paste-first strong {
  color: #1e3d2c;
}

.scanner-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: start;
}

.scanner-card.scanner-card-wide {
  grid-column: 1 / -1;
}

.scanner-drop-wrap {
  margin-bottom: 14px;
}

.scanner-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.scanner-file-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 22px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  background: linear-gradient(90deg, #d96aa7, #b36ae2);
  color: #fff;
  border: none;
  box-shadow: 0 6px 18px rgba(179, 106, 226, 0.35);
}

.scanner-file-label:hover {
  filter: brightness(1.06);
}

.scanner-image-preview-wrap,
.scanner-video-preview-wrap {
  margin-top: 12px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid #f0e3ef;
  background: #fcf9fd;
}

.scanner-image-preview {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
}

.scanner-video-preview {
  display: block;
  width: 100%;
  max-height: 360px;
  background: #1a1220;
}

.scanner-label {
  display: block;
  margin: 16px 0 8px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #5a3f58;
}

.scanner-label:first-of-type {
  margin-top: 0;
}

.scanner-fen-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e5d4e8;
  font-size: 0.95rem;
  font-family: ui-monospace, monospace;
  color: #3d2445;
  background: #fff;
}

.scanner-fen-input:focus {
  outline: 2px solid #d96aa7;
  outline-offset: 2px;
}

.scanner-fen-textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e5d4e8;
  font-size: 0.9rem;
  line-height: 1.45;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #3d2445;
  background: #fff;
  resize: vertical;
  min-height: 4.5rem;
  word-break: break-all;
}

.scanner-fen-textarea:focus {
  outline: 2px solid #d96aa7;
  outline-offset: 2px;
}

.scanner-mic-row .ghost-btn {
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}

.scanner-alt-steps {
  margin: 0;
  padding-left: 1.35rem;
  line-height: 1.6;
  color: #554060;
  font-size: 0.95rem;
}

.scanner-alt-steps li {
  margin-bottom: 14px;
}

.scanner-alt-steps li:last-child {
  margin-bottom: 0;
}

.scanner-alt-steps a {
  color: #7b2f61;
  font-weight: 700;
}

.scanner-alt-steps a:hover {
  color: #b14f8b;
}

.scanner-alt-foot {
  margin: 16px 0 0;
  font-size: 0.82rem;
  color: #8a7194;
  line-height: 1.45;
}

.scanner-chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.scanner-chat-include {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #554060;
  cursor: pointer;
}

.scanner-chat-include input {
  width: 18px;
  height: 18px;
  accent-color: #b36ae2;
}

.scanner-chat-log {
  min-height: 200px;
  max-height: 420px;
  overflow-y: auto;
  padding: 14px 16px;
  background: #faf7fc;
  border: 1px solid #ebe0ef;
  border-radius: 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scanner-chat-msg {
  max-width: 92%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.scanner-chat-msg.system {
  align-self: center;
  max-width: 100%;
  background: #f0ede8;
  color: #5c5348;
  font-size: 0.86rem;
  text-align: center;
}

.scanner-chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #e8d4f2, #dcc9f5);
  color: #3d2445;
}

.scanner-chat-msg.model {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #ebe0ef;
  color: #3d2445;
}

.scanner-chat-msg.error {
  align-self: stretch;
  background: #fff0f1;
  border: 1px solid #f0c4c8;
  color: #6b2830;
}

.scanner-chat-compose {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.scanner-chat-input {
  flex: 1 1 220px;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #e5d4e8;
  font-size: 0.95rem;
  line-height: 1.45;
  color: #3d2445;
  resize: vertical;
  min-height: 72px;
  font-family: inherit;
}

.scanner-chat-input:focus {
  outline: 2px solid #d96aa7;
  outline-offset: 2px;
}

.scanner-chat-compose .primary-btn {
  flex: 0 0 auto;
  padding: 12px 22px;
}

.scanner-chat-gpt-note {
  margin: 14px 0 0;
  font-size: 0.86rem;
  line-height: 1.5;
  color: #6f6273;
}

.scanner-chat-gpt-note a {
  color: #7b2f61;
  font-weight: 700;
}

.scanner-transcript {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid #e5d4e8;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #3d2445;
  background: #fff;
  resize: vertical;
  min-height: 160px;
}

.scanner-transcript:focus {
  outline: 2px solid #d96aa7;
  outline-offset: 2px;
}

.scanner-mic-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin: 14px 0 8px;
}

.scanner-mic-status {
  font-size: 0.88rem;
  font-weight: 600;
  color: #7b5f86;
}

.scanner-run-hint {
  margin: 12px 0 0;
  min-height: 1.3em;
  font-size: 0.9rem;
  font-weight: 600;
  color: #8b3a52;
}

.scanner-results {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #f1e4ef;
}

.scanner-results-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  color: #522548;
}

.scanner-result-block {
  margin-bottom: 18px;
  padding: 14px 16px;
  background: #fcf9fd;
  border-radius: 14px;
  border: 1px solid #f1e4ef;
}

.scanner-result-block:last-child {
  margin-bottom: 0;
}

.scanner-result-block h4 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8a7194;
}

.scanner-result-block p {
  margin: 0;
  line-height: 1.55;
  color: #554060;
  font-size: 0.95rem;
}

.scanner-reasoning-echo {
  font-style: italic;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .scanner-layout {
    grid-template-columns: 1fr;
  }

  .scanner-card.scanner-card-wide {
    grid-column: auto;
  }
}
/* ── User session: header badge & buttons ─────────────────────────────────── */

.cm-user-area {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.cm-user-menu {
  position: relative;
}

.cm-user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f6d6ea;
  border: 1px solid #e8a8cc;
  border-radius: 999px;
  padding: 5px 12px 5px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #6b2e62;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.cm-user-trigger:hover,
.cm-user-menu.is-open .cm-user-trigger {
  background: #efb8d6;
  border-color: #d96aa7;
}

.cm-user-trigger .nav-chevron {
  color: #6b2e62;
}

.cm-user-menu.is-open .nav-chevron {
  transform: rotate(180deg);
}

.cm-user-icon {
  font-size: 1rem;
  line-height: 1;
}

.cm-user-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cm-user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border: 1px solid #edddea;
  border-radius: 14px;
  box-shadow: 0 12px 32px rgba(95, 64, 92, 0.14);
  padding: 6px;
  min-width: 180px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 300;
}

.cm-user-menu.is-open .cm-user-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.cm-user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 14px;
  border: none;
  background: transparent;
  border-radius: 9px;
  color: #5e4a63;
  font-weight: 600;
  font-size: 0.88rem;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.cm-user-menu-item:hover {
  background: #f6d6ea;
  color: #7b2f61;
}

.cm-login-btn {
  border: 1.5px solid #d96aa7;
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  background: linear-gradient(90deg, #d96aa7, #b36ae2);
  color: #fff;
  border-color: transparent;
}

.cm-login-btn:hover {
  filter: brightness(1.08);
}

/* ── Login modal ──────────────────────────────────────────────────────────── */

.cm-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(61, 36, 69, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 24px;
}

.cm-modal-backdrop[hidden] {
  display: none !important;
}

.cm-modal-box {
  background: #fff;
  border-radius: 24px;
  padding: 40px 36px 36px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(61, 36, 69, 0.22);
  text-align: center;
}

.cm-modal-logo {
  font-size: 2.8rem;
  line-height: 1;
  margin-bottom: 14px;
}

.cm-modal-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #3d2445;
  margin: 0 0 8px;
}

.cm-modal-sub {
  font-size: 0.9rem;
  color: #6f6273;
  margin: 0 0 24px;
  line-height: 1.55;
}

.cm-modal-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.cm-modal-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #522548;
}

.cm-modal-input {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1.5px solid #e5d4e8;
  font-size: 0.95rem;
  color: #3d2445;
  font-family: inherit;
  background: #faf7fc;
  transition: border-color 0.15s;
}

.cm-modal-input:focus {
  outline: none;
  border-color: #d96aa7;
}

.cm-modal-error {
  font-size: 0.85rem;
  color: #b02050;
  margin: 0;
  font-weight: 600;
}

.cm-modal-submit-btn {
  width: 100%;
  margin-top: 4px;
}

.cm-modal-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
  color: #c0a8c8;
  font-size: 0.82rem;
}

.cm-modal-divider::before,
.cm-modal-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #ead9e7;
}

.cm-modal-guest-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.cm-modal-guest-note {
  font-size: 0.78rem;
  color: #8a7194;
  font-weight: 400;
}

@media (max-width: 640px) {
  .cm-modal-box {
    padding: 30px 20px 24px;
  }

  .cm-user-name {
    display: none;
  }
}

/* ── Profile form (step 2) ───────────────────────────────────────────────── */

.cm-profile-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: left;
  margin-top: 4px;
}

.cm-profile-section-label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #b36ae2;
  padding: 6px 0 2px;
  border-top: 1px solid #f0e3ef;
  margin-top: 4px;
}

.cm-profile-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.cm-profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cm-modal-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid #e5d4e8;
  font-size: 0.93rem;
  color: #3d2445;
  font-family: inherit;
  background: #faf7fc;
  appearance: none;
  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 fill='%23b36ae2' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
  transition: border-color 0.15s;
}

.cm-modal-select:focus {
  outline: none;
  border-color: #d96aa7;
}

.cm-goals-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.cm-goal-pill {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid #e0cce8;
  background: #faf7fc;
  color: #6a4c68;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
}

.cm-goal-pill:hover {
  border-color: #d96aa7;
  background: #fef0f8;
}

.cm-goal-pill.active {
  background: #d96aa7;
  color: #fff;
  border-color: #d96aa7;
}

.cm-modal-textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1.5px solid #e5d4e8;
  font-size: 0.93rem;
  color: #3d2445;
  font-family: inherit;
  background: #faf7fc;
  resize: vertical;
  line-height: 1.55;
  transition: border-color 0.15s;
}

.cm-modal-textarea:focus {
  outline: none;
  border-color: #d96aa7;
}

.cm-profile-error {
  font-size: 0.85rem;
  color: #b02050;
  font-weight: 600;
  margin: 0;
  text-align: left;
}

.cm-profile-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 6px;
}

/* Make the profile modal box taller / scrollable on small screens */
.cm-modal-box {
  max-height: 90vh;
  overflow-y: auto;
}

@media (max-width: 480px) {
  .cm-profile-row {
    grid-template-columns: 1fr;
  }
}

/* ════════════════════════════════════════════════════════════════════
   Decisions page
   ════════════════════════════════════════════════════════════════════ */

.dec-page {
  max-width: 1100px;
}

/* ── Tab bar ──────────────────────────────────────────────────────── */

.dec-tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
  background: #fff;
  border-radius: 999px;
  padding: 6px;
  border: 1px solid #ead9e7;
  width: fit-content;
}

.dec-tab {
  border-radius: 999px;
  padding: 8px 22px;
  font-size: 0.88rem;
  font-weight: 700;
  background: transparent;
  color: #6a4c68;
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.dec-tab:hover {
  background: #f6eef9;
  transform: none;
}

.dec-tab.active {
  background: linear-gradient(90deg, #d96aa7, #b36ae2);
  color: #fff;
}

/* ── Hero ─────────────────────────────────────────────────────────── */

.dec-hero {
  text-align: center;
  padding: 28px 0 20px;
}

.dec-hero-title {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: #3d2445;
  margin: 0 0 10px;
  font-style: italic;
  letter-spacing: -0.5px;
}

.dec-hero-sub {
  font-size: 1rem;
  color: #6f6273;
  margin: 0;
}

/* ── Input card ───────────────────────────────────────────────────── */

.dec-input-card {
  margin-bottom: 24px;
  padding: 20px 24px 18px;
}

.dec-input-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.dec-dilemma-input {
  flex: 1;
  padding: 14px 18px;
  border-radius: 14px;
  border: 1.5px solid #e5d4e8;
  font-size: 1rem;
  font-family: inherit;
  color: #3d2445;
  background: #faf7fc;
  transition: border-color 0.15s;
}

.dec-dilemma-input:focus {
  outline: none;
  border-color: #d96aa7;
}

.dec-simulate-btn {
  white-space: nowrap;
  padding: 14px 28px;
  font-size: 0.95rem;
}

.dec-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.dec-suggestion-pill {
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid #e0cce8;
  background: #faf7fc;
  color: #6a4c68;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
}

.dec-suggestion-pill:hover {
  border-color: #d96aa7;
  background: #fef0f8;
  transform: none;
}

/* ── Loading ──────────────────────────────────────────────────────── */

.dec-loading {
  text-align: center;
  padding: 48px 24px;
  margin-bottom: 24px;
}

.dec-spinner {
  width: 48px;
  height: 48px;
  border: 5px solid #f0edf5;
  border-top-color: #d96aa7;
  border-radius: 50%;
  animation: dec-spin 0.8s linear infinite;
  margin: 0 auto 18px;
}

@keyframes dec-spin { to { transform: rotate(360deg); } }

.dec-loading-text {
  color: #6f6273;
  font-size: 0.98rem;
  margin: 0;
}

/* ── Result card ──────────────────────────────────────────────────── */

.dec-result-card {
  margin-bottom: 24px;
  padding: 28px;
}

.dec-result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.dec-result-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: #3d2445;
  margin: 0 0 4px;
}

.dec-result-subtitle {
  font-size: 0.93rem;
  color: #7a6b82;
  margin: 0;
}

.dec-relevance-badge {
  background: linear-gradient(90deg, #f6d6ea, #e8d6f8);
  color: #5a2a50;
  font-weight: 800;
  font-size: 0.88rem;
  padding: 8px 18px;
  border-radius: 999px;
  white-space: nowrap;
  border: 1px solid #e0b8d8;
  cursor: default;
  flex-shrink: 0;
}

/* ── Metrics ──────────────────────────────────────────────────────── */

.dec-metrics-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.dec-metric-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f6f1fa;
  border: 1px solid #ead9e7;
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 0.85rem;
}

.dec-metric-icon {
  font-size: 0.95rem;
  line-height: 1;
}

.dec-metric-label {
  font-weight: 600;
  color: #5e4a63;
}

.dec-metric-val {
  font-weight: 800;
  color: #3d2445;
}

/* ── Personal take ────────────────────────────────────────────────── */

.dec-personal-take {
  background: linear-gradient(135deg, #fdf0f8 0%, #f3eafc 100%);
  border-left: 4px solid #d96aa7;
  border-radius: 0 14px 14px 0;
  padding: 14px 18px;
  font-size: 0.95rem;
  color: #3d2445;
  line-height: 1.6;
  margin-bottom: 24px;
  font-style: italic;
}

/* ── Split: timeline | stories ────────────────────────────────────── */

.dec-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

.dec-col-title {
  font-size: 1rem;
  font-weight: 800;
  color: #522548;
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.82rem;
}

/* ── Timeline ─────────────────────────────────────────────────────── */

.dec-timeline-block {
  background: #faf7fc;
  border: 1px solid #ead9e7;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.dec-timeline-block:last-child {
  margin-bottom: 0;
}

.dec-timeline-period {
  font-weight: 800;
  font-size: 0.9rem;
  color: #3d2445;
  margin-bottom: 8px;
}

.dec-timeline-bullets {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dec-timeline-bullets li {
  font-size: 0.88rem;
  color: #5e4a63;
  line-height: 1.45;
}

/* ── Stories ──────────────────────────────────────────────────────── */

.dec-story-card {
  background: #faf7fc;
  border: 1px solid #ead9e7;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.dec-story-card:last-child {
  margin-bottom: 0;
}

.dec-story-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}

.dec-story-num {
  font-weight: 800;
  font-size: 0.88rem;
  color: #3d2445;
}

.dec-vibe-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.dec-vibe-positive {
  background: #e0f2e8;
  color: #2d6a45;
}

.dec-vibe-mixed {
  background: #fef5e0;
  color: #7a5f1a;
}

.dec-vibe-tough {
  background: #fde8f0;
  color: #8c2040;
}

.dec-story-row {
  font-size: 0.85rem;
  color: #5e4a63;
  line-height: 1.45;
  margin-bottom: 5px;
}

.dec-story-row:last-child {
  margin-bottom: 0;
}

.dec-story-lbl {
  font-weight: 700;
  color: #3d2445;
}

/* ── Decision Twin ────────────────────────────────────────────────── */

.dec-twin-section {
  border-top: 1px solid #ead9e7;
  padding-top: 24px;
}

.dec-twin-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.dec-twin-pill {
  font-size: 0.78rem;
}

.dec-twin-grid {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.dec-twin-stat-block {
  text-align: center;
  background: linear-gradient(135deg, #f6d6ea, #e8d6f8);
  border-radius: 18px;
  padding: 20px 24px;
  min-width: 110px;
  flex-shrink: 0;
}

.dec-twin-stat-num {
  font-size: 2rem;
  font-weight: 800;
  color: #522548;
  line-height: 1;
}

.dec-twin-stat-lbl {
  font-size: 0.78rem;
  color: #7b2f61;
  font-weight: 600;
  margin-top: 4px;
  line-height: 1.3;
}

.dec-twin-detail {
  flex: 1;
  min-width: 200px;
}

.dec-twin-bar-wrap {
  margin-bottom: 12px;
}

.dec-twin-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  color: #3d2445;
  margin-bottom: 5px;
}

.dec-twin-bar-outer {
  height: 8px;
  background: #f0edf5;
  border-radius: 999px;
  overflow: hidden;
}

.dec-twin-bar-inner {
  height: 8px;
  background: linear-gradient(90deg, #d96aa7, #b36ae2);
  border-radius: 999px;
  transition: width 0.6s ease;
}

.dec-twin-match,
.dec-twin-outcome,
.dec-twin-minority {
  font-size: 0.88rem;
  color: #5e4a63;
  line-height: 1.5;
  margin: 0 0 8px;
}

.dec-twin-note {
  margin-top: 14px;
  background: #fdf0f8;
  border-left: 3px solid #b36ae2;
  border-radius: 0 12px 12px 0;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #3d2445;
  font-weight: 600;
  font-style: italic;
}

/* ── History tab ──────────────────────────────────────────────────── */

.dec-history-card {
  margin-bottom: 14px;
  padding: 18px 22px;
  transition: box-shadow 0.15s;
}

.dec-history-card:hover {
  box-shadow: 0 18px 40px rgba(95, 64, 92, 0.16);
}

.dec-history-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.dec-history-title {
  font-weight: 800;
  font-size: 1rem;
  color: #3d2445;
  margin-bottom: 2px;
}

.dec-history-dilemma {
  font-size: 0.83rem;
  color: #8a7194;
  margin-bottom: 6px;
}

.dec-history-take {
  font-size: 0.88rem;
  color: #5e4a63;
  line-height: 1.45;
  font-style: italic;
  max-width: 560px;
}

.dec-history-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.dec-history-date {
  font-size: 0.78rem;
  color: #9a8aa4;
  font-weight: 600;
}

.dec-empty-state {
  color: #8a7194;
  font-size: 0.95rem;
  padding: 28px 0;
  text-align: center;
}

/* ── Responsive ───────────────────────────────────────────────────── */

@media (max-width: 720px) {
  .dec-split {
    grid-template-columns: 1fr;
  }

  .dec-input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .dec-simulate-btn {
    width: 100%;
  }

  .dec-hero-title {
    font-size: 1.8rem;
  }
}

/* ── Quiz modal — chrome ─────────────────────────────────────────── */
/* Overlay and panel used by quiz-modal.js on any page               */

.qm-overlay {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(30, 20, 35, 0.65);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px 16px; overflow-y: auto;
}
.qm-panel {
  background: #fff; border-radius: 20px; width: 100%; max-width: 680px;
  margin: auto; box-shadow: 0 8px 48px rgba(90, 40, 80, 0.28);
  display: flex; flex-direction: column;
}
.qm-header {
  padding: 18px 22px 14px; border-bottom: 1.5px solid #f0e8f5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-shrink: 0;
}
.qm-title-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.qm-title { margin: 0; font-size: 1.05rem; font-weight: 800; color: #3d2445; }
.qm-close {
  background: none; border: none; font-size: 1.3rem; color: #9b7eaa;
  cursor: pointer; padding: 2px 8px; border-radius: 8px; line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.qm-close:hover { color: #7b2f61; background: #f6eefa; }
.qm-body { padding: 22px; overflow-y: auto; max-height: calc(92vh - 80px); }

/* ── Quiz content — shared between quiz-modal.js and any host page ─ */

.ai-spinner {
  width: 48px; height: 48px;
  border: 5px solid #f0edf5; border-top-color: #d96aa7;
  border-radius: 50%; animation: ai-spin 0.8s linear infinite;
  margin: 0 auto 18px;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

.ai-loading-view { text-align: center; padding: 32px 0; }
.ai-loading-text { color: #6f6273; font-size: 0.98rem; margin-bottom: 0; }
.ai-loading-card {
  margin: 24px auto 0; max-width: 480px; background: #fcf9fd;
  border: 1px solid #f1e4ef; border-radius: 18px; padding: 22px 24px 18px;
}
.ai-loading-quote-text {
  font-style: italic; color: #3d2445; font-size: 1rem;
  line-height: 1.6; margin: 0 0 6px; transition: opacity 0.3s ease;
}
.ai-loading-quote-attr { font-size: 0.8rem; color: #8a7194; margin: 0 0 14px; }
.ai-loading-personal {
  display: inline-block; font-size: 0.83rem; font-weight: 600; color: #58284f;
  background: #f6d6ea; border-radius: 999px; padding: 5px 14px; line-height: 1.4;
}
.ai-loading-personal:empty { display: none; }

.ai-question-card { margin-bottom: 20px; }
.ai-q-meta { font-size: 0.82rem; font-weight: 700; color: #8a7194; margin-bottom: 10px; }
.ai-q-text { font-size: 1.08rem; font-weight: 700; color: #3d2445; margin-bottom: 18px; line-height: 1.45; }
.ai-choice-list { display: flex; flex-direction: column; gap: 10px; }
.ai-choice-btn {
  width: 100%; text-align: left; border-radius: 14px !important;
  padding: 14px 16px !important; background: #fcf9fd;
  border: 2px solid #ead9e7 !important; color: #42253d;
  font-weight: 600; font-size: 0.95rem;
  transition: border-color 0.15s, background 0.15s;
}
.ai-choice-btn:hover { border-color: #d96aa7 !important; background: #fff; }
.ai-choice-btn.selected {
  border-color: #b36ae2 !important; background: #f6e8fb;
  box-shadow: 0 0 0 1px rgba(179, 106, 226, 0.35);
}
.ai-choice-btn.correct-choice {
  border-color: #4caf50 !important; background: #f0faf2 !important; color: #2d7a3a !important;
}
.ai-choice-btn.wrong-choice {
  border-color: #d96aa7 !important; background: #fdf0f6 !important; color: #8b2240 !important;
}
.ai-choice-btn.locked { pointer-events: none; opacity: 0.88; }

.ai-quiz-nav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-top: 24px; flex-wrap: wrap;
}
.ai-dot-row { display: flex; gap: 8px; align-items: center; }
.ai-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #ead9e7; border: 2px solid #ead9e7; cursor: pointer;
  transition: background 0.2s;
}
.ai-dot.answered { background: #b36ae2; border-color: #b36ae2; }
.ai-dot.current  { border-color: #d96aa7; }
.ai-dot.loading  {
  background: #ead9e7; border-color: #d4b8d0;
  animation: dot-pulse 1.1s ease-in-out infinite; cursor: default;
}
@keyframes dot-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50%       { opacity: 1;   transform: scale(1.15); }
}
.ai-q-inline-loading {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  padding: 48px 0;
}
.ai-q-inline-loading span {
  width: 10px; height: 10px; border-radius: 50%; background: #d96aa7;
  animation: dot-pulse 1.1s ease-in-out infinite;
}
.ai-q-inline-loading span:nth-child(2) { animation-delay: 0.18s; }
.ai-q-inline-loading span:nth-child(3) { animation-delay: 0.36s; }

.question-diagram {
  display: flex; justify-content: center; align-items: center;
  margin: 12px 0 16px; background: #fcf9fd;
  border-radius: 18px; border: 1px solid #f1e4ef; padding: 12px;
}
.question-diagram svg { max-width: 100%; max-height: 200px; width: auto; height: auto; }

.explanation-diagram {
  display: flex; justify-content: center; align-items: center;
  margin-top: 12px; background: #fcf9fd;
  border-radius: 18px; border: 1px solid #f1e4ef; padding: 12px;
}
.explanation-diagram svg { max-width: 100%; max-height: 180px; width: auto; height: auto; }

.ai-inline-feedback {
  margin-top: 18px; border-radius: 14px; padding: 16px 18px;
  background: #fcf9fd; border: 1px solid #f1e4ef;
}
.ai-inline-feedback.correct { border-left: 4px solid #4caf50; }
.ai-inline-feedback.wrong   { border-left: 4px solid #d96aa7; }
.ai-inline-feedback-verdict { font-size: 1rem; font-weight: 800; margin-bottom: 8px; }
.ai-inline-feedback-verdict.correct { color: #2d7a3a; }
.ai-inline-feedback-verdict.wrong   { color: #9b2d4a; }
.ai-inline-feedback-correct-ans { font-size: 0.9rem; font-weight: 600; color: #5a2a50; margin-bottom: 6px; }
.ai-inline-feedback-explanation { font-size: 0.9rem; color: #6f6273; line-height: 1.5; margin-bottom: 6px; }
.ai-inline-feedback-actions {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px;
}

.ai-score-block { text-align: center; padding: 24px 0 20px; }
.ai-score-num   { font-size: 2.8rem; font-weight: 800; color: #522548; line-height: 1; }
.ai-score-label { font-size: 1rem; color: #6f6273; margin-top: 8px; }
.ai-result-item {
  border-radius: 14px; padding: 16px 18px; margin-bottom: 14px;
  background: #fcf9fd; border: 1px solid #f1e4ef;
}
.ai-result-item.correct { border-left: 4px solid #4caf50; }
.ai-result-item.wrong   { border-left: 4px solid #d96aa7; }
.ai-result-q   { font-weight: 700; font-size: 0.95rem; color: #3d2445; margin-bottom: 8px; }
.ai-result-your { font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.ai-result-your.correct { color: #3d7a4a; }
.ai-result-your.wrong   { color: #9b2d4a; }
.ai-result-correct-ans  { font-size: 0.9rem; color: #5a2a50; font-weight: 600; margin-bottom: 6px; }
.ai-result-explanation  { font-size: 0.88rem; color: #6f6273; line-height: 1.5; }
.ai-results-actions     { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 22px; }

.ai-explanation-loading {
  min-height: 1.2em;
  background: linear-gradient(90deg, #f1e4ef 25%, #fdf6fb 50%, #f1e4ef 75%);
  background-size: 200% 100%; animation: ai-shimmer 1.4s infinite; border-radius: 6px;
}
@keyframes ai-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
