:root {
  --bg: #0b1020;
  --panel: #111827;
  --card: #f8fafc;
  --card-soft: #eef2ff;
  --text: #0f172a;
  --muted: #64748b;
  --inverse: #f8fafc;
  --line: rgba(15, 23, 42, 0.13);
  --button: #172033;
  --button-text: #f8fafc;
  --inactive: #e5e7eb;
  --danger: #b91c1c;
  --ok: #166534;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1f2937 0, var(--bg) 56%) fixed;
  color: var(--inverse);
  overflow-x: hidden;
  overflow-y: auto;
}
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

.app-shell {
  min-height: 100dvh;
  display: block;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(0.75rem, 2vw, 1rem) clamp(0.75rem, 3vw, 1.5rem);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(11, 16, 32, 0.82);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.brand-mark {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.75rem;
  display: grid;
  place-items: center;
  background: #f8fafc;
  color: #111827;
  font-weight: 850;
  letter-spacing: -0.05em;
}
h1 { margin: 0; line-height: 1.08; min-width: 0; }
.title-archive { display: block; color: #cbd5e1; font-size: clamp(0.72rem, 2.2vw, 0.9rem); font-weight: 750; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: min(72vw, 42rem); }
.title-section { display: block; margin-top: 0.12rem; color: #f8fafc; font-size: clamp(1.05rem, 4.2vw, 1.55rem); font-weight: 850; letter-spacing: -0.035em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: min(72vw, 42rem); }
.brand p { margin: 0.18rem 0 0; color: #cbd5e1; font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: min(72vw, 42rem); }
.controls { display: flex; gap: 0.45rem; flex-wrap: nowrap; justify-content: flex-end; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 0.1rem; }
.controls button, .loader button, .fixture-button, .collection-button {
  border: 0;
  border-radius: 999px;
  padding: 0.56rem 0.78rem;
  background: var(--button);
  color: var(--button-text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.11);
}
.controls button:disabled { opacity: 0.42; }

.stage {
  min-height: calc(100dvh - 4.5rem);
  display: grid;
  place-items: start center;
  padding: clamp(0.7rem, 3vw, 1.5rem);
}
.talk-card {
  width: min(100%, 820px);
  min-height: min(64dvh, 520px);
  border-radius: clamp(1.2rem, 4vw, 2rem);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: clip;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-left: 7px solid var(--section-accent, #111827);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1rem, 4vw, 1.6rem);
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.role-block { display: flex; gap: 1rem; min-width: 0; align-items: center; }
.symbol {
  box-shadow: inset 0 0 0 2px rgba(148, 163, 184, 0.35);
  flex: 0 0 auto;
  width: clamp(3.2rem, 12vw, 5rem);
  height: clamp(3.2rem, 12vw, 5rem);
  border-radius: 1.25rem;
  display: grid;
  place-items: center;
  background: var(--card-soft);
  color: #1e293b;
  font-size: clamp(1.55rem, 7vw, 2.6rem);
  font-weight: 800;
}
.visual-label { margin: 0 0 0.25rem; color: var(--muted); font-size: 0.84rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
h2 { margin: 0; font-size: clamp(1.35rem, 5.4vw, 2.25rem); line-height: 1.03; letter-spacing: -0.045em; }
.badges { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; max-width: 45%; }
.badge {
  border-radius: 999px;
  padding: 0.32rem 0.55rem;
  font-size: 0.74rem;
  font-weight: 750;
  color: #334155;
  background: #e2e8f0;
  white-space: nowrap;
}
.card-body { background: #f8fafc; }
.summary-view, .expanded-view {
  padding: clamp(1rem, 4vw, 1.8rem);
}
.summary-view {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: clamp(12rem, 35dvh, 22rem);
}
.summary-view p { margin: 0; font-size: clamp(1.3rem, 5vw, 2.15rem); line-height: 1.18; font-weight: 750; letter-spacing: -0.035em; max-width: 18em; }
.expanded-view { display: none; }
.expanded-view p { font-size: clamp(1rem, 2.5vw, 1.22rem); line-height: 1.58; margin: 0; color: #1f2937; }
.talk-card.expanded .summary-view { display: none; }
.talk-card.expanded .expanded-view { display: block; }
.detail-block {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: #334155;
  font-size: 0.95rem;
  line-height: 1.5;
}
.detail-block h3 { margin: 0 0 0.5rem; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.detail-block a { color: #1d4ed8; overflow-wrap: anywhere; }
.hidden { display: none !important; }
.card-foot {
  border-top: 1px solid var(--line);
  background: #ffffff;
}
.transition-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1px;
  background: var(--line);
}
.transition-list.empty {
  display: block;
  background: #ffffff;
}
.branch {
  min-height: 5.2rem;
  border: 0;
  border-left: 0;
  padding: clamp(0.85rem, 3vw, 1.2rem);
  background: #ffffff;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.25rem;
  text-align: left;
}
.branch:not(:disabled):hover, .branch:not(:disabled):focus-visible { background: #f1f5f9; outline: none; box-shadow: inset 0 0 0 1px #cbd5e1; }
.branch:disabled { color: #94a3b8; background: var(--inactive); }
.branch-kicker { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--muted); font-weight: 800; }
.branch-label { font-size: clamp(0.98rem, 2.6vw, 1.18rem); font-weight: 820; line-height: 1.12; }
.branch-meta { font-size: 0.78rem; color: var(--muted); }
.end-card-message {
  padding: 1.1rem;
  text-align: center;
  color: #64748b;
  font-weight: 820;
}
.loader {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(2, 6, 23, 0.78);
  display: grid;
  place-items: center;
  padding: clamp(0.75rem, 3vw, 1.5rem);
}
.loader-panel {
  width: min(100%, 820px);
  max-height: min(92dvh, 820px);
  overflow: auto;
  background: #f8fafc;
  color: var(--text);
  border-radius: 1.4rem;
  box-shadow: var(--shadow);
  padding: clamp(1rem, 4vw, 1.6rem);
}
.loader-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.loader h2, .loader h3 { margin: 0; letter-spacing: -0.03em; }
.loader p { margin: 0.35rem 0 0; color: #475569; line-height: 1.45; }
.upload-box {
  display: grid;
  gap: 0.35rem;
  margin: 1rem 0;
  padding: 1.1rem;
  border: 1px dashed #94a3b8;
  border-radius: 1rem;
  background: #fff;
}
.upload-box span { font-weight: 820; }
.upload-box small { color: #64748b; }
.upload-box input { margin-top: 0.55rem; }
.loader-section { margin-top: 1rem; }
.collection-list { display: grid; gap: 0.45rem; margin-top: 0.7rem; }
.fixture-list { display: grid; gap: 0.35rem; margin-top: 0.7rem; }
.deck-heading { margin-top: 1rem !important; }
.collection-tree { border: 1px solid var(--line); border-radius: 0.75rem; background: #fff; overflow: hidden; }
.collection-tree summary { cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; padding: 0.75rem 0.9rem; font-weight: 820; color: #111827; }
.collection-tree summary small { color: #64748b; font-weight: 700; }
.deck-file-list { display: grid; gap: 0.25rem; padding: 0 0.75rem 0.75rem 1.5rem; }
.fixture-button, .collection-button { text-align: left; border-radius: 0.45rem; background: #111827; display: block; }
.deck-file-button { background: #f1f5f9; color: #111827; border: 1px solid #cbd5e1; padding: 0.55rem 0.7rem; font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 0.88rem; }
.deck-file-button:hover, .deck-file-button:focus-visible { background: #e2e8f0; outline: none; }
.fixture-button small, .collection-button small { color: #cbd5e1; line-height: 1.3; }
.collection-button em { color: #94a3b8; font-size: 0.78rem; line-height: 1.35; font-style: normal; }
.collection-button.active { background: #334155; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.32); }
.messages {
  min-height: 6rem;
  white-space: pre-wrap;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 0.85rem;
  padding: 0.9rem;
  overflow: auto;
}
@media (max-width: 680px) {
  .topbar { align-items: stretch; flex-direction: column; gap: 0.55rem; }
  .brand { align-items: flex-start; }
  .brand-mark { width: 2rem; height: 2rem; border-radius: 0.6rem; }
  .brand p { max-width: 100%; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .controls { justify-content: flex-start; margin-inline: -0.1rem; }
  .controls button { flex: 0 0 auto; padding: 0.48rem 0.62rem; font-size: 0.82rem; }
  .stage { min-height: auto; padding: 0.65rem; }
  .reader { width: 100%; }
  .talk-card { min-height: 0; border-radius: 1rem; overflow: visible; }
  .card-head { flex-direction: column; gap: 0.75rem; padding: 0.95rem; }
  .role-block { gap: 0.75rem; align-items: flex-start; }
  .symbol { width: 3rem; height: 3rem; border-radius: 0.85rem; font-size: 1.45rem; }
  .badges { max-width: 100%; justify-content: flex-start; }
  .summary-view { min-height: auto; text-align: left; justify-content: flex-start; align-items: flex-start; }
  .summary-view p { font-size: clamp(1.22rem, 6vw, 1.65rem); max-width: none; }
  .transition-list { grid-template-columns: 1fr; }
  .branch { min-height: 4.6rem; }
  .loader { place-items: stretch; }
  .loader-panel { max-height: calc(100dvh - 1.5rem); border-radius: 1rem; }
}
@media (orientation: landscape) and (max-height: 560px) {
  .topbar { padding-block: 0.45rem; }
  .talk-card { min-height: 0; }
  .summary-view { min-height: auto; }
  .summary-view p { font-size: clamp(1rem, 4vw, 1.5rem); }
  .branch { min-height: 4.25rem; }
  .symbol { width: 3rem; height: 3rem; font-size: 1.45rem; }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.landing {
  width: min(100%, 1180px);
  align-self: stretch;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(1rem, 3vw, 1.75rem);
  padding: clamp(1rem, 3vw, 1.4rem);
}
.landing-kicker {
  color: #93c5fd;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.82rem;
}
.landing h2 {
  font-size: clamp(3rem, 9vw, 5.5rem);
  line-height: 0.92;
  letter-spacing: -0.07em;
  color: #f8fafc;
}
.landing-copy {
  margin: -0.5rem 0 0;
  max-width: 46rem;
  color: #cbd5e1;
  font-size: clamp(1rem, 2.1vw, 1.25rem);
  line-height: 1.4;
}
.workflow-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(0.85rem, 2vw, 1rem);
}
.workflow-card {
  min-height: 17rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.9rem;
  padding: clamp(1.15rem, 2.8vw, 1.55rem);
  border-radius: 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.54);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.workflow-card.accent-card {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.46), rgba(15, 23, 42, 0.76));
  border-color: rgba(96, 165, 250, 0.5);
}
.step-badge {
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #304ffe;
  color: #fff;
  font-weight: 900;
  font-size: 1.05rem;
}
.workflow-card h3, .preset-strip h3 {
  margin: 0;
  font-size: clamp(1.3rem, 3vw, 1.75rem);
  line-height: 1.05;
  letter-spacing: -0.045em;
  color: #f8fafc;
}
.workflow-card p, .preset-strip p {
  margin: 0;
  color: #cbd5e1;
  line-height: 1.42;
  font-size: 1rem;
}
.primary-action, .secondary-action {
  margin-top: auto;
  min-height: 3.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0.72rem 1rem;
  background: #2563eb;
  color: #ffffff;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}
.secondary-action {
  margin-top: 0;
  min-width: 12rem;
  background: rgba(15, 23, 42, 0.82);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.file-action input { display: none; }
.preset-strip {
  display: grid;
  grid-template-columns: 1fr auto auto 1.1fr;
  align-items: center;
  gap: 1rem;
  padding: clamp(1rem, 2.6vw, 1.25rem);
  border-radius: 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.48);
}
.privacy-note {
  border-left: 1px solid rgba(148, 163, 184, 0.28);
  padding-left: 1rem;
}
.reader {
  width: min(100%, 920px);
  display: grid;
  gap: 0.75rem;
  place-items: center;
}
.deck-bar {
  width: min(100%, 820px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.78rem 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 1rem;
  background: rgba(15, 23, 42, 0.72);
  color: #f8fafc;
}
.deck-bar-kicker {
  margin: 0 0 0.2rem;
  color: #93c5fd;
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
.deck-bar strong {
  display: block;
  max-width: 58vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.deck-bar button, .demo-button {
  border: 0;
  border-radius: 999px;
  padding: 0.58rem 0.82rem;
  background: #172033;
  color: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.11);
}
.download-row, .demo-button {
  display: grid;
  gap: 0.25rem;
  width: 100%;
  text-align: left;
  border-radius: 0.8rem;
  padding: 0.85rem 0.95rem;
  text-decoration: none;
}
.download-row {
  background: #ffffff;
  color: #111827;
  border: 1px solid var(--line);
}
.download-row small, .demo-button small {
  color: #64748b;
  font-weight: 700;
}
.demo-button {
  background: #111827;
}
.demo-button small { color: #cbd5e1; }
.deck-file-button.active {
  background: #dbeafe;
  border-color: #2563eb;
}

@media (max-width: 860px) {
  .workflow-grid { grid-template-columns: 1fr; }
  .workflow-card { min-height: 13rem; }
  .preset-strip { grid-template-columns: 1fr; align-items: stretch; }
  .secondary-action { width: 100%; }
  .privacy-note { border-left: 0; padding-left: 0; }
}

/* v7: archive/section context moved into the main header; the old in-reader strip is retired. */
.deck-bar { display: none !important; }

.contents-view {
  width: min(100%, 1120px);
  align-self: stretch;
  display: grid;
  gap: 1rem;
  padding: clamp(0.9rem, 2.5vw, 1.25rem);
  color: #f8fafc;
}
.contents-head {
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 1.1rem;
  padding: clamp(1rem, 2.4vw, 1.3rem);
  background: rgba(15, 23, 42, 0.62);
}
.contents-kicker, .contents-section-kicker {
  margin: 0 0 0.3rem;
  color: #93c5fd;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
}
.contents-head h2 {
  margin: 0;
  color: #f8fafc;
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  letter-spacing: -0.055em;
}
.contents-head p:last-child {
  margin: 0.35rem 0 0;
  color: #cbd5e1;
}
.contents-list {
  display: grid;
  gap: 1rem;
  padding-bottom: 1rem;
}
.contents-section {
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 1.1rem;
  background: rgba(15, 23, 42, 0.52);
  border-top: 0;
}
.contents-section-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}
.contents-section-head h3 {
  margin: 0;
  color: #f8fafc;
  font-size: clamp(1.05rem, 2.2vw, 1.35rem);
  letter-spacing: -0.035em;
}
.contents-section-kicker {
  color: #cbd5e1;
  overflow-wrap: anywhere;
}
.contents-count {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-weight: 800;
  font-size: 0.8rem;
}
.mini-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13.5rem, 1fr));
  gap: 1px;
  background: rgba(148, 163, 184, 0.2);
}
.mini-card {
  min-height: 8rem;
  border: 0;
  border-left: 4px solid var(--section-accent, #2563eb);
  background: #f8fafc;
  color: #0f172a;
  display: grid;
  align-content: start;
  gap: 0.34rem;
  padding: 0.85rem;
  text-align: left;
}
.mini-card:hover, .mini-card:focus-visible {
  background: #eef2ff;
  outline: none;
  box-shadow: inset 0 0 0 1px #cbd5e1;
}
.mini-card-kicker, .mini-card-meta {
  color: #64748b;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
}
.mini-card strong {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 1rem;
  line-height: 1.12;
  letter-spacing: -0.025em;
}
.mini-card-summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: #475569;
  font-size: 0.82rem;
  line-height: 1.25;
}
.mini-card-meta {
  margin-top: 0.15rem;
}

@media (max-width: 680px) {
  .topbar { align-items: flex-start; }
  .brand { align-items: flex-start; }
  .title-archive, .title-section, .brand p { max-width: 62vw; }
  .contents-view { padding: 0.75rem; }
  .mini-card-grid { grid-template-columns: 1fr; }
}

/* v11 shell/card refactor: app tabs in the header; card navigation belongs to the card. */
.controls.app-tabs {
  flex: 0 0 auto;
  padding: 0.18rem;
  gap: 0.18rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.controls.app-tabs .tab-button {
  min-width: 5.6rem;
  background: transparent;
  box-shadow: none;
  color: #cbd5e1;
}
.controls.app-tabs .tab-button.active {
  background: #f8fafc;
  color: #111827;
}
.controls.app-tabs .tab-button:disabled {
  opacity: 0.38;
}

.stage {
  padding-block: clamp(1rem, 3.2vw, 2rem) clamp(1.25rem, 4vw, 2.4rem);
}
.reader {
  width: min(100%, 920px);
  height: clamp(34rem, calc(100dvh - 7.25rem), 48rem);
  display: grid;
  place-items: center;
  gap: 0;
}
.talk-card {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  width: min(100%, 820px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 8px solid var(--section-accent, #111827);
  border-top: 1px solid rgba(255,255,255,0.55);
}
.card-head {
  flex: 0 0 9.75rem;
  min-height: 9.75rem;
  max-height: 9.75rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.65rem;
  overflow: hidden;
  padding: clamp(0.95rem, 2.3vw, 1.25rem);
}
.card-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
}
.card-title-row .role-block {
  min-width: 0;
  flex: 1 1 auto;
}
.card-title-row h2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-tools {
  flex: 0 0 auto;
  display: flex;
  gap: 0.35rem;
  align-items: center;
  justify-content: flex-end;
}
.card-tools button {
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.65rem;
  background: #e2e8f0;
  color: #0f172a;
  font-size: 0.82rem;
  font-weight: 800;
}
.card-tools button:disabled {
  opacity: 0.42;
}
.card-tools button:not(:disabled):hover,
.card-tools button:not(:disabled):focus-visible {
  background: #cbd5e1;
  outline: none;
}
.badges {
  max-width: 100%;
  justify-content: flex-start;
  overflow: hidden;
  max-height: 2.15rem;
}
.badge {
  font-size: 0.7rem;
  padding: 0.28rem 0.5rem;
}
.card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.summary-view,
.expanded-view {
  min-height: 100%;
  padding: clamp(1.1rem, 3vw, 2rem);
}
.summary-view {
  min-height: 100%;
}
.expanded-view {
  min-height: 100%;
}
.card-foot {
  flex: 0 0 7.25rem;
  min-height: 7.25rem;
  max-height: 7.25rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.transition-list {
  min-height: 100%;
}
.branch {
  min-height: 7.25rem;
}
.transition-list:has(.branch:nth-child(3)) .branch {
  min-height: 5.1rem;
}
.end-card-message {
  min-height: 7.25rem;
  display: grid;
  place-items: center;
}

@media (max-width: 760px) {
  .topbar {
    position: sticky;
    align-items: stretch;
    flex-direction: column;
    gap: 0.55rem;
    padding: 0.65rem 0.7rem;
  }
  .brand-mark { width: 2rem; height: 2rem; border-radius: 0.6rem; }
  .title-archive, .title-section, .brand p { max-width: calc(100vw - 4.8rem); }
  .title-section { font-size: clamp(1.05rem, 6vw, 1.45rem); }
  .controls.app-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    overflow: visible;
  }
  .controls.app-tabs .tab-button {
    min-width: 0;
    width: 100%;
    padding: 0.5rem 0.35rem;
  }
  .stage {
    padding: 0.8rem 0.65rem 1.1rem;
  }
  .reader {
    width: 100%;
    height: clamp(31rem, calc(100dvh - 8.8rem), 42rem);
  }
  .talk-card {
    width: 100%;
    border-radius: 1rem;
    border-left-width: 6px;
  }
  .card-head {
    flex-basis: 8.7rem;
    min-height: 8.7rem;
    max-height: 8.7rem;
    padding: 0.85rem;
  }
  .card-title-row {
    gap: 0.55rem;
  }
  .role-block { gap: 0.6rem; }
  .symbol {
    width: 2.65rem;
    height: 2.65rem;
    border-radius: 0.75rem;
    font-size: 1.25rem;
  }
  .visual-label { font-size: 0.68rem; margin-bottom: 0.15rem; }
  .card-title-row h2 {
    font-size: clamp(1.15rem, 6.2vw, 1.62rem);
    -webkit-line-clamp: 2;
  }
  .card-tools {
    flex-direction: column;
    gap: 0.2rem;
  }
  .card-tools button {
    width: 4.3rem;
    padding: 0.32rem 0.42rem;
    font-size: 0.72rem;
  }
  .badges {
    flex-wrap: nowrap;
    overflow-x: auto;
    max-height: 1.9rem;
  }
  .badge { flex: 0 0 auto; }
  .summary-view, .expanded-view {
    padding: 1rem;
  }
  .summary-view {
    text-align: left;
    justify-content: flex-start;
    align-items: center;
  }
  .summary-view p {
    font-size: clamp(1.25rem, 7vw, 1.8rem);
    max-width: none;
  }
  .card-foot {
    flex-basis: 7rem;
    min-height: 7rem;
    max-height: 7rem;
  }
  .transition-list {
    grid-template-columns: 1fr;
  }
  .branch, .end-card-message {
    min-height: 3.5rem;
  }
  .branch {
    padding: 0.68rem 0.85rem;
  }
  .branch-label { font-size: 0.98rem; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .topbar { position: static; }
  .reader { height: 25rem; }
  .card-head {
    flex-basis: 6.4rem;
    min-height: 6.4rem;
    max-height: 6.4rem;
  }
  .card-foot {
    flex-basis: 5.7rem;
    min-height: 5.7rem;
    max-height: 5.7rem;
  }
  .branch { min-height: 2.9rem; }
  .symbol { width: 2.35rem; height: 2.35rem; font-size: 1.1rem; }
  .badges { display: none; }
}

/* v12 simplified shell: page header, spacer, fixed content, spacer, footer. */
html, body {
  height: 100%;
}
body {
  overflow: hidden;
}
.app-shell {
  height: 100dvh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.topbar {
  position: static;
  flex: 0 0 auto;
}
.stage {
  min-height: 0;
  height: 100%;
  width: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: clamp(0.9rem, 2.5vh, 1.6rem) clamp(0.75rem, 3vw, 1.5rem);
}
.page-footer {
  min-height: 2.15rem;
  padding: 0.45rem clamp(0.75rem, 3vw, 1.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: #94a3b8;
  font-size: 0.78rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: rgba(11,16,32,0.78);
}
.landing,
.contents-view,
.reader {
  width: min(100%, 980px);
  max-height: 100%;
}
.landing,
.contents-view {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.reader {
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
}
.talk-card {
  width: min(100%, 820px);
  height: 100%;
  min-height: 0;
  max-height: 100%;
  display: grid;
  grid-template-rows: 9.25rem minmax(0, 1fr) 10.25rem;
  border-left: 7px solid var(--section-accent, #111827);
  overflow: hidden;
}
.card-head {
  min-height: 0;
  max-height: none;
  height: auto;
  flex: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(0.9rem, 2.4vw, 1.2rem);
}
.card-body {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.summary-view,
.expanded-view {
  min-height: 100%;
}
.summary-view {
  min-height: 100%;
}
.card-foot {
  min-height: 0;
  max-height: none;
  height: auto;
  flex: none;
  overflow: hidden;
}
.transition-list {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.branch {
  min-height: 0;
  height: 100%;
  padding: 0.8rem 0.95rem;
}
.branch-label {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.branch-meta {
  display: none;
}
.end-card-message {
  height: 100%;
  display: grid;
  place-items: center;
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    gap: 0.55rem;
    padding: 0.62rem 0.7rem;
  }
  .brand-mark { width: 2rem; height: 2rem; }
  .title-archive,
  .title-section,
  .brand p { max-width: calc(100vw - 4.8rem); }
  .controls.app-tabs {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  .controls.app-tabs .tab-button {
    min-width: 0;
    width: 100%;
    padding: 0.45rem 0.35rem;
  }
  .stage {
    padding: 0.65rem;
  }
  .page-footer {
    min-height: 1.85rem;
    padding-block: 0.34rem;
  }
  .page-footer span:last-child {
    display: none;
  }
  .talk-card {
    width: 100%;
    border-radius: 1rem;
    border-left-width: 6px;
    grid-template-rows: 8.2rem minmax(0, 1fr) 9.2rem;
  }
  .card-head {
    padding: 0.75rem;
  }
  .role-block { gap: 0.58rem; }
  .symbol {
    width: 2.55rem;
    height: 2.55rem;
    border-radius: 0.72rem;
    font-size: 1.15rem;
  }
  .visual-label { font-size: 0.66rem; margin-bottom: 0.12rem; }
  .card-title-row h2 {
    font-size: clamp(1.08rem, 5.8vw, 1.5rem);
    -webkit-line-clamp: 2;
  }
  .card-tools {
    gap: 0.18rem;
    flex-direction: column;
  }
  .card-tools button {
    width: 4.05rem;
    padding: 0.28rem 0.36rem;
    font-size: 0.68rem;
  }
  .badges {
    max-width: 100%;
    max-height: 1.75rem;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .badge { flex: 0 0 auto; font-size: 0.68rem; padding: 0.25rem 0.45rem; }
  .summary-view,
  .expanded-view {
    padding: 0.95rem;
  }
  .summary-view {
    text-align: left;
    justify-content: flex-start;
  }
  .summary-view p {
    font-size: clamp(1.18rem, 6.2vw, 1.7rem);
    max-width: none;
  }
  .transition-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }
  .branch {
    padding: 0.55rem 0.48rem;
    gap: 0.12rem;
  }
  .branch-kicker { font-size: 0.58rem; letter-spacing: 0.06em; }
  .branch-label { font-size: 0.76rem; line-height: 1.08; }
}

@media (max-height: 560px) and (orientation: landscape) {
  .talk-card {
    grid-template-rows: 6.3rem minmax(0, 1fr) 6.2rem;
  }
  .badges { display: none; }
  .symbol { width: 2.25rem; height: 2.25rem; font-size: 1rem; }
  .branch-label { font-size: 0.72rem; }
}

/* v14: simpler two-column card header and compact card controls */
.card-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: clamp(0.6rem, 2vw, 1rem);
  width: 100%;
}
.card-title-row .role-block {
  min-width: 0;
  width: 100%;
}
.card-title-row .role-block > div {
  min-width: 0;
}
.card-title-row h2 {
  max-width: 100%;
}
.card-tools {
  flex: 0 0 auto;
  min-width: 0;
  display: grid;
  grid-template-columns: 2.25rem auto 2.25rem;
  align-items: center;
  justify-content: end;
  gap: 0.34rem;
  padding-top: 0.15rem;
}
.card-tools button {
  min-width: 0;
  min-height: 2.1rem;
  border-radius: 999px;
  padding: 0.42rem 0.62rem;
  line-height: 1;
}
.card-tools .card-icon-btn {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
}
.card-tools .back-control {
  font-size: 1.18rem;
}
.card-tools .reset-control {
  padding-inline: 0.72rem;
  font-size: 0.78rem;
}
.card-tools .view-control {
  font-size: 1.1rem;
}
@media (max-width: 760px) {
  .card-title-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.45rem;
  }
  .card-tools {
    grid-template-columns: 1.9rem;
    grid-auto-rows: 1.9rem;
    gap: 0.22rem;
  }
  .card-tools .card-icon-btn,
  .card-tools button {
    width: 1.9rem;
    height: 1.9rem;
    min-height: 1.9rem;
    padding: 0;
    font-size: 0.9rem;
  }
  .card-tools .reset-control {
    width: 3.55rem;
    justify-self: end;
    padding-inline: 0.2rem;
    font-size: 0.62rem;
  }
}

.download-row {
  appearance: none;
  width: 100%;
  text-align: left;
  font: inherit;
}
