/* View switcher — grouped palette */
.view-switcher-palette {
  display: grid;
  gap: .8rem;
}
.vs-group {
  border: 1px solid var(--color-border);
  background: var(--color-surface-2);
  padding: .7rem .8rem .7rem 1.1rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 34%);
  gap: 1rem;
  align-items: start;
  position: relative;
}
.vs-group::before {
  content: "";
  position: absolute;
  left: .55rem;
  top: .75rem;
  bottom: .75rem;
  width: 2px;
  background: rgba(74,144,217,.18);
}
.vs-group-main {
  min-width: 0;
}
.vs-group-head {
  margin-bottom: .45rem;
}
.vs-group-head h3 {
  display: flex;
  align-items: baseline;
  gap: .38rem;
  margin: 0;
  font-size: .83rem;
  font-weight: 700;
  color: var(--color-text-1);
}
.vs-group-arrow {
  color: var(--color-accent, #4a90d9);
  font-weight: 800;
}
.vs-group-head p {
  margin: .15rem 0 0;
  font-size: .76rem;
  color: var(--color-text-3);
  line-height: 1.45;
}
.vs-group-links {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.vs-btn {
  display:inline-flex; align-items:center; gap:.28rem; padding:.36rem .72rem; border-radius: 999px;
  font-size:.8rem; font-weight:600; white-space:nowrap;
  text-decoration:none; line-height:1.4; color:#888;
  transition:background .1s, color .1s, border-color .1s; flex-shrink:0;
  border: 1px solid transparent;
  background: #eeedf0;
}
.vs-btn-arrow {
  color: var(--color-text-4, #9ca3af);
  font-weight: 800;
}
a.vs-btn:hover { background:#e0dfe4; color:#333; }
.vs-active { background:#fff; color:#1a1a2e; border-color: var(--color-border); box-shadow:0 1px 3px rgba(0,0,0,.08); cursor:default; }
.vs-primary {
  background: #fff7ed;
  color: #7c2d12;
  border-color: #fed7aa;
  font-weight: 800;
}
.vs-primary .vs-btn-arrow {
  color: #ea580c;
}
.vs-active.vs-primary {
  background: #fff;
  color: #1a1a2e;
  border-color: #f59e0b;
  box-shadow: 0 1px 4px rgba(245, 158, 11, .22);
}
.vs-locked { color:#888; cursor:pointer; font-size:.75rem; background:#f5f5f5; }
.vs-locked:hover { background:#efefef; color:#666; }
.vs-group-hint {
  margin: .15rem 0 0;
  padding-left: .9rem;
  border-left: 2px solid var(--color-border, #e5e7eb);
  color: var(--color-text-3, #64748b);
  font-size: .78rem;
  line-height: 1.5;
  min-height: 3em;
  transition: color .12s ease;
}

/* Test meta panel */
.test-meta-block { margin: -.25rem 0 .9rem; }
.test-meta-static { font-size: .8rem; color: #999; margin-bottom: .3rem; }
.towner-name { font-weight: 600; color: #444; }
.tset-label { font-weight: 400; color: #888; }
.tmeta-sep { color: #ccc; }
.tmeta-desc {
  margin-top: .4rem; font-size: .85rem; color: #555; line-height: 1.65;
  background: #f7f7f8; border-radius: 0; padding: .55rem .85rem;
  white-space: pre-wrap; word-break: break-word;
}

/* ── Unified result page header ────────────────────────────────── */
.res-page-header { margin-bottom: 1.25rem; }

.res-ph-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .4rem;
  font-size: .8rem;
  color: var(--color-text-3);
  margin-bottom: .35rem;
}
.res-ph-left  { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.res-ph-sep   { color: var(--color-text-3); margin: 0 .1rem; }
.res-ph-date  { white-space: nowrap; }
.res-ph-question {
  font-size: .88rem;
  color: var(--color-text-2);
  font-style: italic;
  margin-bottom: .55rem;
  padding: .4rem .65rem;
  background: var(--color-surface-2);
  border-radius: 0;
}
.res-ph-h1row {
  display: block;
  min-width: 0;
  overflow: visible;
}
.res-ph-h1row h1 { font-size: 1.3rem; font-weight: 700; margin: 0 0 .35rem; }
.res-ph-switcher {
  display: block;
  width: 100%;
  min-width: 0;
}
.res-ph-switcher summary {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .25rem .35rem;
  cursor: pointer;
  list-style: none;
  font-size: .82rem;
  font-weight: 700;
  color: var(--color-accent, #4a90d9);
  padding: .15rem 0;
  border: 0;
  background: transparent;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color .12s ease;
}
.res-ph-switcher summary::-webkit-details-marker { display: none; }
.res-ph-switcher summary::before {
  content: "↓";
  font-weight: 800;
  text-decoration: none;
}
.res-ph-switcher summary:hover {
  color: var(--color-accent-strong, #2563eb);
}
.res-ph-switcher[open] summary { margin-bottom: .35rem; }
.res-ph-switcher-intro {
  font-size: .78rem;
  color: var(--color-text-3);
  line-height: 1.5;
  margin: 0 0 .7rem;
  max-width: 42rem;
}
.res-ph-switcher-current {
  color: var(--color-text-2);
  font-weight: 600;
  text-decoration: none;
}

@media (max-width: 720px) {
  .vs-group {
    grid-template-columns: 1fr;
    gap: .55rem;
    padding-left: 1rem;
  }
  .vs-group::before {
    left: .45rem;
  }

  .vs-group-hint {
    padding-left: 0;
    border-left: 0;
  }
}

/* ── Chapter sidebar (right sliding panel) ─────────────────────── */
.chap-sidebar {
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%) translateX(calc(100% - 28px));
  transition: transform .3s ease;
  width: 220px;
  max-height: 72vh;
  background: var(--color-surface, #fff);
  border: 1px solid var(--color-border);
  border-right: none;
  border-radius: 0;
  box-shadow: -3px 0 14px rgba(0,0,0,.09);
  z-index: 200;
  display: flex;
  flex-direction: row;
}
.chap-sidebar.open { transform: translateY(-50%) translateX(0); }

.chap-sidebar-ear {
  flex: 0 0 28px;
  width: 28px;
  background: var(--color-surface-2, #f4f4f8);
  border: none;
  border-right: 1px solid var(--color-border);
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.chap-sidebar-ear span {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-size: .7rem;
  font-weight: 600;
  color: var(--color-text-3);
  letter-spacing: .06em;
  transform: rotate(180deg);
  user-select: none;
}
.chap-sidebar-ear:hover { background: var(--color-surface-3, #e8e8f0); }

.chap-sidebar-body {
  flex: 1;
  overflow-y: auto;
  padding: .5rem .3rem;
}
.chap-nav-btn {
  display: block;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: .32rem .5rem;
  font-size: .77rem;
  color: var(--color-text-2);
  cursor: pointer;
  border-radius: 0;
  line-height: 1.35;
  font-family: inherit;
}
.chap-nav-btn:hover { background: var(--color-surface-2); color: var(--color-accent); }

@media (max-width: 640px) { .chap-sidebar { display: none; } }

/* ── Markdown content images — auto size + lightbox trigger ─────────── */
.vykl-note img, .ai-md-body img, .cms-content img,
.portrait-ai-text img, .portrait-ai-poem img, .md-content img {
  max-width: min(350px, 100%);
  max-height: 350px;
  object-fit: contain;
  border-radius: 0;
  cursor: zoom-in;
  display: block;
  margin: .6rem 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}

/* ── Lightbox overlay ──────────────────────────────────────────────── */
#md-lightbox {
  display: none;
  position: fixed; inset: 0; z-index: 9000;
  background: rgba(0,0,0,.82);
  align-items: center; justify-content: center;
  cursor: zoom-out;
}
#md-lightbox.open { display: flex; }
#md-lightbox img {
  max-width: 90vw; max-height: 90vh;
  object-fit: contain;
  border-radius: 0;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  cursor: default;
}

/* ── Chapter card (shared across all views) ─────────────── */
.chapter-card {
  background: #fff;
  border-radius: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.05);
  margin-bottom: 1.25rem;
  padding: 1.1rem 1.5rem 1.4rem;
  overflow: hidden;
}
.chapter-card-title {
  font-size: .82rem;
  font-weight: 700;
  color: var(--color-text-3, #6b7280);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin: 0 0 .9rem;
}
.chapter-card-desc {
  font-size: .85rem;
  color: #6b7280;
  margin: -.5rem 0 .9rem;
  line-height: 1.5;
}
