.chapter-studio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 392px;
  min-height: calc(100vh - 72px);
}

.classroom-account {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 3px 4px 3px 11px;
  border: 1px solid #c8cfcc;
  border-radius: 999px;
  background: #fff;
  color: #35534f;
  font-size: 12px;
}

.classroom-account[hidden] {
  display: none;
}

.classroom-account-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.classroom-logout {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: #edf2f0;
  cursor: pointer;
  color: #35534f;
  font-size: 11px;
}

.classroom-logout:hover {
  background: #dfe9e6;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #c8cfcc;
  border-radius: 999px;
  background: #fff;
  color: #42615d;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chapter-workspace {
  min-width: 0;
  padding: 34px clamp(20px, 4vw, 64px) 64px;
}

.workspace-heading {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  max-width: 1120px;
  margin: 0 auto 26px;
}

.workspace-heading h1 {
  margin: 0;
  font-size: clamp(28px, 3.2vw, 46px);
  line-height: 1.12;
}

.workspace-heading p {
  max-width: 620px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.heading-mark {
  display: grid;
  width: 76px;
  height: 76px;
  flex: 0 0 76px;
  place-items: center;
  border: 1px solid #e2c8b9;
  border-radius: 20px;
  background: #fff7f1;
  color: var(--accent);
  box-shadow: 0 14px 32px rgba(119, 77, 52, 0.09);
}

.heading-mark svg {
  width: 34px;
  height: 34px;
}

.chapter-empty {
  display: grid;
  max-width: 1120px;
  min-height: min(64vh, 620px);
  margin: 0 auto;
  place-items: center;
  align-content: center;
  padding: 52px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.78);
  box-shadow: var(--shadow);
  text-align: center;
}

.chapter-empty[hidden],
.generation-view[hidden] {
  display: none;
}

.empty-visual {
  position: relative;
  display: grid;
  width: 210px;
  height: 150px;
  margin-bottom: 26px;
  place-items: center;
}

.empty-slide {
  position: relative;
  z-index: 1;
  display: grid;
  width: 152px;
  height: 96px;
  place-items: center;
  border: 1px solid #b9cbc8;
  border-radius: 12px;
  background: #fff;
  color: var(--blue);
  box-shadow: 0 18px 36px rgba(31, 63, 66, 0.12);
}

.empty-slide::before,
.empty-slide::after {
  position: absolute;
  width: 120px;
  height: 76px;
  border: 1px solid #d6dfdc;
  border-radius: 10px;
  background: #f8faf9;
  content: "";
}

.empty-slide::before {
  z-index: -2;
  top: 16px;
  left: -18px;
  transform: rotate(-7deg);
}

.empty-slide::after {
  z-index: -1;
  top: 14px;
  right: -17px;
  transform: rotate(7deg);
}

.empty-slide svg {
  width: 38px;
  height: 38px;
}

.empty-track {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.empty-track::before {
  position: absolute;
  right: 30px;
  left: 30px;
  height: 1px;
  background: #cbd5d2;
  content: "";
}

.empty-track i {
  position: relative;
  width: 9px;
  height: 9px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px #d7aa93;
}

.chapter-empty h2 {
  margin: 0;
  font-size: 23px;
}

.chapter-empty p {
  margin: 10px 0 22px;
  color: var(--muted);
  font-size: 13px;
}

.generation-view {
  display: grid;
  max-width: 1120px;
  gap: 30px;
  margin: 0 auto;
  animation: chapter-reveal 260ms ease both;
}

@keyframes chapter-reveal {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.generation-card {
  padding: 25px 27px 23px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 253, 248, 0.96);
  box-shadow: var(--shadow);
}

.generation-header {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
}

.generation-file {
  display: flex;
  min-width: 0;
  gap: 14px;
  align-items: center;
}

.file-icon {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  place-items: center;
  border-radius: 12px;
  background: #eef3f1;
  color: var(--blue);
}

.file-icon svg {
  width: 23px;
  height: 23px;
}

.generation-file h2 {
  max-width: 720px;
  margin: 2px 0 0;
  overflow: hidden;
  font-size: 18px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.generation-file p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.status-pill,
.chapter-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.status-pill.is-waiting,
.chapter-status.is-waiting {
  border-color: #d9d7cb;
  background: #f6f4ee;
  color: #74736c;
}

.status-pill.is-active,
.chapter-status.is-active {
  border-color: #b9d4db;
  background: #eaf4f6;
  color: #276b85;
}

.status-pill.is-ready,
.chapter-status.is-ready {
  border-color: #b9d5cb;
  background: #eaf5f0;
  color: #287b61;
}

.status-pill.is-error,
.chapter-status.is-error {
  border-color: #e2b9b3;
  background: #fbeeeb;
  color: #a93d32;
}

.status-pill.is-paused,
.chapter-status.is-paused {
  border-color: #e0c9a4;
  background: #fbf3e4;
  color: #8a6118;
}

.progress-block {
  margin-top: 24px;
}

.progress-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
}

.progress-copy strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e8e1;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 320ms ease;
}

.generation-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 20px;
}

.generation-stats > div {
  padding: 13px 15px;
  border: 1px solid #dfe2dd;
  border-radius: 10px;
  background: #fafbf8;
}

.generation-stats span,
.generation-stats strong {
  display: block;
}

.generation-stats span {
  color: var(--muted);
  font-size: 11px;
}

.generation-stats strong {
  margin-top: 4px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.chapter-section-heading {
  display: flex;
  gap: 18px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 15px;
}

.chapter-section-heading h2 {
  margin: 0;
  font-size: 21px;
}

.chapter-hint {
  color: var(--muted);
  font-size: 11px;
}

.chapter-heading-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.chapter-list {
  display: grid;
  gap: 10px;
}

.chapter-placeholder {
  display: grid;
  min-height: 180px;
  place-items: center;
  align-content: center;
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: rgba(255, 253, 248, 0.72);
  text-align: center;
}

.chapter-placeholder .loader {
  margin-bottom: 13px;
}

.chapter-placeholder strong,
.chapter-placeholder small {
  display: block;
}

.chapter-placeholder strong {
  font-size: 14px;
}

.chapter-placeholder small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.chapter-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 7px 20px rgba(27, 44, 42, 0.045);
}

.chapter-card.is-ready {
  border-color: #c7dcd4;
}

.chapter-card.is-error {
  border-color: #e5c5bf;
}

.chapter-number {
  display: grid;
  min-height: 112px;
  place-items: center;
  border-right: 1px solid #e5e5df;
  background: #f7f6f1;
  color: #9a9c95;
  font-size: 13px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.chapter-card.is-ready .chapter-number {
  background: #eef6f2;
  color: var(--success);
}

.chapter-card.is-error .chapter-number {
  background: #fbefec;
  color: var(--danger);
}

.chapter-card-body {
  display: grid;
  gap: 14px;
  padding: 16px 18px 15px;
}

.chapter-card-title {
  display: flex;
  min-width: 0;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
}

.chapter-card-title h3 {
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-card-title p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.chapter-progress {
  display: grid;
  gap: 7px;
}

.chapter-progress-copy {
  display: flex;
  min-width: 0;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.chapter-progress-copy span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-progress-copy strong {
  flex: 0 0 auto;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.chapter-progress-track {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8e8e1;
}

.chapter-progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 320ms ease;
}

.chapter-card.is-ready .chapter-progress-track span {
  background: var(--success);
}

.chapter-card.is-error .chapter-progress-track span {
  background: var(--danger);
}

.chapter-card-footer {
  display: flex;
  min-width: 0;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding-top: 13px;
  border-top: 1px solid #ecece6;
}

.chapter-detail {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-actions {
  display: flex;
  gap: 7px;
  align-items: center;
  flex: 0 0 auto;
}

.chapter-action-button {
  display: inline-flex;
  min-height: 34px;
  gap: 6px;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--blue);
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.chapter-action-button:hover {
  border-color: var(--line-strong);
}

.chapter-action-button.is-primary {
  border-color: #b8cfc7;
  background: #eff7f3;
  color: var(--success);
}

.chapter-action-button.is-danger {
  border-color: #e2c3bd;
  background: #fdf3f1;
  color: var(--danger);
}

.chapter-action-button.is-danger:hover {
  border-color: #cfa49c;
}

.chapter-action-button:disabled {
  opacity: 0.62;
  cursor: default;
}

.chapter-action-button svg {
  width: 15px;
  height: 15px;
}

.chapter-working {
  display: inline-flex;
  min-height: 34px;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.chapter-working .loader {
  width: 15px;
  height: 15px;
  border-width: 2px;
}

.chapter-card-title h3 {
  display: flex;
  gap: 7px;
  align-items: center;
}

.chapter-card-title h3 svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: #d18a27;
}

.chapter-sections {
  display: grid;
  gap: 8px;
}

.section-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid #e6e8e3;
  border-radius: 9px;
  background: #fbfcf9;
}

.section-card.is-ready {
  border-color: #d2e5dc;
  background: #f7fbf8;
}

.section-card.is-error {
  border-color: #edd3cf;
  background: #fff9f8;
}

.section-number {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 8px;
  background: #eff1ec;
  color: #777b75;
  font-size: 10px;
  font-weight: 800;
}

.section-card.is-ready .section-number {
  background: #e2f2e9;
  color: var(--success);
}

.section-card.is-error .section-number {
  background: #f9e5e1;
  color: var(--danger);
}

.section-card-main {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.section-card-heading {
  display: flex;
  min-width: 0;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.section-card-heading strong,
.section-card-heading small {
  display: block;
}

.section-card-heading strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.section-card-heading small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.section-status {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
}

.section-card.is-ready .section-status {
  color: var(--success);
}

.section-card.is-error .section-status {
  color: var(--danger);
}

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

.compact-library-section {
  padding: 18px;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.compact-upload-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.upload-progress {
  margin: 10px 0 0;
  padding: 9px 10px;
  border-radius: 8px;
  background: #edf5f3;
  color: #285d55;
  font-size: 11px;
  line-height: 1.45;
}

.upload-progress.is-error {
  background: #fff0ed;
  color: #9b4135;
}

.library-title-actions {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.library-clear-button {
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid #d3b58e;
  border-radius: 999px;
  background: #fff8ec;
  color: #8d5930;
  cursor: pointer;
  font-size: 10px;
}

.library-clear-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.compact-library-list {
  max-height: 318px;
  margin-top: 12px;
  overflow-y: auto;
}

.library-list {
  display: grid;
  gap: 7px;
}

.library-empty {
  padding: 24px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.library-item {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 24px;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.library-item:hover {
  border-color: var(--line-strong);
}

.library-item.is-selected {
  border-color: var(--blue);
  background: var(--blue-soft);
  box-shadow: 0 0 0 2px rgba(39, 107, 133, 0.08);
}

.library-order {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: #eef2f0;
  color: var(--blue);
  font-size: 11px;
  font-weight: 750;
}

.library-item.is-selected .library-order {
  background: var(--blue);
  color: #fff;
}

.library-meta {
  min-width: 0;
}

.library-meta strong,
.library-meta span {
  display: block;
}

.library-meta strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-meta span {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-check {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  color: var(--blue);
}

.library-check svg {
  width: 15px;
  height: 15px;
}

.selected-file {
  display: grid;
  gap: 5px;
  margin-top: 13px;
  padding: 11px 12px;
  border: 1px solid #dfe2dd;
  border-radius: 9px;
  background: #fafbf8;
}

.selected-file span {
  color: var(--muted);
  font-size: 10px;
}

.selected-file strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-preview {
  width: min(960px, calc(100vw - 40px));
  max-height: calc(100vh - 48px);
  padding: 20px;
  overflow: auto;
  border: 1px solid #cfd5d1;
  border-radius: 14px;
  background: #fffdf8;
  color: var(--ink);
  box-shadow: 0 28px 80px rgba(20, 30, 30, 0.24);
}

.chapter-preview::backdrop {
  background: rgba(15, 24, 24, 0.58);
  backdrop-filter: blur(4px);
}

.preview-heading {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 15px;
}

.preview-heading h2 {
  margin: 0;
  font-size: 20px;
}

.preview-heading p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.preview-heading .icon-button {
  flex: 0 0 auto;
}

.chapter-preview video {
  display: block;
  width: 100%;
  max-height: calc(100vh - 230px);
  border-radius: 10px;
  background: #10201e;
}

.preview-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

@media (max-width: 1080px) {
  .chapter-studio {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    position: static;
    height: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 720px) {
  .classroom-account-name {
    display: none;
  }

  .chapter-workspace {
    padding: 24px 16px 42px;
  }

  .workspace-heading {
    align-items: flex-start;
  }

  .heading-mark {
    display: none;
  }

  .workspace-heading h1 {
    font-size: 30px;
  }

  .chapter-empty {
    min-height: 430px;
  }

  .generation-card {
    padding: 20px 17px;
  }

  .generation-header,
  .chapter-card-title,
  .chapter-card-footer,
  .chapter-section-heading,
  .chapter-heading-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-pill {
    align-self: flex-start;
  }

  .generation-file {
    width: 100%;
  }

  .generation-file h2 {
    max-width: calc(100vw - 118px);
  }

  .generation-stats {
    grid-template-columns: 1fr;
  }

  .chapter-card {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .chapter-number {
    min-height: 150px;
  }

  .chapter-card-body {
    padding: 14px;
  }

  .chapter-card-title h3,
  .chapter-progress-copy span,
  .chapter-detail {
    white-space: normal;
  }

  .chapter-actions {
    width: 100%;
  }

  .section-card {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .section-actions {
    grid-column: 2;
    width: 100%;
  }

  .section-actions .chapter-action-button {
    flex: 1;
  }

  .chapter-action-button {
    flex: 1;
  }

  .chapter-preview {
    width: calc(100vw - 20px);
    padding: 14px;
  }
}

@media (max-width: 480px) {
  .topbar-actions .runtime-status {
    display: none;
  }

  .brand small {
    display: none;
  }

  .compact-upload-actions {
    grid-template-columns: 1fr;
  }
}
