:root {
  color-scheme: light;
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-soft: #eef5f4;
  --text: #17201b;
  --muted: #59645f;
  --line: #d9dfdc;
  --red: #b54030;
  --blue: #2265a8;
  --green: #2f6b4f;
  --gold: #b9852c;
  --shadow: 0 18px 45px rgba(23, 32, 27, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

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

a {
  color: inherit;
}

.site-header {
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 18px;
  justify-content: space-between;
  padding: 12px 24px;
  position: relative;
  z-index: 1;
}

.brand-link {
  align-items: center;
  display: flex;
  gap: 14px;
  min-width: 220px;
  text-decoration: none;
}

.brand-link strong {
  display: block;
  font-size: 1.02rem;
  line-height: 1.15;
}

.brand-kicker,
.kicker,
.form-type,
.destination,
.filename,
.status-line,
.side-nav-title {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0;
}

.poster-mark {
  aspect-ratio: 1290 / 1892;
  border: 1px solid rgba(23, 32, 27, 0.18);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(23, 32, 27, 0.16);
  flex: 0 0 auto;
  height: 92px;
  object-fit: cover;
  object-position: 50% 18%;
  width: 63px;
}

.site-nav {
  align-items: center;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  justify-content: flex-end;
}

.mobile-page-menu {
  display: none;
}

.site-nav a,
.builder-menu summary,
.side-nav a,
.button {
  border-radius: 6px;
  font-weight: 800;
  text-decoration: none;
}

.site-nav a,
.builder-menu summary {
  color: var(--muted);
  cursor: pointer;
  padding: 9px 11px;
}

.site-nav a:hover,
.site-nav a.active,
.builder-menu summary:hover,
.builder-menu summary.active {
  background: var(--surface-soft);
  color: var(--text);
}

.site-nav a.active,
.builder-menu summary.active {
  box-shadow: inset 0 -3px 0 var(--red);
}

.builder-menu {
  position: relative;
}

.builder-menu summary {
  list-style: none;
  white-space: nowrap;
}

.builder-menu summary::-webkit-details-marker {
  display: none;
}

.builder-menu summary::after {
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  content: "";
  display: inline-block;
  height: 7px;
  margin-left: 10px;
  transform: translateY(-2px) rotate(45deg);
  width: 7px;
}

.builder-menu[open] summary::after {
  transform: translateY(2px) rotate(225deg);
}

.builder-menu-panel {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 4px;
  min-width: 230px;
  padding: 8px;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  z-index: 20;
}

.builder-menu-panel a {
  display: block;
}

.home-shell,
.app-shell {
  margin: 0 auto;
  max-width: 1440px;
  padding: 24px;
}

.home-hero {
  align-items: center;
  display: grid;
  gap: 28px;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  min-height: calc(100vh - 150px);
}

.hero-poster {
  aspect-ratio: 1290 / 1892;
  border: 1px solid rgba(23, 32, 27, 0.18);
  border-radius: 8px;
  box-shadow: 0 24px 62px rgba(23, 32, 27, 0.24);
  display: block;
  height: auto;
  max-height: 680px;
  object-fit: cover;
  width: 100%;
}

.feature-board {
  background: #101310;
  border: 1px solid rgba(23, 32, 27, 0.18);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: block;
  height: auto;
  margin: 22px 0 0;
  max-height: 620px;
  object-fit: contain;
  width: 100%;
}

.spirit-guide {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 22px 0 24px;
}

.spirit-guide img {
  background: #101310;
  border: 1px solid rgba(23, 32, 27, 0.18);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: block;
  height: auto;
  object-fit: contain;
  width: 100%;
}

h1,
h2 {
  letter-spacing: 0;
  line-height: 1.08;
  margin: 0;
}

h1 {
  font-size: clamp(2.35rem, 6vw, 5.6rem);
  max-width: 920px;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2.25rem);
}

.lede {
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.28rem);
  margin: 18px 0 0;
  max-width: 760px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.button {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
}

.button:hover {
  border-color: var(--blue);
}

.button.primary {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
}

.button.quiet {
  color: var(--muted);
}

.builder-directory,
.boundary-strip,
.footer-nav {
  margin-top: 32px;
}

.section-heading {
  margin-bottom: 14px;
}

.builder-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.builder-card,
.boundary-strip,
.footer-nav-card,
.form-panel,
.preview-panel,
.side-nav {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.builder-card {
  display: grid;
  gap: 8px;
  min-height: 176px;
  padding: 18px;
  text-decoration: none;
}

.builder-card:hover {
  border-color: var(--blue);
}

.builder-card span {
  color: var(--red);
  font-weight: 900;
}

.builder-card strong {
  font-size: 1.22rem;
}

.builder-card p,
.boundary-strip p,
.hint {
  color: var(--muted);
  margin: 0;
}

.boundary-strip {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 18px;
}

.footer-nav {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.footer-nav-card {
  display: grid;
  gap: 5px;
  min-height: 86px;
  padding: 16px;
  text-decoration: none;
}

.footer-nav-card:hover {
  border-color: var(--blue);
}

.footer-nav-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.footer-nav-card strong {
  font-size: 1.18rem;
}

.footer-nav-card.next {
  text-align: right;
}

.page-intro {
  margin: 8px 0 22px;
}

.page-intro h1 {
  font-size: clamp(2rem, 5vw, 4.4rem);
}

.builder-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: 250px minmax(0, 1fr) minmax(360px, 0.9fr);
}

.recurring-builder-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: 250px minmax(0, 1fr) minmax(360px, 0.9fr);
}

.runsheet-layout {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: 290px minmax(0, 0.92fr) minmax(420px, 1.08fr);
}

.recurring-picker-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

.recurring-picker {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.component-tools {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
  margin-top: 10px;
}

.component-tools .button {
  min-height: 38px;
  padding: 8px 10px;
}

.component-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.component-option {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding: 9px 10px;
}

.component-option:hover,
.component-option.active {
  background: var(--surface-soft);
  border-color: var(--line);
}

.component-check {
  align-items: start;
  cursor: pointer;
  display: grid;
  flex: 1;
  gap: 8px;
  grid-template-columns: 22px minmax(0, 1fr);
  min-width: 0;
}

.component-check input {
  margin: 4px 0 0;
}

.component-option strong,
.component-option span {
  display: block;
}

.component-option strong {
  line-height: 1.2;
}

.component-option span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.duration-adjuster {
  align-items: center;
  display: grid;
  flex: 0 0 auto;
  gap: 4px;
  grid-template-columns: 34px 54px 34px;
}

.duration-adjuster button,
.duration-adjuster input {
  border: 1px solid var(--line);
  border-radius: 6px;
  font-weight: 900;
  min-height: 34px;
  padding: 4px;
  text-align: center;
}

.duration-adjuster button {
  background: #ffffff;
  cursor: pointer;
}

.duration-adjuster input {
  background: #fffdf8;
  width: 100%;
}

.micro-search {
  display: grid;
  gap: 6px;
  margin: 6px 0 12px;
}

.micro-search span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  padding: 0 4px;
}

.micro-search input {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 44px;
  padding: 10px 12px;
  width: 100%;
}

.recurring-picker button {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 12px;
  text-align: left;
}

.recurring-picker button:hover,
.recurring-picker button.active {
  background: var(--surface-soft);
  border-color: var(--line);
  color: var(--text);
}

.recurring-picker button.active {
  border-left: 4px solid var(--red);
}

.recurring-picker strong,
.recurring-picker span {
  display: block;
}

.recurring-picker span {
  font-size: 0.82rem;
  font-weight: 800;
  margin-top: 2px;
}

.side-nav {
  display: grid;
  gap: 8px;
  padding: 12px;
  position: sticky;
  top: 18px;
}

.side-nav-title {
  padding: 2px 4px 6px;
}

.side-nav a {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
}

.side-nav a:hover,
.side-nav a.active {
  background: var(--surface-soft);
}

.side-nav a.active {
  border-left: 4px solid var(--red);
}

.side-nav span,
.side-note {
  color: var(--muted);
  font-size: 0.86rem;
}

.side-note {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.form-panel,
.preview-panel {
  min-width: 0;
  padding: 20px;
}

.form-heading,
.preview-heading {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-weight: 800;
}

.hint {
  font-size: 0.88rem;
}

.field input,
.field select,
.field textarea,
.markdown-preview {
  background: #fbfcfc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  padding: 10px 12px;
  width: 100%;
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.markdown-preview {
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  min-height: 560px;
  overflow-wrap: anywhere;
  resize: vertical;
  white-space: pre-wrap;
  word-break: break-word;
}

.runsheet-preview-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
  padding: 20px;
}

.runsheet-topline {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.82rem;
  font-weight: 900;
  gap: 8px 14px;
  margin-bottom: 8px;
}

.runsheet-preview-card h2 {
  font-size: clamp(1.7rem, 3vw, 2.6rem);
}

.runsheet-summary {
  color: var(--muted);
  margin: 10px 0 0;
}

.runsheet-jump-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0;
}

.runsheet-jump-nav a {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 900;
  padding: 7px 10px;
  text-decoration: none;
}

.runsheet-timeline {
  display: grid;
  gap: 10px;
}

.runsheet-block {
  border: 1px solid var(--line);
  border-left: 6px solid var(--green);
  border-radius: var(--radius);
  display: grid;
  gap: 6px;
  padding: 14px;
}

.runsheet-block.ads {
  border-left-color: var(--gold);
}

.runsheet-block.story {
  border-left-color: var(--red);
}

.runsheet-block.scene {
  border-left-color: var(--blue);
}

.runsheet-block.meta {
  border-left-color: var(--muted);
}

.runsheet-block-header {
  align-items: baseline;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.runsheet-time {
  color: var(--red);
  font-size: 0.86rem;
  font-weight: 900;
}

.runsheet-block h3 {
  font-size: 1.12rem;
  line-height: 1.2;
  margin: 0;
}

.runsheet-block p {
  margin: 0;
}

.runsheet-block small {
  color: var(--muted);
  font-weight: 800;
}

.runsheet-notes {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  margin-top: 14px;
  padding: 12px;
}

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

.status-line {
  margin-top: 12px;
}

.un-finder {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 28px;
  padding: 20px;
}

.un-finder-heading {
  align-items: start;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding-bottom: 16px;
}

.un-finder-heading h2 {
  margin-top: 4px;
}

.un-finder-note,
.un-empty {
  color: var(--muted);
  margin: 10px 0 0;
}

.un-finder-controls {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  margin-top: 16px;
}

.un-finder-controls label {
  display: grid;
  gap: 6px;
}

.un-finder-controls span,
.un-finder-meta {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 900;
}

.un-finder-controls input,
.un-finder-controls select {
  background: #fbfcfc;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  min-height: 46px;
  padding: 10px 12px;
  width: 100%;
}

.un-finder-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: space-between;
  margin-top: 12px;
}

.back-to-top {
  background: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 999px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  color: #ffffff;
  cursor: pointer;
  font-weight: 900;
  min-height: 48px;
  opacity: 0;
  padding: 0 16px;
  pointer-events: none;
  position: fixed;
  right: 18px;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 80;
}

.back-to-top.is-visible {
  opacity: 0.94;
  pointer-events: auto;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--red);
}

.un-calendar {
  margin-top: 16px;
}

.un-calendar-title {
  font-weight: 900;
  margin-bottom: 10px;
}

.un-calendar-grid {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.un-day,
.un-month-strip span {
  background: #f8faf9;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
}

.un-day {
  display: grid;
  gap: 5px;
  min-height: 94px;
  padding: 8px;
}

.un-day.has-events {
  background: var(--surface-soft);
  border-color: rgba(34, 101, 168, 0.28);
}

.un-day-number {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.un-day a {
  color: var(--text);
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-decoration: none;
}

.un-day a:hover {
  color: var(--blue);
}

.un-more {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
}

.un-month-strip {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.un-month-strip span {
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  padding: 10px;
}

.un-month-strip .has-match {
  background: var(--surface-soft);
  color: var(--text);
}

@media (max-width: 1180px) {
  .site-header {
    align-items: stretch;
    display: grid;
    gap: 12px;
    grid-template-columns: 1fr;
    padding: 10px 16px;
  }

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

  .mobile-nav-ready .site-nav {
    display: none;
  }

  .mobile-nav-ready .mobile-page-menu {
    display: grid;
    gap: 6px;
  }

  .mobile-page-menu span {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 900;
  }

  .mobile-page-menu select {
    appearance: auto;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font-weight: 900;
    min-height: 48px;
    padding: 10px 12px;
    width: 100%;
  }

  .builder-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .builder-layout,
  .recurring-builder-layout,
  .runsheet-layout {
    grid-template-columns: 1fr;
  }

  .side-nav {
    display: none;
  }
}

@media (max-width: 840px) {
  .site-header {
    padding: 10px 14px;
  }

  .poster-mark {
    height: 112px;
    width: 76px;
  }

  .home-shell,
  .app-shell {
    padding: 16px;
  }

  .page-intro {
    margin-top: 18px;
  }

  .home-hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .hero-poster {
    max-height: none;
    order: -1;
    object-fit: contain;
    object-position: center;
    width: min(100%, 430px);
  }

  .builder-grid,
  .boundary-strip,
  .footer-nav,
  .spirit-guide,
  .side-nav {
    grid-template-columns: 1fr;
  }

  .footer-nav-card,
  .footer-nav-card.next {
    text-align: left;
  }

  .builder-card {
    min-height: 132px;
  }
}

@media (max-width: 560px) {
  .poster-mark {
    height: 132px;
    width: 90px;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 3.4rem);
  }

  .page-intro h1 {
    font-size: clamp(1.85rem, 10vw, 3rem);
  }

  .form-heading,
  .preview-heading {
    display: grid;
  }

  .markdown-preview {
    min-height: 380px;
  }

  .un-finder {
    padding: 16px;
  }

  .un-finder-heading,
  .un-finder-controls {
    grid-template-columns: 1fr;
  }

  .un-finder-heading {
    display: grid;
  }

  .un-calendar-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .un-month-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .back-to-top {
    bottom: calc(88px + env(safe-area-inset-bottom));
    right: 14px;
  }

  .actions .button {
    flex: 1 1 100%;
  }
}
