:root {
  color-scheme: light;
  --paper: #f4f5f2;
  --surface: #ffffff;
  --ink: #17201c;
  --muted: #667069;
  --line: #d9ded9;
  --forest: #176447;
  --forest-dark: #0e4933;
  --water: #247c91;
  --gold: #b9792b;
  --coral: #c55c4a;
  --focus: #0b6c80;
  --shadow: 0 18px 50px rgba(28, 45, 36, 0.09);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
}

button,
input {
  font: inherit;
}

button,
a,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 30%, transparent);
  outline-offset: 3px;
}

.app-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 26px 34px 22px;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand-block {
  min-width: 0;
}

.eyebrow,
.session-kicker {
  margin: 0;
  color: var(--forest);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: "Songti TC", "Noto Serif TC", Georgia, serif;
  font-size: 30px;
  font-weight: 600;
  line-height: 1.2;
}

.seat-picker {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(2, 132px);
  border: 1px solid var(--line);
  background: var(--surface);
}

.seat-button {
  position: relative;
  min-width: 0;
  height: 54px;
  padding: 7px 35px 7px 13px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.seat-button:last-child {
  border-right: 0;
}

.seat-button:hover:not(:disabled) {
  background: #f7faf8;
}

.seat-button[aria-pressed="true"] {
  color: var(--ink);
  background: #eaf3ee;
}

.seat-button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.seat-index {
  color: var(--forest);
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
}

.seat-name {
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.seat-check {
  position: absolute;
  right: 12px;
  width: 16px;
  height: 16px;
  color: var(--forest);
  opacity: 0;
}

.seat-button.is-complete .seat-check {
  opacity: 1;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.scene-section {
  padding: 24px 0 20px;
}

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

.section-heading h2 {
  margin-bottom: 0;
  font-size: 15px;
  line-height: 1.4;
}

.section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.scene-picker {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.scene-option {
  position: relative;
  min-width: 0;
  min-height: 78px;
  padding: 12px 42px 12px 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  text-align: left;
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(20, 35, 27, 0.02);
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.scene-option::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--scene-accent);
}

.scene-option:hover {
  border-color: color-mix(in srgb, var(--scene-accent) 52%, var(--line));
  box-shadow: 0 8px 22px rgba(31, 52, 41, 0.07);
  transform: translateY(-1px);
}

.scene-option[aria-checked="true"] {
  border-color: var(--scene-accent);
  box-shadow: inset 0 0 0 1px var(--scene-accent), 0 9px 24px rgba(31, 52, 41, 0.08);
}

.scene-birds {
  --scene-accent: var(--forest);
}

.scene-quiet {
  --scene-accent: var(--water);
}

.scene-long {
  --scene-accent: var(--gold);
}

.scene-icon {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--scene-accent);
  background: color-mix(in srgb, var(--scene-accent) 10%, white);
}

.scene-icon svg {
  width: 20px;
  height: 20px;
}

.scene-copy {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.scene-copy strong,
.scene-copy small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.scene-copy strong {
  font-size: 15px;
  line-height: 1.25;
}

.scene-copy small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.scene-selected {
  position: absolute;
  right: 14px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: white;
  background: white;
}

.duration-section {
  min-height: 68px;
  padding: 11px 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
}

.duration-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.duration-label > svg {
  width: 18px;
  height: 18px;
  color: var(--gold);
}

.duration-label h2 {
  margin: 0;
  font-size: 14px;
  line-height: 1.3;
}

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

.duration-controls,
.duration-presets,
.custom-duration {
  display: flex;
  align-items: center;
}

.duration-controls {
  gap: 10px;
}

.duration-presets {
  border: 1px solid var(--line);
  background: var(--surface);
}

.duration-presets button {
  width: 48px;
  height: 36px;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.duration-presets button:last-child {
  border-right: 0;
}

.duration-presets button:hover:not(:disabled) {
  background: #f3f7f4;
}

.duration-presets button[aria-pressed="true"] {
  color: white;
  background: var(--forest);
}

.custom-duration {
  height: 38px;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.custom-duration input {
  width: 62px;
  height: 36px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  text-align: center;
  background: var(--surface);
}

.duration-controls button:disabled,
.custom-duration input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.scene-selected svg {
  width: 13px;
  height: 13px;
  opacity: 0;
}

.scene-option[aria-checked="true"] .scene-selected {
  border-color: var(--scene-accent);
  background: var(--scene-accent);
}

.scene-option[aria-checked="true"] .scene-selected svg {
  opacity: 1;
}

.player-stage {
  position: relative;
  min-height: 390px;
  flex: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

#sound-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.82;
  pointer-events: none;
}

.player-content {
  position: relative;
  z-index: 1;
  width: min(520px, calc(100% - 32px));
  padding: 36px 16px 32px;
  display: grid;
  justify-items: center;
  text-align: center;
}

.session-kicker {
  margin-bottom: 8px;
}

.timer {
  min-width: 5.5ch;
  color: var(--ink);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 76px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  line-height: 1.06;
}

.now-playing {
  min-height: 24px;
  margin: 11px 0 24px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 650;
}

.transport {
  height: 84px;
  display: grid;
  grid-template-columns: 44px 84px 44px;
  align-items: center;
  gap: 22px;
}

.bowl-cue-button {
  min-width: 92px;
  height: 38px;
  margin-top: 17px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #d8c8ad;
  border-radius: 19px;
  color: #76511f;
  background: #fbf7ef;
  cursor: pointer;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.bowl-cue-button:hover {
  border-color: var(--gold);
  color: #5f3d14;
  background: #f7efe1;
}

.bowl-cue-button:active {
  transform: translateY(1px);
}

.bowl-cue-button svg {
  width: 17px;
  height: 17px;
}

.bowl-cue-button span {
  font-size: 13px;
  font-weight: 700;
}

.bowl-cue-button.is-ringing svg {
  animation: bowl-ring 720ms ease-out;
}

@keyframes bowl-ring {
  0%, 100% { transform: rotate(0); }
  22% { transform: rotate(12deg); }
  48% { transform: rotate(-10deg); }
  72% { transform: rotate(5deg); }
}

.play-button,
.icon-button {
  display: grid;
  place-items: center;
  border: 0;
  cursor: pointer;
}

.play-button {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  color: white;
  background: var(--forest-dark);
  box-shadow: 0 14px 32px rgba(14, 73, 51, 0.24);
  transition: background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.play-button:hover:not(:disabled) {
  background: var(--forest);
  box-shadow: 0 16px 36px rgba(14, 73, 51, 0.29);
  transform: translateY(-1px);
}

.play-button:active:not(:disabled) {
  transform: translateY(1px);
}

.play-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.play-button svg {
  width: 34px;
  height: 34px;
  fill: currentColor;
}

.play-button.is-playing svg {
  fill: none;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--muted);
  background: #eef1ee;
  transition: color 160ms ease, background-color 160ms ease;
}

.icon-button:hover:not(:disabled) {
  color: var(--ink);
  background: #e1e7e3;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
}

.icon-button svg {
  width: 19px;
  height: 19px;
}

.status-line {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-line.is-error {
  color: #9e3728;
}

.volume-section {
  padding: 18px 2px 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.volume-section > p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.volume-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 20px auto minmax(130px, 210px) 42px;
  align-items: center;
  gap: 10px;
}

.volume-row > svg {
  width: 18px;
  height: 18px;
  color: var(--water);
}

.volume-row label,
.volume-row output {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.volume-row output {
  text-align: right;
}

input[type="range"] {
  width: 100%;
  height: 22px;
  margin: 0;
  accent-color: var(--water);
  cursor: pointer;
}

footer {
  padding-top: 20px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 11px;
}

footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

footer a:hover {
  color: var(--ink);
}

.audio-sources {
  display: flex;
  gap: 14px;
}

.completion-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  width: min(330px, calc(100vw - 32px));
  min-height: 74px;
  padding: 14px 13px;
  display: grid;
  grid-template-columns: 34px 1fr 36px;
  align-items: center;
  gap: 10px;
  border: 1px solid #b9d5c5;
  border-radius: 6px;
  color: var(--ink);
  background: #f4fbf7;
  box-shadow: var(--shadow);
}

.completion-toast[hidden] {
  display: none;
}

.completion-toast > svg {
  width: 28px;
  height: 28px;
  color: var(--forest);
}

.completion-toast div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.completion-toast strong {
  font-size: 14px;
}

.completion-toast span {
  color: var(--muted);
  font-size: 12px;
}

.completion-toast button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.completion-toast button:hover {
  color: var(--ink);
  background: #e8f3ec;
}

.completion-toast button svg {
  width: 18px;
  height: 18px;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 20px 20px 18px;
  }

  .topbar {
    align-items: stretch;
    gap: 18px;
  }

  .seat-picker {
    grid-template-columns: repeat(2, minmax(108px, 1fr));
  }

  .scene-picker {
    grid-template-columns: 1fr;
  }

  .scene-option {
    min-height: 66px;
  }

  .duration-section {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
    padding: 13px 2px;
  }

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

  .player-stage {
    min-height: 365px;
  }

  .timer {
    font-size: 66px;
  }
}

@media (max-width: 540px) {
  .app-shell {
    padding: 18px 16px 16px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .seat-picker {
    width: 100%;
  }

  .seat-button {
    width: auto;
  }

  .section-heading span {
    display: none;
  }

  .scene-section {
    padding: 20px 0 16px;
  }

  .player-stage {
    min-height: 340px;
  }

  .duration-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .duration-presets {
    width: 100%;
  }

  .duration-presets button {
    min-width: 0;
    flex: 1;
  }

  .custom-duration {
    justify-content: flex-end;
  }

  .player-content {
    padding: 28px 10px 26px;
  }

  .timer {
    font-size: 56px;
  }

  .transport {
    gap: 18px;
  }

  .volume-section {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .volume-row {
    grid-template-columns: 20px auto minmax(0, 1fr) 40px;
  }

  footer {
    padding-top: 16px;
  }

  .completion-toast {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 390px) {
  h1 {
    font-size: 27px;
  }

  .seat-button {
    height: 52px;
    padding-left: 10px;
    padding-right: 29px;
    gap: 6px;
  }

  .seat-check {
    right: 8px;
  }

  .scene-option {
    padding-right: 39px;
  }

  .scene-copy strong {
    font-size: 14px;
  }

  .timer {
    font-size: 52px;
  }

  .transport {
    grid-template-columns: 42px 78px 42px;
    gap: 16px;
  }

  .play-button {
    width: 78px;
    height: 78px;
  }

  .icon-button {
    width: 42px;
    height: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .bowl-cue-button.is-ringing svg {
    animation: none;
  }
}
