:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --surface-strong: #eff4f1;
  --ink: #171a18;
  --muted: #65706a;
  --line: #d8e0db;
  --accent: #d83b2d;
  --accent-dark: #9f241a;
  --teal: #087a75;
  --focus: #ffcc66;
  --shadow: 0 18px 60px rgba(23, 26, 24, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(8, 122, 117, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(216, 59, 45, 0.10), transparent 28%),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  width: min(1180px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0;
  align-items: stretch;
}

.reader-panel,
.library-panel {
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(216, 224, 219, 0.95);
  box-shadow: var(--shadow);
}

.reader-panel {
  display: flex;
  min-height: calc(100vh - 48px);
  flex-direction: column;
}

.library-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.55rem, 2.6vw, 2.25rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.top-bar p,
.drop-zone p,
.status-card p,
.timeline-meta {
  color: var(--muted);
}

.top-bar p {
  margin-top: 6px;
}

.file-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 112px;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
  user-select: none;
}

.file-button input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-button span {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(255, 255, 255, 0.75);
}

.rsvp-stage {
  position: relative;
  display: grid;
  flex: 1;
  min-height: 360px;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(23, 26, 24, 0.055) 1px, transparent 1px) 50% 0 / 40px 40px,
    linear-gradient(180deg, var(--surface), var(--surface-strong));
}

.guide-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-1px);
  background: linear-gradient(180deg, transparent, rgba(216, 59, 45, 0.45) 18%, rgba(216, 59, 45, 0.45) 82%, transparent);
}

.rsvp-stage.is-empty .guide-line {
  display: none;
}

.guide-line::before,
.guide-line::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 18px;
  height: 18px;
  transform: translateX(-50%) rotate(45deg);
  background: var(--accent);
}

.guide-line::before {
  top: 32px;
}

.guide-line::after {
  bottom: 32px;
}

.word-display {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 10ch) 1ch minmax(0, 12ch);
  width: min(92vw, 900px);
  align-items: baseline;
  justify-content: center;
  padding: 30px 16px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(2.5rem, 9vw, 6.5rem);
  line-height: 1;
  letter-spacing: 0;
}

.word-display .before {
  min-width: 0;
  text-align: right;
}

.word-display .focal {
  color: var(--accent);
  text-align: center;
}

.word-display .after {
  min-width: 0;
  text-align: left;
}

.word-display .placeholder {
  grid-column: 1 / -1;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.86);
  padding: 8px 12px;
  text-align: center;
  font-family: inherit;
  font-size: clamp(1.4rem, 5vw, 3rem);
}

.timeline {
  padding: 18px 22px 10px;
  border-top: 1px solid var(--line);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
  font-size: 0.92rem;
}

.controls {
  display: grid;
  grid-template-columns: 96px minmax(140px, 240px) 96px;
  gap: 12px;
  justify-content: center;
  padding: 12px 22px;
}

.icon-button,
.play-button,
#loadTextButton {
  min-height: 44px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.play-button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.icon-button:disabled,
.play-button:disabled,
#loadTextButton:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  gap: 16px;
  padding: 6px 22px 22px;
}

.settings label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.settings output {
  color: var(--ink);
  font-weight: 700;
}

select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.drop-zone {
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px dashed #9fb1aa;
  background: #fbfcfb;
}

.drop-zone.dragging {
  border-color: var(--accent);
  background: #fff7f5;
}

.book-mark {
  width: 54px;
  height: 76px;
  background:
    linear-gradient(90deg, transparent 46%, rgba(255, 255, 255, 0.45) 46% 54%, transparent 54%),
    linear-gradient(135deg, var(--teal), #3b8f64);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
}

details {
  border: 1px solid var(--line);
  background: #fff;
  padding: 14px;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

textarea {
  width: 100%;
  margin: 12px 0;
  resize: vertical;
  border: 1px solid var(--line);
  padding: 10px;
}

.status-card {
  margin-top: auto;
  padding: 16px;
  background: var(--surface-strong);
  border-left: 4px solid var(--teal);
}

.status-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: 100%;
    min-height: 100vh;
    padding: 0;
  }

  .reader-panel {
    min-height: 72vh;
    border-left: 0;
    border-right: 0;
  }

  .library-panel {
    border-left: 0;
    border-right: 0;
    box-shadow: none;
  }

  .top-bar,
  .settings {
    grid-template-columns: 1fr;
  }

  .top-bar {
    align-items: flex-start;
  }

  .file-button {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .rsvp-stage {
    min-height: 300px;
  }

  .word-display {
    grid-template-columns: minmax(0, 8ch) 1ch minmax(0, 8ch);
    font-size: clamp(2.1rem, 14vw, 4.8rem);
  }

  .controls {
    grid-template-columns: 74px minmax(110px, 1fr) 74px;
    padding-inline: 14px;
  }

  .timeline,
  .top-bar,
  .settings {
    padding-inline: 14px;
  }
}
