:root {
  --navy: #052a63;
  --navy-2: #083a82;
  --orange: #f05a1a;
  --paper: #f7f9fc;
  --line: #d8e1ef;
  --text: #172033;
  --muted: #667085;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--paper);
  color: var(--text);
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

body { overflow-x: hidden; }

button, textarea { font: inherit; }

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: #fff;
  font-weight: 800;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.version-note {
  color: #98a2b3;
  font-size: 10px;
  line-height: 1.2;
  margin-top: 2px;
}

h1, h2, h3 { margin: 0; letter-spacing: 0; }

h1 {
  font-size: 22px;
  line-height: 1.2;
  color: var(--navy);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn,
.action-btn,
.nav-btn,
.copy-btn,
.download-link {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 8px;
  cursor: pointer;
  min-height: 38px;
}

.icon-btn {
  width: 40px;
  padding: 0;
  font-size: 18px;
}

.action-btn,
.copy-btn,
.download-link {
  padding: 8px 12px;
  font-weight: 700;
}

.action-btn:hover,
.icon-btn:hover,
.copy-btn:hover,
.download-link:hover,
.nav-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr) minmax(260px, 360px);
  grid-template-areas: "left main right";
  gap: 0;
  min-height: calc(100vh - 72px);
}

.left-panel,
.right-panel {
  background: #fff;
  border-right: 1px solid var(--line);
  overflow: auto;
  max-height: calc(100vh - 72px);
}

.left-panel {
  grid-area: left;
}

.main-panel {
  grid-area: main;
}

.right-panel {
  grid-area: right;
  border-right: 0;
  border-left: 1px solid var(--line);
}

.panel-title {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 14px 16px;
  color: var(--navy);
  font-weight: 800;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.slide-list {
  padding: 8px;
}

.slide-list button {
  width: 100%;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.slide-list button:hover,
.slide-list button.active {
  background: #edf3ff;
}

.slide-no {
  color: var(--orange);
  font-weight: 900;
}

.slide-list-title {
  color: var(--navy);
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slide-list-cat {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.main-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 14px;
}

.slide-stage {
  position: relative;
  min-width: 0;
}

.slide-toolbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.slide-kicker {
  color: var(--orange);
  font-size: 13px;
  font-weight: 800;
}

#slideTitle {
  color: var(--navy);
  font-size: 24px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.nav-btn {
  height: 44px;
  font-size: 30px;
  line-height: 1;
}

.slide-image {
  display: block;
  width: 100%;
  max-height: calc(100vh - 250px);
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(5, 42, 99, 0.08);
  cursor: zoom-in;
}

.notes-panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.notes-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.notes-head h3 {
  color: var(--navy);
  font-size: 16px;
}

#saveStatus {
  color: var(--muted);
  font-size: 12px;
}

#slideNoteInput {
  width: 100%;
  min-height: 112px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  line-height: 1.6;
}

.focus-box,
.prompt-list,
.download-list {
  padding: 14px 16px;
}

.download-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.focus-card,
.prompt-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 12px;
  background: #fff;
}

.focus-card strong,
.prompt-card h3 {
  color: var(--navy);
}

.focus-card p,
.prompt-card pre {
  margin: 8px 0 0;
  line-height: 1.6;
}

.usage-label {
  color: var(--muted);
  font-weight: 700;
}

.meta-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.pill {
  border: 1px solid #c8d6ee;
  background: #f2f6fc;
  color: var(--navy);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
}

.prompt-card pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  max-height: 320px;
  overflow: auto;
}

.copy-btn {
  margin-top: 10px;
}

.download-link {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  text-align: center;
  flex: 1 0 100%;
}

.download-dot {
  width: 12px;
  height: 12px;
  min-height: 12px;
  flex: 0 0 12px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  font-size: 0;
  line-height: 0;
}

.download-dot-blue {
  background: #0b5bd3;
}

.download-dot-red {
  background: #d92d20;
}

.download-dot:hover {
  transform: scale(1.16);
  box-shadow: 0 0 0 4px rgba(5, 42, 99, 0.08);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(3, 14, 32, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.lightbox.open { display: flex; }

.lightbox img {
  max-width: 96vw;
  max-height: 92vh;
  object-fit: contain;
}

#closeLightboxBtn {
  position: fixed;
  top: 14px;
  right: 18px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  font-size: 30px;
  cursor: pointer;
}

.exit-fullscreen {
  display: none;
  position: absolute;
  right: 14px;
  top: 58px;
  z-index: 5;
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
}

.slide-stage:fullscreen {
  background: #07182f;
  display: grid;
  place-items: center;
  padding: 24px;
}

.slide-stage:fullscreen .slide-toolbar { display: none; }
.slide-stage:fullscreen .exit-fullscreen { display: block; }
.slide-stage:fullscreen .slide-image {
  max-width: 96vw;
  max-height: 92vh;
  border: 0;
}

.left-collapsed .workspace {
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  grid-template-areas: "main right";
}

.right-collapsed .workspace {
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  grid-template-areas: "left main";
}

.left-collapsed.right-collapsed .workspace {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "main";
}

.left-collapsed .left-panel,
.right-collapsed .right-panel {
  display: none;
}

@media (max-width: 920px) {
  .topbar {
    height: auto;
    min-height: 72px;
    flex-wrap: wrap;
    padding: 12px;
  }

  .top-actions {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
    flex-wrap: wrap;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "main"
      "right"
      "left";
  }

  .main-panel { order: 1; }
  .right-panel { order: 2; }
  .left-panel { order: 3; }

  .left-panel,
  .right-panel {
    max-height: none;
    border: 0;
    border-bottom: 1px solid var(--line);
  }

  .left-collapsed .workspace,
  .right-collapsed .workspace,
  .left-collapsed.right-collapsed .workspace {
    grid-template-columns: 1fr;
  }

  .left-collapsed .workspace {
    grid-template-areas:
      "main"
      "right";
  }

  .right-collapsed .workspace {
    grid-template-areas:
      "main"
      "left";
  }

  .left-collapsed.right-collapsed .workspace {
    grid-template-areas: "main";
  }

  .left-collapsed .left-panel,
  .right-collapsed .right-panel {
    display: none;
  }

  .main-panel {
    padding: 12px;
  }

  #slideTitle { font-size: 20px; }

  .slide-image {
    max-height: none;
  }
}

@media (max-width: 520px) {
  .brand-mark { width: 36px; height: 36px; }
  h1 { font-size: 18px; }
  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
    flex-basis: calc(100vw - 24px);
    gap: 6px;
  }
  .icon-btn {
    width: 100%;
    min-width: 0;
  }
  .action-btn {
    width: 100%;
    min-width: 0;
    padding: 8px;
    text-align: center;
    white-space: normal;
  }
  .slide-toolbar {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    gap: 8px;
  }
  .nav-btn { height: 38px; font-size: 24px; }
}

.inflow-frame {
  overflow: hidden;
}

.inflow-frame summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  color: var(--navy);
  font-weight: 800;
}

.inflow-frame summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.focus-content {
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}

.focus-content p {
  margin: 10px 0 0;
  line-height: 1.7;
}

.audio-box {
  margin-top: 12px;
}

.audio-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.audio-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.audio-card h3 {
  color: var(--navy);
  font-size: 16px;
}

.audio-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.audio-duration {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
  padding: 4px 9px;
}

.page-audio {
  width: 100%;
  display: block;
}

.audio-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin-top: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--navy);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.audio-download:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.video-panel {
  display: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 12px 30px rgba(5, 42, 99, 0.08);
}

.video-frame-wrap {
  aspect-ratio: 16 / 9;
  width: 100%;
  background: #0b1220;
  border-radius: 8px;
  overflow: hidden;
}

.video-frame {
  width: 100%;
  height: 100%;
  border: 0;
}

.video-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.video-actions .download-link {
  flex: 1 1 180px;
}

.video-guide-panel {
  padding: 16px;
}

.video-guide-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
  margin-bottom: 12px;
}

.video-guide-head h3 {
  color: var(--navy);
  font-size: 18px;
}

.video-guide-head p {
  margin: 8px 0 0;
  color: #344054;
  line-height: 1.65;
}

.video-guide-principles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.video-guide-principles span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--navy);
  background: #f8fbff;
  font-size: 13px;
  font-weight: 800;
}

.video-guide-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.video-guide-controls button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 900;
  min-height: 38px;
  padding: 8px 10px;
}

.video-guide-controls button.active {
  border-color: var(--navy);
  background: #102a43;
  color: #fff;
}

.video-guide-sort-note {
  color: #667085;
  font-size: 12px;
  line-height: 1.55;
  margin: 0 0 12px;
}

.video-guide-table {
  display: grid;
  gap: 8px;
  max-height: 430px;
  overflow: auto;
  padding-right: 2px;
}

.video-guide-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.1fr) minmax(150px, 1fr) minmax(150px, .9fr);
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
}

.video-guide-row.is-muted {
  background: #f8fafc;
}

.video-guide-row.is-weak {
  border-color: #fed7aa;
  background: #fffaf4;
}

.video-guide-page {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--navy);
  text-decoration: none;
}

.video-guide-page span {
  color: var(--orange);
  font-weight: 900;
}

.video-guide-page strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-guide-times {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.video-guide-times a,
.video-no-segment {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--navy);
  background: #fff;
  text-decoration: none;
  font-size: 12px;
  font-weight: 800;
}

.video-no-segment {
  color: var(--muted);
  background: transparent;
}

.video-guide-status {
  color: #344054;
  font-size: 13px;
  line-height: 1.45;
}

.video-guide-order {
  color: var(--orange);
  display: inline-block;
  font-weight: 900;
  margin-right: 8px;
}

.video-guide-empty {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 920px) {
  .video-guide-head,
  .video-guide-row {
    grid-template-columns: 1fr;
  }

  .video-guide-controls {
    grid-template-columns: 1fr;
  }

  .video-guide-head .download-link {
    width: 100%;
    text-align: center;
  }
}

