:root {
  color-scheme: light;
  --primary: #e8e2d0;
  --secondary: #9e1b1b;
  --secondary-rgb: 158, 27, 27;
  --outline: #C78C25;
  --page-bg:
    radial-gradient(circle at top left, rgba(255, 244, 216, 0.92), transparent 34%),
    linear-gradient(180deg, #f4efdf 0%, #e8e2d0 100%);
  --panel-bg: rgba(232, 226, 208, 0.94);
  --text-main: #3a221b;
  --text-muted: rgba(58, 34, 27, 0.72);
  --accent: var(--secondary);
  --accent-strong: #7f1515;
  --shadow: 0 20px 50px rgba(122, 33, 33, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text-main);
  background: var(--page-bg);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.hero-card,
.panel {
  border: 1px solid var(--outline);
  border-radius: 24px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 28px 32px;
  margin-bottom: 20px;
  overflow: hidden;
}

.panel {
  padding: 28px;
  margin-bottom: 20px;
}

.hero-header,
.result-stage-header,
.section-heading,
.field-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.hero-header {
  align-items: center;
  gap: 20px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-icon {
  width: 90px;
  height: 90px;
  flex: 0 0 auto;
}

.hero-stage {
  margin-top: 20px;
}

.hero-intro,
.result-stage,
.mode-card {
  border-radius: 20px;
  border: 1px solid rgba(197, 160, 89, 0.45);
}

.hero-intro {
  padding: 18px 20px;
  background:
    linear-gradient(180deg, rgba(255, 250, 241, 0.88) 0%, rgba(245, 236, 217, 0.88) 100%);
}

.hero-prompt-label {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-copy,
.about-copy,
.mode-summary-copy,
.workflow-copy,
.mode-card-copy,
.status,
.field span {
  color: var(--text-muted);
}

.hero-copy,
.about-copy,
.workflow-copy,
.mode-card-copy {
  line-height: 1.6;
}

.hero-copy {
  max-width: 58ch;
  margin-bottom: 0;
  font-size: 1.05rem;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.about-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.hero-link-chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(var(--secondary-rgb), 0.22);
  background: rgba(255, 251, 243, 0.86);
  color: var(--accent-strong);
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 600;
}

.hero-link-chip:hover {
  background: rgba(158, 27, 27, 0.08);
}

.generator-workbench,
.generator-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.generator-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: stretch;
  padding-top: 18px;
  border-top: 1px solid rgba(197, 160, 89, 0.45);
}

.result-stage {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255, 252, 246, 0.92) 0%, rgba(245, 236, 217, 0.82) 100%);
}

.result-stage-title {
  margin-bottom: 0;
  font-size: 1.2rem;
}

.player-shell {
  margin-top: auto;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(158, 27, 27, 0.08);
  border: 1px solid rgba(158, 27, 27, 0.12);
}

.about-panel {
  overflow: hidden;
}

.workflow-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mode-workflow-section .section-heading {
  align-items: flex-end;
}

.mode-heading-copy h2 {
  margin-bottom: 6px;
}

.workflow-copy {
  margin-bottom: 0;
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 0;
}

.mode-card {
  min-height: 160px;
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 251, 243, 0.82) 0%, rgba(241, 232, 211, 0.92) 100%);
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.mode-card:focus-visible {
  outline: 2px solid rgba(var(--secondary-rgb), 0.48);
  outline-offset: 3px;
}

.mode-card.is-active,
.mode-cards[data-active-mode="mini"] #mode-card-mini,
.mode-cards[data-active-mode="flash"] #mode-card-flash,
.mode-cards[data-active-mode="pro"] #mode-card-pro,
.mode-cards[data-active-mode="ultra"] #mode-card-ultra {
  transform: translateY(-4px);
  border-color: rgba(var(--secondary-rgb), 0.42);
  box-shadow: 0 16px 30px rgba(var(--secondary-rgb), 0.12);
}

.mode-card-kicker {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(var(--secondary-rgb), 0.12);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mode-card-copy {
  margin: 12px 0 0;
  font-size: 0.94rem;
}

.mode-options-panel {
  padding-top: 0;
}

.mode-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.option-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

#flash-style-field {
  grid-column: 1 / -1;
  container-type: inline-size;
}

.option-field legend {
  padding: 0;
  margin: 0;
  color: var(--text-muted);
}

.option-grid {
  display: grid;
  gap: 10px;
}

.option-grid-mini {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.option-grid-flash {
  grid-template-columns: repeat(3, minmax(84px, 1fr));
  align-items: stretch;
}

.flash-style-layout {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(200px, 1.2fr);
  gap: 14px;
  align-items: stretch;
}

.flash-style-description-card {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-self: stretch;
  min-height: 0;
  padding: 14px 16px;
  border: 1px solid rgba(197, 160, 89, 0.45);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 251, 243, 0.88) 0%, rgba(241, 232, 211, 0.9) 100%);
}

.flash-style-description-label {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.flash-style-description-copy {
  margin: 0;
  color: var(--text-main);
  line-height: 1.5;
}

.option-tile {
  position: relative;
  display: flex;
  min-height: 56px;
  cursor: pointer;
  min-width: 0;
}

.option-tile input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.option-tile span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  min-width: 84px;
  padding: 10px 12px;
  border: 1px solid rgba(197, 160, 89, 0.45);
  border-radius: 12px;
  background: rgba(255, 251, 243, 0.82);
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
  transition:
    border-color 180ms ease,
    box-shadow 180ms ease,
    transform 180ms ease,
    background 180ms ease;
}

.option-tile input:checked + span {
  border-color: rgba(var(--secondary-rgb), 0.42);
  background: rgba(158, 27, 27, 0.09);
  box-shadow: 0 12px 24px rgba(var(--secondary-rgb), 0.08);
  transform: translateY(-1px);
}

.option-tile input:focus-visible + span {
  outline: 2px solid rgba(var(--secondary-rgb), 0.48);
  outline-offset: 2px;
}

@container (max-width: 430px) {
  .flash-style-layout {
    grid-template-columns: 1fr;
  }

  .flash-style-description-card {
    min-height: auto;
  }
}

.about-section {
  margin-top: 0;
}

.about-copy p {
  margin: 0;
}

.about-copy p + p {
  margin-top: 12px;
}

.about-mode-token {
  color: var(--secondary);
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--accent);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-inline {
  align-items: flex-start;
  min-width: 180px;
}

.input-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.field-hint {
  font-size: 0.92rem;
  line-height: 1.35;
}

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

.mode-summary,
.result-summary {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid rgba(197, 160, 89, 0.55);
}

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

.result-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-label {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.result-value {
  font-size: 1rem;
  font-weight: 600;
}

textarea,
select,
button,
.download-link {
  font: inherit;
}

textarea,
select {
  width: 100%;
  border: 1px solid var(--outline);
  border-radius: 16px;
  padding: 14px 16px;
  background: rgba(255, 251, 243, 0.82);
  color: var(--text-main);
}

textarea {
  resize: vertical;
  min-height: 220px;
}

.sample-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 12px;
}

.sample-toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--outline);
  background: rgba(255, 251, 243, 0.82);
  color: var(--text-main);
  white-space: nowrap;
}

.sample-toggle-field input {
  width: 16px;
  height: 16px;
  accent-color: var(--secondary);
}

.sample-toggle-field[hidden] {
  display: none;
}

.sample-toggle-field:has(input:disabled) {
  opacity: 0.55;
}

.sample-length-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 200px;
  margin: 0;
  padding: 0;
  border: 0;
}

.sample-length-field > span {
  color: var(--text-muted);
}

.sample-length-pills {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 48px;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--outline);
  background: rgba(255, 251, 243, 0.82);
}

.sample-length-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.sample-length-pill input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: inherit;
}

.sample-length-pill span {
  position: relative;
  z-index: 1;
  color: inherit;
  font-weight: 600;
  pointer-events: none;
}

.sample-length-pill:has(input:checked) {
  background: rgba(var(--secondary-rgb), 0.12);
  color: var(--accent-strong);
}

.sample-length-pill:has(input:focus-visible) {
  outline: 2px solid rgba(var(--secondary-rgb), 0.48);
  outline-offset: 2px;
}

.sample-length-field:has(input:disabled) {
  opacity: 0.55;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 999px;
  border: 0;
  text-decoration: none;
}

button {
  cursor: pointer;
  color: var(--primary);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 14px 26px rgba(var(--secondary-rgb), 0.18);
}

.secondary-button {
  color: var(--accent-strong);
  background: rgba(158, 27, 27, 0.1);
  border: 1px solid var(--outline);
  box-shadow: none;
}

.dice-button {
  gap: 10px;
  min-width: 170px;
  padding: 0 20px 0 16px;
}

.dice-button-face {
  position: relative;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 7px;
  border: 1px solid rgba(158, 27, 27, 0.28);
  background: rgba(255, 251, 243, 0.9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.dice-pip {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--secondary);
}

.pip-top-left {
  top: 5px;
  left: 5px;
}

.pip-center {
  top: 10px;
  left: 10px;
}

.pip-bottom-right {
  right: 5px;
  bottom: 5px;
}

.download-link {
  background: rgba(158, 27, 27, 0.1);
  color: var(--accent-strong);
}

.download-link.is-disabled {
  pointer-events: none;
  opacity: 0.45;
}

.status {
  min-height: 24px;
  margin: 16px 0 12px;
}

.progress-section {
  margin: 0 0 16px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.progress-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(197, 160, 89, 0.18);
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--secondary);
  transition: width 120ms linear;
}

.player {
  width: 100%;
  margin-top: 0;
}

@media (max-width: 900px) {
  .hero-stage,
  .generator-layout {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 20px;
  }

  .hero-card,
  .panel {
    padding: 18px;
    border-radius: 20px;
  }

  .hero-header,
  .result-stage-header,
  .section-heading,
  .field-header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .brand-lockup {
    gap: 14px;
  }

  .brand-icon {
    width: 60px;
    height: 60px;
  }

  .sample-tools {
    justify-content: flex-start;
  }

  .mode-cards,
  .mode-options-grid,
  .grid,
  .result-grid {
    grid-template-columns: 1fr;
  }
}
