:root {
  --bg: #eef4fb;
  --paper: #ffffff;
  --panel: #f5f8fc;
  --panel-strong: #e6effa;
  --ink: #201714;
  --muted: #5c6878;
  --brand-blue: #1f4a98;
  --brand-blue-soft: #c8d9f2;
  --gold: #153873;
  --line: rgba(31, 74, 152, .18);
  --shadow: 0 24px 70px rgba(21, 56, 115, .16);
  --radius: 8px;
}

* { box-sizing: border-box; }

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

body { overflow: hidden; }

button,
select,
a { font: inherit; }

button:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(31, 74, 152, .34);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 50;
  transform: translateY(-140%);
  background: var(--ink);
  color: #fff;
  padding: 8px 12px;
  border-radius: var(--radius);
}

.skip-link:focus { transform: translateY(0); }

.app {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr) 360px;
  height: 100vh;
  transition: grid-template-columns .18s ease;
  background:
    linear-gradient(120deg, rgba(31, 74, 152, .09), transparent 34%),
    linear-gradient(180deg, #f8fbff 0%, #eaf2fb 100%);
}

.app.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr) 360px; }

.app.info-collapsed { grid-template-columns: 272px minmax(0, 1fr) 0; }

.app.sidebar-collapsed.info-collapsed { grid-template-columns: 0 minmax(0, 1fr) 0; }

.app:fullscreen,
.app.is-presentation {
  width: 100vw;
  height: 100vh;
}

.app.is-presentation {
  position: fixed;
  inset: 0;
  z-index: 35;
}

body.presentation-lock { overflow: hidden; }

.sidebar,
.info {
  min-height: 0;
  min-width: 0;
  background: rgba(255, 253, 248, .82);
  backdrop-filter: blur(14px);
}

.app.sidebar-collapsed .sidebar,
.app.info-collapsed .info {
  border: 0;
  overflow: hidden;
  padding: 0;
  pointer-events: none;
  visibility: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  display: block;
  width: 138px;
  height: auto;
  margin: 0 0 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0 0 10px;
  font-size: 20px;
  line-height: 1.35;
  letter-spacing: 0;
}

.brand p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.slide-list {
  overflow: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slide-tab {
  width: 100%;
  min-height: 46px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  padding: 9px 10px;
  cursor: pointer;
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: start;
}

.slide-tab:hover {
  background: rgba(31, 74, 152, .08);
  color: var(--ink);
}

.slide-tab.active {
  background: #e6effa;
  border-color: rgba(31, 74, 152, .32);
  color: var(--ink);
}

.slide-tab .num {
  color: var(--brand-blue);
  font-weight: 700;
  font-size: 12px;
}

.slide-tab .name {
  font-size: 13px;
  line-height: 1.35;
}

.stage {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 251, 255, .88);
}

.topbar-title {
  flex: 1 1 150px;
  min-width: 0;
}

.topbar-title strong {
  display: block;
  font-size: 19px;
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-title span {
  display: block;
  color: var(--brand-blue);
  font-size: 13px;
  margin-top: 4px;
}

.nav {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-btn,
.text-btn {
  border: 1px solid rgba(31, 74, 152, .28);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .76);
  color: var(--ink);
  min-height: 40px;
  padding: 0 10px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(21, 56, 115, .08);
}

.icon-btn {
  width: 42px;
  font-size: 24px;
  line-height: 1;
}

.text-btn.primary {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: #fff;
  font-weight: 700;
}

.panel-toggle {
  min-width: 78px;
  color: var(--brand-blue);
  font-weight: 700;
}

.icon-btn:disabled,
.text-btn:disabled {
  cursor: default;
  opacity: .42;
  box-shadow: none;
}

.text-btn:not(:disabled):hover,
.icon-btn:not(:disabled):hover {
  background: #e6effa;
}

.text-btn.primary:not(:disabled):hover { background: #153873; }

.slide-frame {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 26px;
  position: relative;
}

.slide-frame::before {
  content: "";
  width: min(100%, calc((100vh - 150px) * 16 / 9));
  max-height: calc(100vh - 150px);
  aspect-ratio: 16 / 9;
  border: 1px dashed rgba(31, 74, 152, .2);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(31, 74, 152, .08), rgba(255, 255, 255, .56)),
    repeating-linear-gradient(0deg, transparent 0, transparent 31px, rgba(31, 74, 152, .035) 32px);
  box-shadow: var(--shadow);
  display: none;
}

.slide-frame.is-missing::before { display: block; }

.slide-frame.is-missing > img { display: none; }

.slide-frame > img,
.video-host {
  width: min(100%, calc((100vh - 150px) * 16 / 9));
  max-height: calc(100vh - 150px);
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #eef4fb;
}

.slide-frame > img {
  object-fit: contain;
}

.video-host {
  overflow: hidden;
  background: #000;
}

.video-host[hidden] { display: none; }

.video-host iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.slide-frame.has-video .slide-overlay { display: none; }

.slide-overlay {
  position: absolute;
  right: clamp(40px, 4.2vw, 72px);
  bottom: clamp(38px, 5vw, 78px);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .9);
  border: 1px solid rgba(31, 74, 152, .18);
  box-shadow: 0 10px 26px rgba(21, 56, 115, .12);
}

.slide-overlay img {
  width: 96px;
  height: auto;
  aspect-ratio: auto;
  box-shadow: none;
  border-radius: 0;
  background: transparent;
}

.slide-overlay span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}

.info {
  border-left: 1px solid var(--line);
  overflow: auto;
  padding: 22px;
}

.info h2 {
  margin: 0 0 8px;
  font-size: 23px;
  line-height: 1.35;
  letter-spacing: 0;
}

.core {
  margin: 0 0 16px;
  color: var(--brand-blue);
  font-weight: 700;
  line-height: 1.55;
}

.block {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.block[hidden] { display: none; }

.block h3 {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 14px;
  line-height: 1.4;
}

.block ol {
  margin: 0;
  padding-left: 22px;
  color: var(--muted);
  line-height: 1.7;
}

.block li {
  margin-bottom: 12px;
  padding-left: 2px;
}

.block li:last-child { margin-bottom: 0; }

.block li::marker {
  color: var(--brand-blue);
  font-weight: 700;
}

.block p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

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

.prompt-head h3 {
  margin: 0;
}

.copy-prompt {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .78);
  color: var(--brand-blue);
  font-size: 12px;
  font-weight: 700;
  padding: 0 10px;
  cursor: pointer;
}

.copy-prompt:hover {
  background: #e6effa;
}

.prompt-usage {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.55;
}

.prompt-box {
  margin: 0;
  padding: 12px;
  border: 1px solid rgba(31, 74, 152, .22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .72);
  color: #352646;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 280px;
  overflow: auto;
}

.share-text {
  margin-bottom: 12px;
  color: var(--ink);
  font-weight: 600;
}

.links {
  display: grid;
  gap: 8px;
}

.link-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 8px;
  align-items: center;
}

.link-row a {
  min-height: 40px;
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 10px;
  background: rgba(255, 255, 255, .7);
  overflow-wrap: anywhere;
}

.link-row a:hover { background: #e6effa; }

.copy-link {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .78);
  color: var(--brand-blue);
  cursor: pointer;
}

.cover-card {
  display: none;
  margin: 16px 0 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #eaf2fb;
}

.cover-card.active {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 14px;
  align-items: center;
}

.qr-button {
  width: 100px;
  height: 100px;
  border: 1px solid rgba(31, 74, 152, .24);
  border-radius: var(--radius);
  background: #fff;
  padding: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.qr-button img,
#qrcodeLarge img {
  display: block;
  max-width: 100%;
  height: auto;
}

.qr-text {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.qr-text strong {
  color: var(--ink);
  font-size: 14px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(34, 26, 47, .68);
}

.modal[hidden] { display: none; }

.modal-box {
  position: relative;
  width: min(92vw, 430px);
  text-align: center;
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 30px 28px 26px;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  right: 12px;
  top: 10px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #e6effa;
  color: var(--ink);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

#qrcodeLarge {
  display: grid;
  place-items: center;
  width: 260px;
  height: 260px;
  margin: 0 auto 16px;
}

.modal-box p {
  margin: 10px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  z-index: 45;
  transform: translate(-50%, 120%);
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}

.toast.active {
  opacity: 1;
  transform: translate(-50%, 0);
}

.mobile-menu { display: none; }

.mobile-next { display: none; }

@media (max-width: 1120px) {
  body { overflow: auto; }

  .app {
    display: block;
    min-height: 100vh;
    height: auto;
  }

  .sidebar { display: none; }

  .sidebar-toggle { display: none; }

  .app.info-collapsed .info { display: none; }

  .mobile-menu {
    display: block;
    width: 100%;
    min-height: 42px;
    margin-top: 9px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .88);
    color: var(--ink);
    padding: 9px 10px;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 12;
    min-height: 0;
    flex-wrap: wrap;
    background: rgba(248, 251, 255, .96);
    backdrop-filter: blur(14px);
  }

  .topbar-title { width: 100%; }

  .topbar-title strong { white-space: normal; }

  .nav {
    width: 100%;
    justify-content: space-between;
  }

  .slide-frame {
    min-height: auto;
    padding: 16px;
  }

  .slide-overlay {
    right: 28px;
    bottom: 28px;
    gap: 8px;
    padding: 6px 8px;
  }

  .slide-overlay img { width: 72px; }

  .slide-frame > img,
  .video-host,
  .slide-frame::before {
    width: 100%;
    max-height: none;
  }

  .info {
    border-left: 0;
    border-top: 1px solid var(--line);
    background: var(--paper);
  }

  .app.is-presentation {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: auto;
  }

  .app.is-presentation .stage {
    min-height: 0;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 12px;
    position: sticky;
  }

  .topbar-title strong { font-size: 17px; }

  .nav {
    display: flex;
    width: calc(100vw - 62px);
    max-width: calc(100vw - 62px);
    gap: 3px;
    justify-content: flex-start;
    flex-wrap: nowrap;
    min-width: 0;
  }

  #nextBtn {
    display: none !important;
  }

  .mobile-next {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 12px;
    top: 124px;
    z-index: 80;
  }

  #copyPageBtn { display: none; }

  .info-toggle { display: none; }

  .icon-btn {
    flex: 0 0 28px;
    width: 28px;
    min-height: 36px;
    padding: 0;
    font-size: 18px;
  }

  .text-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 36px;
    padding: 0 2px;
    font-size: 9px;
    white-space: nowrap;
  }

  .info { padding: 18px 16px 28px; }

  .info h2 { font-size: 21px; }

  .cover-card.active { grid-template-columns: 1fr; }

  .slide-overlay {
    left: 34px;
    right: auto;
    bottom: 24px;
  }

  .slide-overlay img { width: 62px; }

  .slide-overlay span { font-size: 11px; }

  .qr-button {
    width: 116px;
    height: 116px;
  }
}
