:root {
  --bg: #e7f9fe;
  --surface: #daecf1;
  --border: #bed1d6;
  --text: #04191f;
  --muted: #55696f;
  --primary: #0d758b;
  --primary-dark: #075466;
  --secondary: #724498;
  --secondary-dark: #553070;
  --accent: #bf4925;
  --accent-dark: #8f3218;
  --pale: #f6fdff;
  --shadow: rgba(4, 25, 31, .13);
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(118deg, transparent 0 38%, rgba(255,255,255,.34) 43%, transparent 50%) fixed,
    repeating-linear-gradient(135deg, rgba(13,117,139,.022) 0 1px, transparent 1px 7px),
    var(--bg);
  font-family: var(--sans);
  line-height: 1.55;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary-dark); }
[hidden] { display: none !important; }
.heat-line { height: 5px; background: linear-gradient(90deg, var(--accent), var(--secondary), var(--primary), var(--accent)); }
.shell { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }

.masthead { min-height: 90px; display: flex; justify-content: space-between; align-items: center; border-bottom: 3px double var(--border); }
.masthead p { margin: 0; color: var(--muted); font-size: .9rem; }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--text); text-decoration: none; font: 700 1.3rem var(--serif); letter-spacing: .02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--pale); background: var(--primary-dark); border: 1px solid var(--primary-dark); outline: 1px solid var(--pale); outline-offset: -4px; transform: rotate(45deg); }
.brand-mark::first-letter { transform: rotate(-45deg); }

.intro { padding: 76px 0 54px; max-width: 840px; }
.eyebrow { margin: 0 0 7px; color: var(--accent-dark); font-size: .75rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { margin: 0; font-family: var(--serif); font-weight: 500; line-height: 1.05; }
h1 { max-width: 760px; font-size: clamp(2.8rem, 7vw, 5.8rem); letter-spacing: -.045em; }
h2 { font-size: clamp(1.65rem, 3vw, 2.45rem); }
.intro > p:last-child { max-width: 690px; margin: 24px 0 0; color: var(--muted); font-size: 1.08rem; }

.panel, .result-card, .month-sheet {
  position: relative;
  background:
    linear-gradient(120deg, rgba(255,255,255,.34), transparent 35% 66%, rgba(255,255,255,.18)),
    var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 18px 55px var(--shadow);
  clip-path: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}
.setup-panel { padding: clamp(24px, 5vw, 48px); }
.section-heading { display: flex; align-items: flex-start; gap: 16px; margin: 0 0 28px; }
.stage { flex: 0 0 38px; display: grid; place-items: center; aspect-ratio: 1; color: var(--pale); background: var(--secondary-dark); font: italic 1.1rem var(--serif); border-radius: 50%; }
.setup-grid { display: grid; grid-template-columns: 1.5fr .8fr 1fr; gap: 18px; align-items: start; }
.field { position: relative; }
.field label { display: block; margin-bottom: 7px; font-size: .78rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
input, select {
  width: 100%; min-height: 48px; padding: 10px 12px; color: var(--text); background: rgba(246,253,255,.82); border: 1px solid #8aa3aa; border-radius: 2px;
}
.input-prefix { display: flex; align-items: center; min-height: 48px; background: rgba(246,253,255,.82); border: 1px solid #8aa3aa; }
.input-prefix span { padding-left: 13px; color: var(--primary-dark); font-weight: 800; }
.input-prefix input { border: 0; background: transparent; }
input:focus, select:focus, .input-prefix:focus-within { outline: 3px solid var(--secondary); outline-offset: 2px; }
.input-prefix input:focus { outline: 0; }
.hint, .inclusion-note, .archive-note, .automation-note { color: var(--muted); font-size: .83rem; }
.hint { margin: 6px 0 0; }
.inclusion-note { max-width: 760px; margin: 18px 0 0; }
.suggestions { position: absolute; z-index: 10; top: 76px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; background: var(--pale); border: 1px solid var(--primary); box-shadow: 0 12px 30px var(--shadow); }
.suggestions li { display: flex; gap: 10px; align-items: center; min-height: 48px; padding: 7px 9px; cursor: pointer; }
.suggestions li[aria-selected="true"], .suggestions li:hover { background: var(--surface); }
.suggestions img { width: 34px; height: 34px; object-fit: cover; border-radius: 50%; background: var(--border); }
.suggestions strong, .suggestions span { display: block; line-height: 1.25; }
.suggestions span { color: var(--muted); font-size: .83rem; }

.form-actions, .result-tools, .archive-toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-top: 24px; }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 46px; padding: 10px 18px; border: 1px solid transparent; border-radius: 2px; cursor: pointer; font-weight: 800; text-decoration: none; transition: transform .16s ease, background .16s ease; }
.button:hover { transform: translateY(-2px); }
.button:focus-visible, summary:focus-visible { outline: 3px solid var(--secondary); outline-offset: 3px; }
.button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.primary { color: white; background: var(--primary-dark); }
.primary:hover { background: #043f4d; }
.secondary { color: white; background: var(--secondary-dark); }
.secondary:hover { background: #432358; }
.quiet { color: var(--text); background: transparent; border-color: #789198; }
.quiet:hover { background: rgba(255,255,255,.45); }

.progress-wrap { margin-top: 26px; padding-top: 20px; border-top: 3px double var(--border); }
.progress-top { display: flex; justify-content: space-between; gap: 16px; }
.progress-track { height: 8px; margin: 10px 0 14px; overflow: hidden; background: var(--border); }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--primary), var(--secondary)); transition: width .25s; }
.progress-ledger { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 0; padding: 0; list-style-position: inside; color: var(--muted); font-size: .82rem; }
.status { min-height: 1.5em; margin-top: 12px; color: var(--primary-dark); font-weight: 700; }
.error { margin-top: 16px; padding: 14px 16px; color: #681c08; background: #fff0eb; border-left: 5px solid var(--accent); }

.result-section, .archive-section { padding: 80px 0 0; }
.empty-state { display: grid; place-items: center; min-height: 390px; padding: 30px; text-align: center; }
.empty-state p { max-width: 440px; color: var(--muted); }
.empty-rosette { color: var(--primary); font-size: 4.2rem; }
.result-card { width: min(920px, 100%); margin: 0 auto; padding: clamp(14px, 2.5vw, 24px); color: white; background: var(--primary-dark); border: 5px double var(--pale); box-shadow: 0 22px 65px rgba(4,25,31,.22); clip-path: none; }
.result-kicker { padding-bottom: 7px; color: #bfe9f0; font-size: clamp(.65rem, 1.5vw, .84rem); font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.result-context { display: flex; justify-content: space-between; align-items: baseline; gap: 18px; padding-bottom: 14px; }
.result-context strong { max-width: 60%; overflow: hidden; font: 500 clamp(1.15rem, 3vw, 2rem) var(--serif); text-overflow: ellipsis; white-space: nowrap; }
.result-context span { color: #d9f3f7; font-size: clamp(.67rem, 1.5vw, .85rem); text-align: right; }
#collage { display: block; width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--surface); border: 1px solid #bfe9f0; }
.result-card figcaption { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; padding-top: 13px; color: #d9f3f7; font-size: clamp(.62rem, 1.5vw, .82rem); }
.result-card figcaption span:nth-child(2) { text-align: center; }
.result-card figcaption span:last-child { text-align: right; }
.result-tools { justify-content: center; }
.automation-note { max-width: 720px; margin: 18px auto 0; text-align: center; }
.credits { max-width: 920px; margin: 18px auto 0; border-top: 1px solid var(--border); }
.credits summary { min-height: 44px; padding: 12px 2px; cursor: pointer; font-weight: 800; }
.credits a { overflow-wrap: anywhere; }
.credit-row { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 9px 0; border-top: 1px dotted var(--border); font-size: .84rem; }

.archive-section { padding-bottom: 90px; }
.archive-toolbar { margin-top: 0; }
.field.compact { width: 130px; }
.archive-note { max-width: 760px; }
.calendar { display: grid; gap: 30px; margin-top: 28px; }
.month-sheet { padding: clamp(16px, 3vw, 30px); break-after: page; }
.month-title { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 14px; border-bottom: 3px double var(--border); }
.month-title h3 { margin: 0; font: 500 clamp(1.5rem, 3vw, 2.4rem) var(--serif); }
.month-title span { color: var(--accent-dark); font-weight: 800; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 10px; }
.weekday { padding: 6px 2px; color: var(--muted); font-size: .68rem; font-weight: 800; text-align: center; text-transform: uppercase; }
.calendar-day { position: relative; min-width: 0; aspect-ratio: 1; padding: 5px; background: rgba(246,253,255,.56); border: 1px solid var(--border); }
.calendar-day.blank { background: rgba(190,209,214,.18); }
.calendar-day .day-number { position: relative; z-index: 1; display: inline-grid; place-items: center; width: 23px; height: 23px; color: var(--text); background: rgba(246,253,255,.86); border-radius: 50%; font-size: .7rem; font-weight: 800; }
.calendar-day img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 28px 0 44px; color: var(--muted); border-top: 3px double var(--border); font-size: .82rem; }
footer span:first-child { color: var(--text); font: 700 1rem var(--serif); }

@media (max-width: 720px) {
  .shell { width: min(100% - 24px, 1120px); }
  .masthead { min-height: 72px; }
  .masthead p { display: none; }
  .intro { padding: 50px 4px 38px; }
  .setup-grid { grid-template-columns: 1fr; }
  .result-section, .archive-section { padding-top: 58px; }
  .result-context { display: block; }
  .result-context strong { display: block; max-width: 100%; }
  .result-context span { display: block; padding-top: 4px; text-align: left; }
  .result-card figcaption { gap: 5px; }
  .month-sheet { padding: 10px; }
  .month-grid { gap: 2px; }
  .calendar-day { padding: 2px; }
  footer { display: block; }
  footer span { display: block; margin-top: 5px; }
}

@media (max-width: 420px) {
  h1 { font-size: 2.55rem; }
  .setup-panel { padding: 24px 16px; }
  .section-heading { gap: 10px; }
  .stage { flex-basis: 32px; }
  .button { width: 100%; }
  .archive-toolbar .field { width: 100%; }
  .result-card { padding: 10px; }
  .result-card figcaption { grid-template-columns: 1fr 1fr; }
  .result-card figcaption span:last-child { grid-column: 1 / -1; text-align: left; }
  .weekday { font-size: .55rem; }
  .calendar-day .day-number { width: 18px; height: 18px; font-size: .6rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; }
}

@media print {
  @page { size: landscape; margin: 10mm; }
  body { background: white; }
  .heat-line, .masthead, .intro, .setup-panel, .result-section, .archive-section > .section-heading, .archive-toolbar, .archive-note, footer { display: none !important; }
  .shell, .archive-section { width: auto; margin: 0; padding: 0; }
  .calendar { display: block; margin: 0; }
  .month-sheet { min-height: 180mm; margin: 0; padding: 8mm; box-shadow: none; clip-path: none; break-after: page; }
}
