:root {
  color-scheme: dark;
  --ink: #f7f5ee;
  --muted: #aeb6ba;
  --panel: #171c1f;
  --panel-soft: #20272b;
  --line: #344046;
  --accent: #f2c14e;
  --accent-ink: #1b1608;
  --stage: #101315;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0d1113;
  color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #69777e;
  background: #293238;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

button.wide {
  width: 100%;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  min-height: 100vh;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  overflow: auto;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid #283137;
}

.panel-header h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.panel-header p,
.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.tool-section {
  display: grid;
  gap: 10px;
}

.tool-section label,
.list-title {
  color: #dce1df;
  font-size: 14px;
  font-weight: 700;
}

textarea {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
  background: #101416;
  color: var(--ink);
  line-height: 1.6;
}

input[type="number"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #101416;
  color: var(--ink);
}

input[type="range"] {
  width: 100%;
}

.button-row,
.nav-row,
.toggle-row,
.segmented {
  display: flex;
  gap: 8px;
}

.button-row > button,
.segmented > button {
  flex: 1;
}

.nav-row {
  align-items: center;
}

.nav-row button {
  width: 56px;
  font-size: 22px;
}

.nav-row output {
  flex: 1;
  text-align: center;
  color: var(--muted);
}

.toggle-row {
  flex-wrap: wrap;
  color: var(--muted);
}

.toggle-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

.segmented {
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101416;
}

.segmented button {
  min-height: 34px;
  border: 0;
  background: transparent;
}

.segmented button.active {
  background: #39454b;
}

.compact-grid {
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
}

.slide-list-wrap {
  min-height: 120px;
}

.slide-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.slide-list button {
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  text-align: left;
  color: #dce1df;
}

.slide-list button.active {
  border-color: var(--accent);
}

.workspace {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 16px;
  min-width: 0;
  padding: 26px;
}

.stage-frame {
  width: min(calc(100vw - 440px), calc((100vh - 108px) * 16 / 9));
  min-width: 360px;
  aspect-ratio: 16 / 9;
  border: 1px solid #2b3338;
  background: #070808;
  box-shadow: 0 18px 80px rgba(0, 0, 0, 0.35);
}

.slide-stage {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    var(--stage);
  background-size: 120px 120px;
}

.safe-frame {
  position: absolute;
  inset: 6.5%;
  border: 2px dashed rgba(242, 193, 78, 0.42);
  pointer-events: none;
}

.slide-stage.hide-safe .safe-frame {
  display: none;
}

.subtitle {
  position: absolute;
  left: 50%;
  width: 86%;
  transform: translateX(-50%);
  color: white;
  text-align: center;
  font-size: 72px;
  line-height: 1.22;
  font-weight: 850;
  letter-spacing: 0;
  outline: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.subtitle.with-shadow {
  text-shadow:
    0 4px 0 #000,
    4px 0 0 #000,
    -4px 0 0 #000,
    0 -4px 0 #000,
    0 9px 28px rgba(0, 0, 0, 0.72);
}

.position-bottom .subtitle {
  bottom: 11%;
}

.position-middle .subtitle {
  top: 50%;
  transform: translate(-50%, -50%);
}

.position-top .subtitle {
  top: 12%;
}

.presenting .app-shell {
  display: block;
}

.presenting .control-panel,
.presenting .hint {
  display: none;
}

.presenting .workspace {
  width: 100vw;
  height: 100vh;
  padding: 0;
  background: #000;
}

.presenting .stage-frame {
  width: 100vw;
  height: 100vh;
  min-width: 0;
  border: 0;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .control-panel {
    height: auto;
    border-right: 0;
    border-bottom: 1px solid #283137;
  }

  .stage-frame {
    width: min(100%, calc((100vh - 120px) * 16 / 9));
    min-width: 0;
  }
}
