:root {
  --bg: #101214;
  --panel: #171a1d;
  --line: #2d3337;
  --text: #f3f4f2;
  --muted: #a8aeac;
  --subtle: #757d7d;
  --accent: #76c7bd;
  --warm: #d9bd72;
  --radius: 6px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

button {
  font: inherit;
  color: inherit;
}

.deck-shell {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg);
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
}

.case-type {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

h1 {
  margin: 0;
  font-size: clamp(17px, 1.8vw, 21px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: 0;
}

.topbar-actions,
.text-button {
  display: flex;
  align-items: center;
}

.icon-button,
.text-button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
}

.icon-button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
}

.icon-button svg,
.text-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button:hover,
.text-button:hover {
  border-color: var(--accent);
}

.stage-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) minmax(160px, 24vh);
  gap: 10px;
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 12px 18px;
  overflow: hidden;
}

.media-stage {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #060708;
}

.media-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  place-items: center;
}

.empty-media {
  color: var(--muted);
  font-size: 15px;
}

.empty-media code {
  color: var(--accent);
}

.cine-viewer {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  background: #020303;
}

.cine-frame,
.cine-video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  background: #020303;
  cursor: pointer;
}

.cine-topline {
  position: absolute;
  z-index: 3;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  pointer-events: none;
}

.cine-topline {
  top: 12px;
}

.cine-topline span {
  padding: 6px 8px;
  border-radius: var(--radius);
  background: rgba(6, 7, 8, 0.72);
}

.cine-controls {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  background: #101214;
}

.cine-controls button,
.cine-strip button,
.clip-step {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.frame-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cine-controls button {
  min-height: 28px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 650;
}

.frame-stepper button {
  width: 32px;
  padding: 0;
  display: grid;
  place-items: center;
}

.frame-stepper svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cine-controls input {
  width: 100%;
  height: 22px;
  accent-color: var(--accent);
  cursor: ew-resize;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #3a4247;
  border-radius: 5px;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.18) 0,
      rgba(255, 255, 255, 0.18) 1px,
      transparent 1px,
      transparent 24px
    ),
    linear-gradient(180deg, #24292d, #171b1e);
}

.cine-controls input::-webkit-slider-runnable-track {
  height: 20px;
  border-radius: 5px;
  background: transparent;
}

.cine-controls input::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 9px;
  height: 28px;
  margin-top: -4px;
  border: 1px solid rgba(0, 0, 0, 0.42);
  border-radius: 999px;
  background: var(--accent);
}

.cine-controls input::-moz-range-track {
  height: 20px;
  border-radius: 5px;
  background: transparent;
}

.cine-controls input::-moz-range-thumb {
  width: 9px;
  height: 28px;
  border: 1px solid rgba(0, 0, 0, 0.42);
  border-radius: 999px;
  background: var(--accent);
}

.cine-strip-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  gap: 6px;
  align-items: stretch;
  padding: 0 10px 10px;
  background: #101214;
}

.cine-strip {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.cine-strip button {
  flex: 0 0 clamp(138px, 13vw, 210px);
  min-height: 36px;
  padding: 6px 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  text-align: left;
}

.cine-strip button span {
  display: block;
  margin-bottom: 2px;
  color: var(--subtle);
  font-weight: 750;
}

.cine-strip button[aria-current] {
  border-color: rgba(118, 199, 189, 0.75);
  color: var(--text);
}

.cine-strip button[aria-current] span {
  color: var(--accent);
}

.clip-step {
  min-width: 0;
  padding: 0;
  display: grid;
  place-items: center;
}

.clip-step:disabled {
  cursor: default;
  opacity: 0.35;
}

.clip-step svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.teaching-strip {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 0;
}

.teaching-strip.case-collapsed {
  grid-template-columns: 44px minmax(0, 1fr);
}

.teaching-strip.questions-collapsed {
  grid-template-columns: minmax(0, 1fr) 44px;
}

.teaching-strip.case-collapsed.questions-collapsed {
  grid-template-columns: 44px 44px;
}

.key-column {
  min-height: 0;
}

.teaching-card {
  min-height: 0;
  height: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: auto;
}

.teaching-card span {
  margin: 0;
  color: var(--subtle);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.content-heading {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

[data-collapse-card] {
  cursor: pointer;
}

[data-collapse-card]:hover {
  color: var(--text);
}

.heading-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.slide-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

.slide-toggle button {
  min-width: 0;
  padding: 4px 8px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.slide-toggle button[aria-current] {
  background: var(--accent);
  color: #07110f;
}

.font-controls {
  display: inline-flex;
  gap: 4px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.02);
}

.font-controls button {
  min-width: 34px;
  padding: 5px 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.font-controls button:hover {
  background: #22282b;
  color: var(--text);
}

.teaching-card.is-collapsed {
  align-self: stretch;
  height: 100%;
  min-width: 0;
  padding: 10px 8px;
  overflow: hidden;
  cursor: pointer;
}

.teaching-card.is-collapsed .content-heading {
  height: 100%;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.teaching-card.is-collapsed .content-heading > span {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  white-space: nowrap;
}

.teaching-card.is-collapsed .heading-actions {
  flex-direction: column;
}

.teaching-card.is-collapsed .slide-toggle {
  display: none;
}

.teaching-card.is-collapsed .font-controls {
  display: none;
}

.teaching-card.is-collapsed .collapsible-content {
  display: none;
}

.teaching-card p,
.key-content {
  margin: 8px 0 0;
  color: var(--text);
  font-size: calc(clamp(15px, 1.45vw, 20px) + (var(--font-step, 0) * 1px));
  line-height: 1.34;
}

.timeline-list {
  margin: 8px 0 0;
  padding-left: 22px;
  color: var(--text);
  font-size: calc(clamp(13px, 1vw, 16px) + (var(--font-step, 0) * 1px));
  line-height: 1.24;
}

.timeline-list li + li {
  margin-top: 7px;
}

.question-list {
  margin: 10px 0 0;
  padding: 0 0 0 20px;
  color: var(--text);
  font-size: calc(clamp(14px, 1.25vw, 18px) + (var(--font-step, 0) * 1px));
  line-height: 1.32;
}

.question-list li + li {
  margin-top: 10px;
}

@media (min-width: 1180px) and (min-aspect-ratio: 3 / 2) {
  .stage-panel {
    width: 100%;
    grid-template-columns: minmax(300px, 32vw) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "text media";
    gap: 12px;
  }

  .media-stage {
    grid-area: media;
  }

  .teaching-strip {
    grid-area: text;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }

  .teaching-strip.case-collapsed,
  .teaching-strip.questions-collapsed,
  .teaching-strip.case-collapsed.questions-collapsed {
    grid-template-columns: 1fr;
  }

  .teaching-strip.case-collapsed {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .teaching-strip.questions-collapsed {
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .teaching-strip.case-collapsed.questions-collapsed {
    grid-template-rows: auto auto;
  }

  .teaching-card {
    padding: 18px;
  }

  .teaching-card p,
  .key-content {
    font-size: calc(clamp(18px, 1.65vw, 24px) + (var(--font-step, 0) * 1px));
    line-height: 1.32;
  }

  .timeline-list {
    font-size: calc(clamp(13px, 0.9vw, 15px) + (var(--font-step, 0) * 1px));
    line-height: 1.22;
  }

  .question-list {
    font-size: calc(clamp(16px, 1.35vw, 20px) + (var(--font-step, 0) * 1px));
  }
}

.text-button {
  gap: 7px;
  min-width: 104px;
  justify-content: center;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 650;
}

.text-button.primary {
  border-color: transparent;
  background: var(--accent);
  color: #07110f;
}

@media (max-width: 760px) {
  .topbar {
    padding-inline: 14px;
  }

  h1 {
    font-size: 19px;
  }

  .stage-panel {
    grid-template-rows: minmax(0, 1fr) minmax(220px, 30vh);
    padding: 10px;
    gap: 8px;
  }

  .cine-controls {
    grid-template-columns: auto 1fr auto;
  }

  .teaching-strip {
    grid-template-columns: 1fr;
  }

  .cine-strip-row {
    grid-template-columns: 30px minmax(0, 1fr) 30px;
  }

  .teaching-card {
    min-height: 0;
  }

  .content-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}

@media (max-height: 760px) {
  .case-type {
    display: none;
  }

  .topbar {
    min-height: 48px;
    padding-block: 8px;
  }

  .stage-panel {
    padding-block: 8px;
    gap: 8px;
  }

  .cine-strip button {
    min-height: 30px;
    font-size: 10px;
  }

  .teaching-card {
    min-height: 0;
    padding: 12px 13px;
  }

  .control-bar {
    min-height: 48px;
    padding-block: 8px;
  }
}
