:root {
  color-scheme: light;
  --paper: #faf6ed;
  --surface: #fffdf7;
  --ink: #172b43;
  --muted: #4d6470;
  --teal: #1f6269;
  --accent: #a33d29;
  --line: #cbd2c5;
  --tint: #eaf0e9;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 500 1rem/1.55 var(--sans);
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.frame { width: min(1180px, 100% - 88px); margin-inline: auto; }
.skip {
  background: var(--surface);
  position: absolute;
  inset: 8px auto auto 8px;
  padding: 8px 12px;
  transform: translateY(-160%);
  z-index: 1;
}
.skip:focus { transform: none; }

.masthead {
  border-bottom: 1px solid var(--line);
  padding-block: 25px 18px;
  text-align: center;
  font: 600 clamp(1.2rem, 2.5vw, 1.6rem)/1.15 var(--serif);
  overflow-wrap: anywhere;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, .84fr) minmax(0, 1fr);
  align-items: stretch;
  min-height: 590px;
  margin-block: 28px 56px;
}
.hero-copy { align-self: center; padding: 20px 34px 26px 0; }
.hero h1 {
  margin: 0;
  font: 600 clamp(5.5rem, 10vw, 9.6rem)/.78 var(--serif);
  letter-spacing: -.058em;
}
.hero h1 span { color: var(--accent); }
.hero p { max-width: 28ch; margin: 32px 0 22px; color: var(--muted); }
.hero-actions, .row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.hero-actions { gap: 16px 22px; }
.hero-art {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: clamp(23px, 4vw, 62px);
  background-color: #183742;
  background-image: radial-gradient(ellipse at 70% 14%, #2b5559, transparent 64%),
    repeating-linear-gradient(128deg, #feead008 0, #feead008 1px, transparent 1px, transparent 5px);
}
.hero-art canvas {
  display: block;
  width: min(100%, 390px);
  height: auto;
  background: var(--surface);
  box-shadow: 0 14px 37px #06151cb5;
}

.button {
  border: 1px solid transparent;
  border-radius: 3px;
  min-height: 43px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 16px;
  text-decoration: none;
  font-size: .86rem;
  line-height: 1.3;
  font-weight: 800;
}
.primary { background: var(--ink); color: #fffaf0; }
.primary:not(:disabled):hover { background: var(--teal); }
.quiet { border-color: var(--line); background: transparent; }
.quiet:not(:disabled):hover { background: var(--tint); }
.text-link { font-size: .86rem; font-weight: 800; text-underline-offset: 4px; }
.text-link:hover { color: var(--teal); }

.studio { scroll-margin-top: 12px; border-top: 1px solid var(--line); padding: 24px 0 50px; }
.studio-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 24px; }
.studio h2 {
  font: 600 clamp(2.8rem, 6vw, 4.2rem)/.92 var(--serif);
  letter-spacing: -.035em;
  margin: 0;
}
.studio-grid { display: grid; grid-template-columns: minmax(0, .82fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.editor, .result { background: var(--surface); border: 1px solid var(--line); padding: clamp(17px, 2.6vw, 31px); min-width: 0; }
.result { position: sticky; top: 15px; scroll-margin-top: 12px; }
.studio h3 { margin: 0; font: 600 1.68rem/1.05 var(--serif); }
.section-line { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 14px; }

.switch {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  background: var(--tint);
  border-radius: 4px;
  max-width: 100%;
}
.switch button {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  min-height: 36px;
  border-radius: 2px;
  white-space: nowrap;
  font-size: .79rem;
  font-weight: 800;
}
.switch [aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 3px #12293320; }

.field { min-width: 0; display: grid; gap: 5px; }
.field label, .advanced summary { font-size: .84rem; font-weight: 800; }
.field :is(input, select):not([type="range"]) {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 3px;
  width: 100%;
  min-height: 43px;
  padding: 7px 9px;
}
.field :is(input, select)[aria-invalid="true"] { border-color: var(--accent); }
.field small, .optional { color: var(--muted); font-size: .77rem; }
.field small.error { color: var(--accent); }
.optional { font-weight: 500; }
.field-pair, .result-pickers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.identity-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(74px, 24%);
  align-items: start;
  gap: 10px;
}
.result-pickers { grid-template-columns: minmax(0, 1fr) minmax(115px, .65fr); margin: 16px 0 10px; }
.pattern-actions { margin-bottom: 12px; }
#event-form { display: grid; gap: 13px; margin: 20px 0 23px; padding: 20px 0; border-block: 1px solid var(--line); }
.form-actions { margin-top: 2px; }
.compact-jump { display: none; }
.error, .muted { font-size: .84rem; margin: 0; }
.error { color: var(--accent); }
.muted { color: var(--muted); }

.event-section { border-bottom: 1px solid var(--line); padding-bottom: 14px; }
#event-count { font-size: .84rem; color: var(--muted); }
#empty-list { margin-top: 11px; }
#event-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 260px; overflow-y: auto; }
#event-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 9px;
  padding-block: 8px;
  border-bottom: 1px solid var(--tint);
}
#event-list li:last-child { border: 0; }
.event-copy { min-width: 0; overflow-wrap: anywhere; }
.event-copy strong { display: block; font-size: .87rem; }
.event-copy small { display: block; font-size: .75rem; color: var(--muted); }
.event-actions { display: flex; align-items: center; gap: 4px; }
.icon-button {
  font-size: 1.05rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  min-width: 38px;
  min-height: 38px;
}
.icon-button:hover { background: var(--tint); }
.advanced { padding-top: 14px; }
.advanced summary { cursor: pointer; width: fit-content; }
.advanced .field { margin-top: 13px; }
.advanced output { margin-left: 6px; font-weight: 600; color: var(--muted); }
input[type="range"] { cursor: pointer; accent-color: var(--teal); max-width: 290px; width: 100%; }

#card-well {
  display: grid;
  place-items: center;
  padding: clamp(12px, 2.7vw, 26px);
  background: var(--tint);
}
#card {
  display: block;
  width: auto;
  height: auto;
  max-width: min(100%, 440px);
  max-height: min(65vh, 630px);
  box-shadow: 0 6px 18px #10283b29;
}
#placeholder {
  min-height: 234px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 6px;
  color: var(--muted);
  text-align: center;
}
#placeholder p { margin: 0; }
.flower-symbol { font: 600 3.7rem/1 var(--serif); color: var(--teal); }
.page-controls { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }
.page-controls output { font-size: .85rem; font-variant-numeric: tabular-nums; }
.page-controls .button { padding-inline: 12px; }
.card-actions { margin-top: 14px; }
#result-status:not(:empty) { margin-top: 9px; }
.footer {
  display: flex;
  align-items: baseline;
  gap: 8px 20px;
  flex-wrap: wrap;
  padding: 17px 0 29px;
  border-top: 1px solid var(--line);
}
.footer a:last-child { margin-inline-start: auto; }

@media (max-width: 1000px) {
  .frame { width: min(100% - 52px, 1180px); }
  .hero { min-height: 490px; }
  .hero h1 { font-size: clamp(4.6rem, 11vw, 8rem); }
  .studio-grid { gap: 15px; }
}

@media (max-width: 760px) {
  .frame { width: min(100% - 32px, 540px); }
  .masthead { padding-block: 17px 12px; }
  .hero { grid-template-columns: minmax(0, 1fr); min-height: auto; margin-block: 23px 35px; }
  .hero-copy { padding: 12px 0 24px; }
  .hero h1 { font-size: clamp(4.2rem, 16vw, 7.2rem); }
  .hero h1 br { display: none; }
  .hero p { margin: 19px 0 15px; }
  .hero-art { padding: clamp(14px, 5vw, 29px); }
  .hero-art canvas { width: min(100%, 340px); }
  .studio-heading { align-items: start; flex-direction: column; }
  .studio-grid { display: flex; flex-direction: column; }
  .editor, .result { width: 100%; }
  .result { position: static; }
  .compact-jump { display: inline-flex; }
}

@media (max-width: 395px) {
  .studio h2 { font-size: 2.65rem; }
  .hero h1 { font-size: clamp(3rem, 12vw, 4.5rem); }
  .result-pickers { grid-template-columns: minmax(0, 1fr); }
  .icon-button { min-width: 44px; min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
