/* ScaleMaster Studio — Member Auth Portal, Digital Bookshelf & Interactive Book Reader */

.portal-shell {
  min-height: 100dvh;
  max-width: 1240px;
  margin: 0 auto;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(36px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Auth Gate View */
.auth-stage {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(300px, 1.15fr) minmax(320px, 440px);
  gap: 28px;
  align-items: center;
  padding: 18px 0;
}

.auth-hero {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid rgba(37, 99, 235, 0.2);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.auth-hero h1 {
  margin: 0;
  font-size: clamp(1.85rem, 3.6vw, 2.65rem);
  line-height: 1.18;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text);
}

.auth-hero h1 span {
  color: #b91c1c;
}

.auth-hero-desc {
  margin: 0;
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 560px;
}

.hero-mini-shelf {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-width: 560px;
}

.mini-book {
  border-radius: 12px;
  padding: 12px;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
  position: relative;
  overflow: hidden;
}

.mini-book::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 7px;
  background: rgba(255, 255, 255, 0.25);
}

.mini-book span {
  font-size: 0.72rem;
  opacity: 0.9;
  font-weight: 600;
}

.mini-book strong {
  font-size: 0.88rem;
  line-height: 1.25;
}

.hero-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  font-size: 0.9rem;
  color: var(--text);
}

.hero-points li {
  display: block;
  padding-left: 1.65em;
  text-indent: -1.65em;
  line-height: 1.68;
}

/* Auth Card */
.auth-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-input);
  padding: 4px;
  border-radius: 11px;
  border: 1px solid var(--border);
}

.auth-tab {
  border: 0;
  background: transparent;
  padding: 9px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}

.auth-tab.is-active {
  background: #ffffff;
  color: var(--accent);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-field label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
}

.text-input {
  width: 100%;
  background: #f8fafc;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.94rem;
  color: var(--text);
}

.text-input:focus {
  background: #ffffff;
  border-color: var(--accent);
}

.auth-submit {
  width: 100%;
  justify-content: center;
  padding: 11px 16px;
  font-size: 0.96rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-demo {
  width: 100%;
  justify-content: center;
  background: #f8fafc;
}

.auth-note {
  margin: 0;
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: center;
}

/* Bookshelf Hub View */
.member-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--ink);
  font-family: inherit;
}

.member-pill--editable {
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.14s ease;
}

.member-pill--editable:hover {
  border-color: var(--primary);
  background: var(--bg-card);
  transform: translateY(-1px);
}

.member-pill--editable:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.member-edit-icon {
  font-size: 0.78rem;
  opacity: 0.65;
  transition: opacity 0.16s ease;
}

.member-pill--editable:hover .member-edit-icon {
  opacity: 1;
}

.modal-dialog--compact {
  width: min(440px, 92vw);
}

.profile-dialog-body {
  padding: 18px 20px 20px;
}

.profile-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.tier-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
}

.tier-tag--pro {
  background: #dbeafe;
  color: #1d4ed8;
}

.tier-tag--vip {
  background: #d1fae5;
  color: #065f46;
}

.welcome-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  background: #ffffff;
  border: 1px solid var(--border);
}

.welcome-banner h2 {
  margin: 0;
  font-size: 1.32rem;
  font-weight: 800;
}

.welcome-banner p {
  margin: 4px 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.welcome-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pricing-bundle-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
}

.price-pill {
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 7px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.14s, box-shadow 0.14s;
}

.price-pill:hover {
  transform: translateY(-1px);
  border-color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.price-pill strong {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--ink);
}

.price-pill--bundle {
  background: var(--brass-soft);
  border-color: rgba(180, 83, 9, 0.35);
  color: #92400e;
}

.price-pill--bundle del {
  opacity: 0.7;
  margin-left: 3px;
}

.price-pill--bundle strong {
  color: #b45309;
}

.price-pill--bundle strong small {
  font-size: 0.74rem;
  font-weight: 700;
}

/* Bookshelf Section & Ledge */
.shelf-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.shelf-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.shelf-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 800;
}

.shelf-rack {
  position: relative;
  padding-bottom: 18px;
}

.shelf-rack::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(180deg, #e2d5c3 0%, #cbb79d 55%, #b39b7d 100%);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.shelf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(295px, 1fr));
  gap: 16px;
  position: relative;
  z-index: 1;
}

.book-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.07);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.12);
}

.book-cover {
  padding: 18px 18px 16px 24px;
  color: #ffffff;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 138px;
}

/* Realistic book spine highlight on left */
.book-cover::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 11px;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.2), rgba(255, 255, 255, 0.22), rgba(0, 0, 0, 0.08));
}

.cover--cobalt  { background: linear-gradient(145deg, #0f172a 0%, #1e3a5f 100%); }
.cover--emerald { background: linear-gradient(145deg, #064e3b 0%, #047857 100%); }
.cover--indigo  { background: linear-gradient(145deg, #1e293b 0%, #334155 100%); }
.cover--violet  { background: linear-gradient(145deg, #312e81 0%, #4338ca 100%); }
.cover--crimson { background: linear-gradient(145deg, #7f1d1d 0%, #b91c1c 100%); }

.book-cover-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.book-type {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  opacity: 0.92;
  text-transform: uppercase;
}

.book-status-badge {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(4px);
}

.book-status-badge--unlocked {
  background: #d1fae5;
  color: #065f46;
}

.book-status-badge--locked {
  background: rgba(15, 23, 42, 0.45);
  color: #ffffff;
}

.book-icon {
  font-size: 1.55rem;
  line-height: 1;
}

.book-cover h4 {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  line-height: 1.25;
}

.book-body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.book-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.book-features {
  margin: 0;
  padding-left: 18px;
  font-size: 0.8rem;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.book-footer {
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.book-price {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.book-actions {
  display: flex;
  gap: 6px;
}

/* Interactive Theory Book Reader */
.reader-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.toc-card {
  position: sticky;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100dvh - 100px);
  overflow-y: auto;
}

.toc-part-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin: 8px 0 2px;
  padding-left: 4px;
}

.toc-mobile-toggle {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.toc-mobile-toggle .toc-toggle-chevron {
  font-size: 0.78rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.16s ease;
}

.toc-card.is-open .toc-toggle-chevron {
  transform: rotate(180deg);
}

.toc-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Musical Staff & Chord Diagram Cards */
.staff-box {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.staff-svg {
  width: 100%;
  min-width: 460px;
  max-width: 720px;
  height: auto;
  display: block;
}

.acc-legend-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.acc-legend-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.acc-symbol-big {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1;
  width: 34px;
  text-align: center;
}

.chord-diagram-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 12px;
}

.chord-diagram-card {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s;
}

.chord-diagram-card:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.1);
  transform: translateY(-2px);
}

.chord-diagram-card--root {
  border-color: rgba(225, 29, 72, 0.45);
  background: #fffafb;
}

.chord-diagram-head {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.chord-diagram-title {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text);
}

.chord-diagram-sub {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--accent);
}

.chord-svg {
  width: 146px;
  height: auto;
  display: block;
  cursor: pointer;
}

.chord-svg--compact {
  width: 98px;
}

.voicing-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
}

.chord-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

.toc-btn {
  text-align: left;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: border-color 0.15s, background 0.15s;
}

.toc-btn:hover {
  border-color: var(--accent);
}

.toc-btn.is-active {
  background: #eff6ff;
  border-color: var(--accent);
  color: #1d4ed8;
}

.toc-btn small {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.toc-btn strong {
  font-size: 0.88rem;
}

.toc-btn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.toc-btn.is-locked {
  opacity: 0.84;
}

.toc-free-tag {
  font-size: 0.67rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid rgba(4, 120, 87, 0.25);
  flex-shrink: 0;
}

.toc-lock-tag {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--brass-soft);
  color: #92400e;
  border: 1px solid rgba(180, 83, 9, 0.28);
  flex-shrink: 0;
}

.locked-teaser-card {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.locked-teaser-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 7px;
}

.locked-teaser-head h3 {
  margin: 0;
  font-size: 1.12rem;
  color: var(--ink);
}

.teaser-sample-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}

.teaser-chords-pair {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.teaser-chord-btn {
  width: 136px;
  cursor: pointer;
}

.locked-teaser-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chapter-article {
  --book-text-size: 1rem;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  max-width: 100%;
}

.chapter-article[data-font-size="sm"] { --book-text-size: 0.92rem; }
.chapter-article[data-font-size="md"] { --book-text-size: 1.01rem; }
.chapter-article[data-font-size="lg"] { --book-text-size: 1.13rem; }

.book-reading-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.book-read-meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.book-read-meta .meta-chip {
  white-space: nowrap;
}

.book-font-controls {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Editorial Textbook Essay Typography */
.book-essay,
.book-essay-bottom {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.book-lead-box {
  background: #f8fafc;
  border-left: 4px solid var(--ink);
  border-radius: 0 12px 12px 0;
  padding: 14px 16px;
}

.book-kicker-pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #ffffff;
  background: var(--ink);
  padding: 2px 9px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.book-lead {
  margin: 0;
  font-size: calc(var(--book-text-size) * 1.02);
  line-height: 1.85;
  color: var(--text);
}

.book-prose-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.book-prose-section:last-of-type {
  border-bottom: 0;
  padding-bottom: 4px;
}

.book-prose-section h3 {
  margin: 0;
  font-size: calc(var(--book-text-size) * 1.14);
  font-weight: 800;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.4;
}

.book-prose-section p {
  margin: 0;
  font-size: var(--book-text-size);
  line-height: 1.88;
  color: #1f2937;
  max-width: 78ch;
  word-break: normal;
  overflow-wrap: break-word;
}

.book-lab-divider {
  background: #f1f5f9;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 13px 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.book-lab-tag {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--chord);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.book-lab-divider h4 {
  margin: 0;
  font-size: 1.02rem;
  color: var(--ink);
}

.book-lab-divider p {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-muted);
}

/* Practical Guitar Callout, Glossary, Summary & Book Pager */
.book-callout {
  background: var(--brass-soft);
  border: 1px solid rgba(180, 83, 9, 0.28);
  border-left: 4px solid var(--brass);
  border-radius: 14px;
  padding: 20px 22px;
}

.book-callout h4 {
  margin: 0 0 14px;
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: #92400e;
}

.book-callout-list {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-size: calc(var(--book-text-size) * 1.04);
  line-height: 1.92;
  letter-spacing: 0.008em;
  color: #1f2937;
  max-width: 74ch;
}

.book-callout-list li {
  padding-left: 4px;
}

.book-callout-list li::marker {
  font-weight: 800;
  color: #92400e;
}

.book-glossary {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  padding: 18px 20px;
}

.book-glossary h4 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
}

.book-glossary-list {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.book-glossary-item {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}

.book-glossary-item dt {
  font-size: 0.95rem;
  color: var(--ink);
  margin-bottom: 5px;
  line-height: 1.4;
}

.book-glossary-item dt span {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--chord);
}

.book-glossary-item dd {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.78;
  color: #334155;
}

.book-summary-box {
  background: #ecfdf5;
  border: 1px solid rgba(4, 120, 87, 0.28);
  border-radius: 13px;
  padding: 16px 20px;
}

.book-summary-box strong {
  display: block;
  font-size: 0.98rem;
  color: #065f46;
  margin-bottom: 7px;
}

.book-summary-box p {
  margin: 0;
  font-size: calc(var(--book-text-size) * 1.02);
  line-height: 1.88;
  color: #064e3b;
}

.book-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.book-pager-indicator {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
}

.book-pager-btn {
  max-width: 100%;
  text-align: left;
}

/* Interactive Step-by-Step Key Builder & 15-Key Master Sharp/Flat Table */
.key-builder-card,
.kb-table-card {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  padding: 15px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-width: 100%;
}

.kb-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.kb-mode-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.kb-key-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.kb-chain-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.kb-chain {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: max-content;
}

.kb-note {
  min-width: 58px;
  background: #f8fafc;
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  padding: 7px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.kb-note small {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
}

.kb-note strong {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--ink);
}

.kb-note.is-sharp {
  background: #fef2f2;
  border-color: rgba(220, 38, 38, 0.45);
}

.kb-note.is-sharp strong {
  color: #b91c1c;
}

.kb-note.is-flat {
  background: #f0f9ff;
  border-color: rgba(3, 105, 161, 0.45);
}

.kb-note.is-flat strong {
  color: #0369a1;
}

.kb-step {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  padding: 2px 5px;
  border-radius: 6px;
  background: var(--bg-input);
  line-height: 1.15;
}

.kb-step small {
  font-size: 0.61rem;
  font-weight: 600;
}

.kb-step.is-h {
  background: #fef2f2;
  color: #b91c1c;
}

.kb-tetra-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.kb-tetra-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.kb-tetra-box--upper {
  background: var(--brass-soft);
  border-color: rgba(180, 83, 9, 0.25);
}

.kb-tetra-link {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--ink);
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px 10px;
  text-align: center;
}

.kb-minor-rel-box,
.kb-shortcut-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 15px;
  font-size: 0.94rem;
  line-height: 1.8;
  color: var(--text);
}

.kb-shortcut-box {
  background: #ecfdf5;
  border-color: rgba(4, 120, 87, 0.25);
  color: #064e3b;
}

.kb-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 2px;
}

.kb-sig-chip {
  display: inline-block;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-input);
  color: var(--ink);
  vertical-align: middle;
}

.kb-sig-chip.is-sharp {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid rgba(220, 38, 38, 0.28);
}

.kb-sig-chip.is-flat {
  background: #f0f9ff;
  color: #0369a1;
  border: 1px solid rgba(3, 105, 161, 0.28);
}

.kb-table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.kb-table {
  width: 100%;
  min-width: 540px;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.kb-table th {
  text-align: left;
  padding: 8px 10px;
  background: var(--bg-input);
  border-bottom: 1px solid var(--border-strong);
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--text-muted);
  white-space: nowrap;
}

.kb-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.kb-table-row {
  cursor: pointer;
  transition: background 0.12s;
}

.kb-table-row:hover {
  background: #f8fafc;
}

.kb-table-row.is-selected {
  background: var(--brass-soft);
}

.kb-notes-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .kb-tetra-row {
    grid-template-columns: 1fr;
  }
  .kb-tetra-link {
    justify-self: center;
  }
}

.chapter-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.chapter-kicker {
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--accent);
}

.chapter-header h2 {
  margin: 4px 0 6px;
  font-size: 1.4rem;
}

.chapter-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.interval-table {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.interval-card {
  background: #f8fafc;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  text-align: left;
  transition: transform 0.1s, border-color 0.15s, background 0.15s;
}

.interval-card:hover {
  border-color: var(--accent);
  background: #eff6ff;
  transform: translateY(-2px);
}

.interval-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.interval-badge {
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 0.78rem;
  padding: 2px 8px;
  border-radius: 999px;
}

.formula-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.formula-card {
  background: #f8fafc;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.formula-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.step-badge {
  font-size: 0.76rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 7px;
  background: #dbeafe;
  color: #1d4ed8;
}

.step-badge--h {
  background: #ffe4e6;
  color: #be123c;
}

.cof-layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}

.cof-svg {
  width: 100%;
  max-width: 380px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.cof-slice {
  cursor: pointer;
  transition: opacity 0.15s;
}

.cof-slice:hover {
  opacity: 0.88;
}

.cof-info-card {
  background: #f8fafc;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-card {
  background: #f8fafc;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.quiz-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.quiz-opt {
  background: #ffffff;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 11px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.quiz-opt:hover {
  border-color: var(--accent);
  background: #eff6ff;
}

.quiz-opt.is-correct {
  background: #d1fae5;
  border-color: #059669;
  color: #065f46;
}

.quiz-opt.is-wrong {
  background: #ffe4e6;
  border-color: #e11d48;
  color: #be123c;
}

@media (max-width: 1024px) {
  .portal-shell {
    padding:
      max(12px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(30px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
    gap: 14px;
  }
  .auth-stage {
    gap: 20px;
  }
  .reader-layout {
    grid-template-columns: 235px minmax(0, 1fr);
    gap: 14px;
  }
}

@media (max-width: 880px) {
  .auth-stage,
  .reader-layout,
  .cof-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .toc-card {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 10px 12px;
    min-width: 0;
    max-width: 100%;
  }
  .toc-card > .label-title {
    display: none;
  }
  .toc-mobile-toggle {
    display: flex;
  }
  .toc-card:not(.is-open) .toc-body {
    display: none;
  }
  .toc-card.is-open .toc-body {
    margin-top: 10px;
    max-height: 55dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .hero-mini-shelf {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .portal-shell {
    padding:
      max(8px, env(safe-area-inset-top))
      max(8px, env(safe-area-inset-right))
      max(24px, env(safe-area-inset-bottom))
      max(8px, env(safe-area-inset-left));
    gap: 10px;
  }
  .auth-stage {
    padding: 2px 0;
    gap: 14px;
  }
  .auth-hero {
    gap: 12px;
  }
  .auth-hero-top {
    flex-wrap: nowrap;
    gap: 8px;
  }
  .hero-eyebrow {
    font-size: 0.72rem;
    padding: 4px 10px;
    gap: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .auth-hero h1 {
    font-size: 1.52rem;
    line-height: 1.24;
  }
  .auth-hero > p {
    font-size: 0.89rem;
    line-height: 1.62;
  }
  .auth-card {
    padding: 16px 14px;
    border-radius: 14px;
  }
  .hero-mini-shelf {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }
  .mini-book {
    padding: 9px 8px 9px 11px;
    border-radius: 10px;
    gap: 3px;
  }
  .mini-book::before {
    width: 4px;
  }
  .mini-book span {
    font-size: 0.63rem;
    line-height: 1.2;
  }
  .mini-book strong {
    font-size: 0.74rem;
    line-height: 1.25;
  }
  .hero-points {
    gap: 6px;
    font-size: 0.84rem;
  }
  .hero-points li {
    line-height: 1.58;
  }
  .member-pill {
    width: 100%;
    justify-content: space-between;
  }
  .book-reading-toolbar {
    padding: 9px 10px;
    gap: 8px;
  }
  .book-read-meta {
    font-size: 0.75rem;
    line-height: 1.5;
  }
  .book-lead-box {
    padding: 12px 13px;
    border-left-width: 3px;
  }
  .book-lead {
    font-size: 0.94rem;
    line-height: 1.8;
    word-break: normal;
    overflow-wrap: break-word;
  }
  .book-prose-section {
    gap: 8px;
  }
  .book-prose-section h3 {
    font-size: 1.04rem;
    line-height: 1.42;
  }
  .book-prose-section p {
    font-size: 0.94rem;
    line-height: 1.82;
  }
  .reader-article {
    padding: 14px 13px 18px;
  }
  .pricing-bundle-strip {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .price-pill--bundle {
    grid-column: 1 / -1;
  }
  .shelf-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .book-cover {
    min-height: 118px;
    padding: 15px 15px 14px 20px;
  }
  .book-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .book-actions {
    width: 100%;
  }
  .book-actions > a,
  .book-actions > button {
    flex: 1;
    justify-content: center;
    text-align: center;
    min-height: 40px;
  }
  .chapter-header h2 {
    font-size: 1.18rem;
  }
  .chord-controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .chord-controls-bar .select-input,
  .chord-controls-bar .select-input--sm {
    width: 100%;
  }
  .chord-diagram-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .chord-diagram-card {
    padding: 10px 6px;
  }
  .chord-svg {
    width: 100%;
    max-width: 136px;
  }
  .interval-table,
  .formula-cards {
    grid-template-columns: 1fr;
  }
  .quiz-card {
    padding: 14px 12px;
  }
  .quiz-options {
    grid-template-columns: 1fr;
  }
  .quiz-opt {
    min-height: 44px;
  }
  .book-pager {
    flex-direction: column;
    align-items: stretch;
  }
  .book-pager-indicator {
    text-align: center;
    order: -1;
  }
  .book-pager-btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
  .book-callout {
    padding: 16px 15px;
  }
  .book-callout-list {
    gap: 12px;
    line-height: 1.86;
  }
  .book-glossary-list {
    grid-template-columns: 1fr;
  }
}


/* ==========================================================================
   Dark Hole Studio v5.0 — Premium Portal, Bookshelf & Reader Polish + Dark Theme
   ========================================================================== */

.auth-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.welcome-banner {
  border-left: 4px solid var(--root);
}

/* Luxury subtle diagonal lighting sheen on book & app covers */
.book-cover {
  overflow: hidden;
}

.book-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.14) 0%, transparent 44%, rgba(0, 0, 0, 0.14) 100%);
  pointer-events: none;
}

.book-cover > * {
  position: relative;
  z-index: 1;
}

.toc-btn.is-active {
  border-left: 3.5px solid var(--accent);
}

/* ---------------- Dark Hole Obsidian Theme for Portal & Theory Book ---------------- */

html[data-theme="dark"] .hero-eyebrow {
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.28);
}

html[data-theme="dark"] .auth-hero h1 span {
  color: #fb7185;
}

html[data-theme="dark"] .auth-card,
html[data-theme="dark"] .book-card,
html[data-theme="dark"] .toc-card,
html[data-theme="dark"] .chapter-article,
html[data-theme="dark"] .book-glossary,
html[data-theme="dark"] .key-builder-card,
html[data-theme="dark"] .kb-table-card,
html[data-theme="dark"] .cof-info-card,
html[data-theme="dark"] .formula-card,
html[data-theme="dark"] .interval-card,
html[data-theme="dark"] .chord-diagram-card,
html[data-theme="dark"] .quiz-card,
html[data-theme="dark"] .locked-teaser-card {
  background: #121722;
  border-color: rgba(148, 163, 184, 0.18);
  color: #f1f5f9;
}

html[data-theme="dark"] .book-card {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 12px 28px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .book-card:hover {
  border-color: rgba(148, 163, 184, 0.34);
  box-shadow: 0 20px 38px rgba(0, 0, 0, 0.6);
}

html[data-theme="dark"] .shelf-rack {
  border-bottom-color: rgba(251, 191, 36, 0.24);
}

html[data-theme="dark"] .auth-tabs,
html[data-theme="dark"] .member-pill,
html[data-theme="dark"] .book-reading-toolbar,
html[data-theme="dark"] .book-font-controls {
  background: #0e131d;
  border-color: rgba(148, 163, 184, 0.18);
}

html[data-theme="dark"] .auth-tab.is-active {
  background: #1e293b;
  color: #60a5fa;
}

html[data-theme="dark"] .tier-tag {
  background: rgba(148, 163, 184, 0.18);
  color: #cbd5e1;
}

html[data-theme="dark"] .member-pill--editable:hover {
  background: #161e2e;
  border-color: rgba(96, 165, 250, 0.55);
}

html[data-theme="dark"] .tier-tag--vip {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}

html[data-theme="dark"] .tier-tag--pro {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
}

/* Theory Book TOC & Reading Typography in Obsidian Dark */
html[data-theme="dark"] .toc-btn {
  background: #161d2b;
  border-color: rgba(148, 163, 184, 0.14);
  color: #e2e8f0;
}

html[data-theme="dark"] .toc-btn:hover {
  background: #1d2638;
  border-color: rgba(148, 163, 184, 0.28);
}

html[data-theme="dark"] .toc-btn.is-active {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(56, 189, 248, 0.4);
  border-left-color: #38bdf8;
  color: #ffffff;
}

html[data-theme="dark"] .toc-mobile-toggle {
  background: #161d2b;
  border-color: rgba(148, 163, 184, 0.22);
  color: #f1f5f9;
}

html[data-theme="dark"] .book-kicker-pill {
  background: #e11d48;
  color: #ffffff;
}

html[data-theme="dark"] .book-lead,
html[data-theme="dark"] .book-prose-section p {
  color: #dde5f0;
}

html[data-theme="dark"] .book-prose-section h3,
html[data-theme="dark"] .chapter-header h2,
html[data-theme="dark"] .book-lab-divider h4,
html[data-theme="dark"] .book-glossary h4,
html[data-theme="dark"] .book-glossary-item dt {
  color: #f8fafc;
}

html[data-theme="dark"] .book-lab-divider {
  background: #171e2d;
  border-color: rgba(148, 163, 184, 0.2);
}

html[data-theme="dark"] .book-callout {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(251, 191, 36, 0.3);
  border-left-color: #f59e0b;
}

html[data-theme="dark"] .book-callout h4,
html[data-theme="dark"] .book-callout-list li::marker {
  color: #fcd34d;
}

html[data-theme="dark"] .book-callout-list {
  color: #e2e8f0;
}

html[data-theme="dark"] .book-glossary-item {
  background: #171e2d;
  border-color: rgba(148, 163, 184, 0.16);
}

html[data-theme="dark"] .book-glossary-item dd {
  color: #cbd5e1;
}

html[data-theme="dark"] .book-summary-box {
  background: rgba(16, 185, 129, 0.11);
  border-color: rgba(52, 211, 153, 0.3);
}

html[data-theme="dark"] .book-summary-box strong {
  color: #6ee7b7;
}

html[data-theme="dark"] .book-summary-box p {
  color: #d1fae5;
}

/* Chapter 3 Key Proof Builder & 15-Key Table in Dark Mode */
html[data-theme="dark"] .kb-note {
  background: #1a2130;
  border-color: rgba(148, 163, 184, 0.25);
}

html[data-theme="dark"] .kb-note strong {
  color: #f8fafc;
}

html[data-theme="dark"] .kb-note.is-sharp {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.5);
}
html[data-theme="dark"] .kb-note.is-sharp strong {
  color: #fda4af;
}

html[data-theme="dark"] .kb-note.is-flat {
  background: rgba(56, 189, 248, 0.16);
  border-color: rgba(56, 189, 248, 0.5);
}
html[data-theme="dark"] .kb-note.is-flat strong {
  color: #7dd3fc;
}

html[data-theme="dark"] .kb-step {
  background: #1a2130;
  color: #cbd5e1;
}

html[data-theme="dark"] .kb-step.is-h {
  background: rgba(244, 63, 94, 0.18);
  color: #fda4af;
}

html[data-theme="dark"] .kb-tetra-box,
html[data-theme="dark"] .kb-minor-rel-box {
  background: #171e2d;
  border-color: rgba(148, 163, 184, 0.18);
  color: #e2e8f0;
}

html[data-theme="dark"] .kb-tetra-box--upper {
  background: rgba(245, 158, 11, 0.11);
  border-color: rgba(251, 191, 36, 0.3);
}

html[data-theme="dark"] .kb-shortcut-box {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(52, 211, 153, 0.3);
  color: #d1fae5;
}

html[data-theme="dark"] .kb-sig-chip.is-sharp {
  background: rgba(244, 63, 94, 0.18);
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.4);
}

html[data-theme="dark"] .kb-sig-chip.is-flat {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.4);
}

html[data-theme="dark"] .kb-table th {
  background: #171e2d;
  color: #94a3b8;
}

html[data-theme="dark"] .kb-table-row:hover {
  background: #1a2233;
}

html[data-theme="dark"] .kb-table-row.is-selected {
  background: rgba(245, 158, 11, 0.14);
}

html[data-theme="dark"] .staff-box,
html[data-theme="dark"] .chord-controls-bar,
html[data-theme="dark"] .teaser-sample-row {
  background: #171e2d;
  border-color: rgba(148, 163, 184, 0.2);
}

html[data-theme="dark"] .step-badge {
  background: #1a2130;
  color: #cbd5e1;
}

html[data-theme="dark"] .step-badge--h {
  background: rgba(244, 63, 94, 0.18);
  color: #fda4af;
}

html[data-theme="dark"] .quiz-opt {
  background: #171e2d;
  border-color: rgba(148, 163, 184, 0.22);
  color: #f1f5f9;
}

html[data-theme="dark"] .quiz-opt:hover {
  background: #1f2a3f;
  border-color: #60a5fa;
}

html[data-theme="dark"] .quiz-opt.is-correct {
  background: rgba(16, 185, 129, 0.2);
  border-color: #34d399;
  color: #a7f3d0;
}

html[data-theme="dark"] .quiz-opt.is-wrong {
  background: rgba(244, 63, 94, 0.2);
  border-color: #fb7185;
  color: #fecdd3;
}

/* Complete sweep of portal & theory-book dark-mode surfaces */
html[data-theme="dark"] .welcome-banner,
html[data-theme="dark"] .book-lead-box,
html[data-theme="dark"] .acc-legend-item {
  background: #161d2b;
  border-color: rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
}

html[data-theme="dark"] .text-input {
  background: #0e131d;
  border-color: rgba(148, 163, 184, 0.24);
  color: #f8fafc;
}

html[data-theme="dark"] .text-input:focus {
  background: #121826;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

html[data-theme="dark"] .btn-demo {
  background: #1a2234;
  border-color: rgba(148, 163, 184, 0.28);
  color: #f1f5f9;
}

html[data-theme="dark"] .btn-demo:hover {
  background: #243047;
}

html[data-theme="dark"] .chord-diagram-card--root {
  background: rgba(244, 63, 94, 0.12);
  border-color: rgba(244, 63, 94, 0.45);
}

html[data-theme="dark"] .toc-free-tag {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}

html[data-theme="dark"] .interval-card:hover {
  background: #1c2538;
  border-color: #60a5fa;
}


/* ==========================================================================
   Ear & Rhythm Lab Styles (Light Pro Studio + Dark Hole Obsidian)
   ========================================================================== */

.lab-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.lab-head-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.lab-title {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.lab-stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.lab-stat-pill {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 72px;
}

.lab-stat-pill span {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
}

.lab-stat-pill strong {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.lab-stat-pill--streak {
  background: var(--brass-soft);
  border-color: rgba(180, 83, 9, 0.28);
}

.lab-stat-pill--streak strong {
  color: var(--brass);
}

.lab-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 13px;
}

.lab-stage {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lab-prompt-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.lab-feedback {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 15px;
  font-size: 0.93rem;
  line-height: 1.55;
  color: var(--text);
}

.lab-feedback.is-ok {
  background: #ecfdf5;
  border-color: rgba(4, 120, 87, 0.35);
  color: #065f46;
}

.lab-feedback.is-wrong {
  background: #fef2f2;
  border-color: rgba(220, 38, 38, 0.35);
  color: #991b1b;
}

.lab-options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(156px, 1fr));
  gap: 9px;
}

.lab-options-grid--chords {
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
}

.lab-opt-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-strong);
  border-radius: 11px;
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.14s, background 0.14s, transform 0.1s;
}

.lab-opt-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.lab-opt-btn strong {
  font-size: 0.96rem;
  color: var(--ink);
}

.lab-opt-btn span {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.lab-opt-btn.is-correct {
  background: #ecfdf5;
  border-color: #059669;
}

.lab-opt-btn.is-correct strong {
  color: #065f46;
}

.lab-opt-btn.is-wrong {
  background: #fef2f2;
  border-color: #dc2626;
}

.lab-opt-btn.is-wrong strong {
  color: #991b1b;
}

/* Rhythm Precision Trainer */
.rhythm-trainer-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rhythm-beat-lamps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.beat-lamp {
  background: var(--bg-input);
  border: 1.5px solid var(--border-strong);
  border-radius: 12px;
  padding: 12px 8px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform 0.08s, background 0.08s, border-color 0.08s, box-shadow 0.08s;
}

.beat-lamp span {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
}

.beat-lamp small {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.beat-lamp.is-lit {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.03);
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.28);
}

.beat-lamp.is-lit span,
.beat-lamp.is-lit small {
  color: #ffffff;
}

.beat-lamp.is-lit.is-accent {
  background: var(--root);
  border-color: var(--root);
  box-shadow: 0 6px 18px rgba(220, 38, 38, 0.34);
}

.beat-lamp.is-silent {
  border-style: dashed;
  opacity: 0.62;
}

.rhythm-meter-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rhythm-meter-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.rhythm-meter-labels strong {
  font-size: 0.88rem;
  color: var(--ink);
  text-align: center;
}

.rhythm-tap-pad {
  width: 100%;
  min-height: 112px;
  border-radius: 15px;
  border: 2px solid var(--border-strong);
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-input) 100%);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px;
  transition: transform 0.06s, border-color 0.1s, background 0.1s, box-shadow 0.1s;
  user-select: none;
}

.rhythm-tap-pad:active,
.rhythm-tap-pad.is-hit {
  transform: scale(0.985);
}

.rhythm-tap-pad.is-perfect {
  border-color: #059669;
  background: rgba(16, 185, 129, 0.14);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
}

.rhythm-tap-pad.is-close {
  border-color: #d97706;
  background: rgba(245, 158, 11, 0.14);
}

.rhythm-tap-pad.is-off {
  border-color: #dc2626;
  background: rgba(220, 38, 38, 0.12);
}

.rhy-pad-icon {
  font-size: 1.7rem;
  line-height: 1;
}

.rhythm-tap-pad strong {
  font-size: 1rem;
  font-weight: 800;
}

.rhythm-tap-pad small {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Polyrhythm Visualizer */
.poly-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.poly-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.poly-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.poly-tracks {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.poly-track-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.poly-track-label {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
}

.poly-steps-row {
  display: grid;
  gap: 5px;
}

.poly-step-cell {
  height: 30px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  transition: background 0.06s, transform 0.06s, color 0.06s;
}

.poly-step-cell.is-hit-a {
  background: rgba(220, 38, 38, 0.14);
  border-color: rgba(220, 38, 38, 0.35);
  color: var(--root);
}

.poly-step-cell.is-hit-b {
  background: rgba(3, 105, 161, 0.14);
  border-color: rgba(3, 105, 161, 0.35);
  color: var(--chord);
}

.poly-step-cell.is-now {
  transform: scale(1.06);
  background: var(--root) !important;
  border-color: var(--root) !important;
  color: #ffffff !important;
}

.poly-step-cell.is-now-b {
  transform: scale(1.06);
  background: var(--chord) !important;
  border-color: var(--chord) !important;
  color: #ffffff !important;
}

/* Dark Hole Obsidian overrides for Ear & Rhythm Lab */
html[data-theme="dark"] .lab-feedback.is-ok {
  background: rgba(16, 185, 129, 0.16);
  border-color: rgba(52, 211, 153, 0.4);
  color: #a7f3d0;
}

html[data-theme="dark"] .lab-feedback.is-wrong {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(251, 113, 133, 0.4);
  color: #fecdd3;
}

html[data-theme="dark"] .lab-opt-btn {
  background: #171e2d;
  border-color: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] .lab-opt-btn.is-correct {
  background: rgba(16, 185, 129, 0.2);
  border-color: #34d399;
}

html[data-theme="dark"] .lab-opt-btn.is-correct strong {
  color: #6ee7b7;
}

html[data-theme="dark"] .lab-opt-btn.is-wrong {
  background: rgba(244, 63, 94, 0.2);
  border-color: #fb7185;
}

html[data-theme="dark"] .lab-opt-btn.is-wrong strong {
  color: #fda4af;
}

html[data-theme="dark"] .rhythm-tap-pad {
  background: linear-gradient(180deg, #171e2d 0%, #101520 100%);
  border-color: rgba(148, 163, 184, 0.28);
}

@media (max-width: 640px) {
  .lab-options-grid,
  .lab-options-grid--chords {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .poly-track-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
