:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --panel: #fffdf8;
  --ink: #24231f;
  --muted: #676257;
  --line: #ddd6c8;
  --green: #1f6f5b;
  --green-dark: #154b40;
  --coral: #c95e42;
  --gold: #d4a02a;
  --blue: #496f8c;
  --shadow: 0 18px 50px rgba(61, 51, 35, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(31, 111, 91, 0.08) 1px, transparent 1px),
    linear-gradient(rgba(31, 111, 91, 0.07) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--ink);
  font-family: "Aptos", "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

a {
  color: inherit;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 54px);
  border-bottom: 1px solid rgba(36, 35, 31, 0.12);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--green-dark);
  background: var(--green);
  color: #f8f1df;
  font-size: 0.84rem;
  letter-spacing: 0;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 4px;
}

.top-nav a {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.95rem;
  text-decoration: none;
}

.top-nav a:hover,
.top-nav a:focus-visible {
  color: var(--green-dark);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: clamp(26px, 5vw, 64px) 0 70px;
}

.intro-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: clamp(22px, 4vw, 48px);
  align-items: end;
  margin-bottom: clamp(28px, 6vw, 76px);
}

.intro-copy {
  max-width: 780px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 820px;
  margin-bottom: 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.45rem, 6vw, 5.5rem);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 0.96;
}

h2 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 3vw, 2.55rem);
  line-height: 1.04;
}

h3 {
  margin-bottom: 16px;
  font-size: 1rem;
}

.lead {
  max-width: 670px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.25rem);
}

.privacy-panel,
.section-block,
.submit-bar,
.result-card {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.privacy-panel {
  padding: 20px;
  transform: rotate(-1deg);
}

.privacy-panel h2 {
  margin-bottom: 12px;
  font-family: inherit;
  font-size: 1.15rem;
}

.privacy-panel ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.survey-layout {
  display: grid;
  gap: 22px;
}

.section-block {
  scroll-margin-top: 84px;
  padding: clamp(18px, 4vw, 34px);
}

.section-heading {
  display: grid;
  max-width: 760px;
  margin-bottom: 24px;
}

.section-heading p:not(.eyebrow) {
  color: var(--muted);
}

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

.field,
.period-row label {
  display: grid;
  gap: 7px;
}

.field span:first-child,
.period-row label > span:first-child,
.source-row > span:first-child {
  color: var(--muted);
  font-size: 0.91rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #cfc7b8;
  border-radius: var(--radius);
  background: #fffaf1;
  color: var(--ink);
  padding: 10px 12px;
}

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

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--gold) 46%, transparent);
  outline-offset: 2px;
}

.input-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.input-unit > span {
  min-width: 48px;
  color: var(--muted);
  font-weight: 800;
}

.input-unit.small {
  grid-template-columns: minmax(80px, 120px) 24px;
}

.mix-board {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.mix-total {
  position: sticky;
  top: 88px;
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at center, color-mix(in srgb, var(--gold) 14%, transparent) 0 46%, transparent 47%),
    #faf2e2;
  text-align: center;
}

.mix-total span:first-child {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3.2rem;
  line-height: 1;
}

.mix-total span:last-child {
  color: var(--muted);
  font-weight: 800;
}

body[data-mix-state="valid"] .mix-total {
  border-color: color-mix(in srgb, var(--green) 52%, var(--line));
}

body[data-mix-state="invalid"] .mix-total {
  border-color: color-mix(in srgb, var(--coral) 56%, var(--line));
}

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

.source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid rgba(221, 214, 200, 0.9);
  background: #fffaf1;
}

.timeline-actions {
  display: flex;
  justify-content: flex-start;
  margin: 14px 0 16px;
}

.primary-button,
.secondary-button,
.icon-button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 850;
}

.primary-button {
  padding: 12px 18px;
  background: var(--green-dark);
  color: #fff8e9;
}

.secondary-button {
  padding: 11px 14px;
  border-color: var(--green-dark);
  background: transparent;
  color: var(--green-dark);
}

.icon-button {
  width: 44px;
  padding: 0;
  border-color: var(--line);
  background: #fff8e9;
  color: var(--coral);
  font-size: 1.5rem;
  line-height: 1;
}

.period-list {
  display: grid;
  gap: 10px;
}

.period-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.1fr) repeat(2, minmax(120px, 0.8fr)) minmax(118px, 0.6fr) minmax(120px, 0.65fr) 44px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid rgba(221, 214, 200, 0.95);
  background: #fffaf1;
}

.check-line {
  display: flex !important;
  align-items: center;
  min-height: 46px;
  padding-bottom: 2px;
}

.check-line input {
  width: 20px;
  min-height: 20px;
}

.timeline-visual {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}

.timeline-scale {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.timeline-bars {
  display: grid;
  gap: 12px;
}

.timeline-line {
  display: grid;
  grid-template-columns: minmax(160px, 240px) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.timeline-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

.timeline-track {
  position: relative;
  height: 18px;
  border: 1px solid var(--line);
  background: #eee6d8;
  overflow: hidden;
}

.timeline-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.submit-bar {
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
}

.submit-bar strong,
.submit-bar span {
  display: block;
}

.submit-bar span {
  color: var(--muted);
  font-size: 0.92rem;
}

.results-block {
  margin-top: 34px;
}

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

.result-card {
  min-height: 120px;
  padding: 18px;
  box-shadow: none;
}

.result-card.wide {
  grid-column: 1 / -1;
}

.metric-card {
  display: grid;
  align-content: center;
  gap: 8px;
  background: #f4ead6;
}

.metric-card span {
  color: var(--muted);
  font-weight: 800;
}

.metric-card strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1;
}

.result-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(221, 214, 200, 0.75);
}

.result-row span {
  color: var(--muted);
}

.answer-timelines {
  margin-top: 24px;
}

.answer-timeline-head,
.answer-timeline-empty {
  border-top: 1px dashed var(--line);
  padding-top: 20px;
}

.answer-timeline-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.answer-timeline-head h3,
.answer-timeline-empty h3 {
  margin-bottom: 6px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}

.answer-timeline-head p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
}

.answer-timeline-head strong {
  color: var(--green-dark);
  white-space: nowrap;
}

.answer-timeline-list {
  display: grid;
  gap: 12px;
}

.answer-timeline-card {
  padding: 14px;
  border: 1px solid rgba(221, 214, 200, 0.9);
  background: #fffaf1;
}

.answer-timeline-card.is-empty {
  background: color-mix(in srgb, #fffaf1 64%, var(--bg));
}

.answer-timeline-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.answer-timeline-title span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 750;
}

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

.answer-timeline-line {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.answer-timeline-label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.answer-timeline-label small {
  display: block;
  margin-top: 2px;
  color: color-mix(in srgb, var(--muted) 72%, transparent);
  font-size: 0.78rem;
  font-weight: 700;
}

.answer-timeline-track {
  position: relative;
  height: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(36, 35, 31, 0.08) 1px, transparent 1px),
    #eee6d8;
  background-size: 8.333% 100%;
  overflow: hidden;
}

.answer-timeline-bar {
  position: absolute;
  top: 0;
  bottom: 0;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

.empty-note {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 920px) {
  .intro-shell,
  .mix-board,
  .field-grid,
  .source-list,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .privacy-panel {
    transform: none;
  }

  .mix-total {
    position: static;
    min-height: 120px;
  }

  .period-row {
    grid-template-columns: 1fr 1fr;
  }

  .period-row .icon-button {
    width: 100%;
  }
}

@media (max-width: 640px) {
  .site-header,
  .submit-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-nav {
    justify-content: flex-start;
  }

  main {
    width: min(100% - 22px, 1180px);
    padding-top: 24px;
  }

  h1 {
    font-size: clamp(2.25rem, 15vw, 3.4rem);
  }

  .section-block {
    padding: 18px 14px;
  }

  .source-row {
    align-items: stretch;
    flex-direction: column;
  }

  .input-unit.small {
    grid-template-columns: minmax(0, 1fr) 24px;
  }

  .period-row {
    grid-template-columns: 1fr;
  }

  .timeline-line {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .answer-timeline-head,
  .answer-timeline-title {
    align-items: stretch;
    flex-direction: column;
  }

  .answer-timeline-line {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .section-block,
  .privacy-panel,
  .submit-bar {
    animation: lift-in 520ms ease-out both;
  }

  @keyframes lift-in {
    from {
      opacity: 0;
      transform: translateY(14px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}
