:root {
  --bg: #f6f0e4;
  --surface: rgba(255, 252, 246, 0.88);
  --surface-strong: #fffaf1;
  --line: #d7c8b2;
  --ink: #231a12;
  --muted: #645446;
  --accent: #3e6d49;
  --accent-soft: rgba(62, 109, 73, 0.12);
  --accent-warm: #b7771f;
  --accent-warm-soft: rgba(183, 119, 31, 0.12);
  --shadow: 0 18px 36px rgba(76, 53, 28, 0.08);
  --radius: 24px;
  --radius-small: 16px;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --font-body: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 35%),
    linear-gradient(180deg, #fbf7f0 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: var(--font-body);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 72px;
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.04em;
  margin: 0;
}

h1 {
  font-size: clamp(2.75rem, 5.4vw, 5rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.65rem, 2.4vw, 2.2rem);
}

p,
li,
td,
th,
label,
button,
input,
select {
  font: inherit;
}

.hero {
  display: grid;
  gap: 16px;
  margin-bottom: 28px;
}

.eyebrow,
.panel-eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.78rem;
  color: var(--muted);
}

.lede {
  max-width: 68ch;
  font-size: 1.2rem;
  line-height: 1.6;
  margin: 0;
}

.notice {
  margin: 0;
  max-width: 72ch;
  padding: 14px 18px;
  border: 1px solid rgba(183, 119, 31, 0.25);
  border-radius: 999px;
  background: rgba(255, 249, 239, 0.9);
  color: #5e4925;
}

.workspace,
.content-grid,
.content-grid--closing {
  display: grid;
  gap: 20px;
}

.workspace {
  grid-template-columns: minmax(0, 1.8fr) minmax(300px, 0.9fr);
  align-items: start;
}

.panel,
.content-card,
.formula-strip,
.examples,
.faq-section {
  background: var(--surface);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
}

.panel,
.content-card,
.examples,
.faq-section {
  border-radius: var(--radius);
}

.panel {
  padding: 24px;
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.format-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
}

.format-toggle legend {
  padding-right: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.format-toggle label {
  position: relative;
}

.format-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.format-toggle span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 10px 16px;
  border-radius: 999px;
  transition: 180ms ease;
}

.format-toggle input:checked + span {
  background: var(--accent);
  color: #fff;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 18px;
  border: 1px solid rgba(215, 200, 178, 0.8);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface-strong);
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(215, 200, 178, 0.75);
}

thead th {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

tbody th {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  width: 72px;
}

.time-input {
  display: flex;
  gap: 8px;
}

.time-input select,
.time-input input,
.settings-grid input,
.settings-grid select,
.time-table input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  padding: 0 14px;
  color: var(--ink);
}

.time-input select {
  width: 78px;
  flex: 0 0 78px;
}

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

.settings-grid label,
.content-card label {
  display: grid;
  gap: 8px;
}

.settings-grid span small {
  color: var(--muted);
}

.form-message,
.rail-summary {
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.form-message[data-state="error"] {
  color: #9c321e;
}

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

.button {
  min-height: 52px;
  padding: 0 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
  border-color: #b49b78;
}

.button--primary {
  background: linear-gradient(135deg, #4f8658, var(--accent));
  color: #fff;
  border-color: transparent;
}

.button--ghost {
  background: rgba(255, 249, 239, 0.8);
}

.result-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.result-card {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(62, 109, 73, 0.18);
  background: rgba(255, 255, 255, 0.88);
  display: grid;
  gap: 8px;
}

.result-card--accent {
  border-color: rgba(183, 119, 31, 0.24);
  background: rgba(255, 250, 241, 0.92);
}

.result-card span,
.result-card small,
.assumptions,
.checklist {
  color: var(--muted);
}

.result-card strong {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: -0.04em;
}

.assumptions,
.checklist {
  padding-left: 18px;
  line-height: 1.6;
}

.formula-strip {
  margin-top: 22px;
  padding: 22px 24px;
  border-radius: 24px;
}

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

.formula-grid p {
  margin: 0;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(215, 200, 178, 0.7);
  display: grid;
  gap: 8px;
}

.content-grid,
.content-grid--closing {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 22px;
}

.content-card {
  padding: 24px;
}

.content-card p,
.content-card li {
  line-height: 1.7;
  color: #3a2f24;
}

.content-card ol,
.content-card ul {
  padding-left: 20px;
}

.examples,
.faq-section {
  margin-top: 22px;
  padding: 24px;
}

.example-table td,
.example-table th {
  vertical-align: top;
}

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

.faq-item {
  border-radius: 18px;
  border: 1px solid rgba(215, 200, 178, 0.7);
  background: rgba(255, 255, 255, 0.72);
}

.faq-question {
  width: 100%;
  padding: 18px 20px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-weight: 600;
  cursor: pointer;
  position: relative;
}

.faq-question::after {
  content: "+";
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.faq-question[aria-expanded="true"]::after {
  content: "-";
}

.faq-answer {
  padding: 0 20px 18px;
}

.faq-answer p {
  margin: 0;
  line-height: 1.7;
}

button,
input,
select {
  font-family: var(--font-body);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(62, 109, 73, 0.26);
  outline-offset: 2px;
}

.period-hidden select {
  display: none;
}

@media (max-width: 980px) {
  .workspace,
  .content-grid,
  .content-grid--closing,
  .formula-grid {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  main {
    width: min(100% - 20px, 1180px);
    padding-top: 24px;
  }

  .hero,
  .panel,
  .content-card,
  .examples,
  .faq-section,
  .formula-strip {
    padding-left: 18px;
    padding-right: 18px;
  }

  .panel,
  .content-card,
  .examples,
  .faq-section {
    border-radius: 20px;
  }

  .panel-heading,
  .section-heading {
    align-items: start;
    flex-direction: column;
  }

  .time-table,
  .time-table thead,
  .time-table tbody,
  .time-table tr,
  .time-table th,
  .time-table td {
    display: block;
  }

  .time-table thead {
    display: none;
  }

  .time-table tr {
    padding: 12px;
    border-bottom: 1px solid rgba(215, 200, 178, 0.75);
  }

  .time-table tr:last-child {
    border-bottom: 0;
  }

  .time-table th,
  .time-table td {
    border-bottom: 0;
    padding: 8px 0;
  }

  .time-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    color: var(--muted);
  }

  .actions {
    flex-direction: column;
  }

  .button {
    width: 100%;
  }
}
