:root {
  --bg: #f6f1ea;
  --bg-soft: #fbf8f2;
  --ink: #1f1d1a;
  --muted: #6f6a61;
  --accent: #2f6f55;
  --accent-2: #d98b5f;
  --card: rgba(255, 255, 255, 0.92);
  --border: #e3dbd1;
  --shadow: 0 18px 45px rgba(31, 29, 26, 0.12);
  --radius: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Segoe UI", "Noto Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, rgba(47, 111, 85, 0.14), transparent 45%),
    radial-gradient(circle at 85% 10%, rgba(217, 139, 95, 0.16), transparent 40%),
    var(--bg);
  min-height: 100vh;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.18),
    rgba(255, 255, 255, 0.18) 1px,
    transparent 1px,
    transparent 12px
  );
  opacity: 0.4;
}

h1,
h2,
h3 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif;
  letter-spacing: -0.01em;
  margin: 0 0 0.6rem 0;
}

p {
  margin: 0 0 1rem 0;
  line-height: 1.6;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

main {
  max-width: 1100px;
  margin: 0 auto 4rem;
  padding: 0 1.5rem;
}

.hero {
  padding: 3.5rem 1.5rem 2rem;
}

.hero-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.hero-top {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.eyebrow {
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin-bottom: 0.8rem;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.lang-switch label {
  font-weight: 600;
}

.lang-switch select {
  min-width: 140px;
}

.lead {
  font-size: 1.05rem;
  max-width: 680px;
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.tabs {
  display: inline-flex;
  gap: 0.5rem;
  padding: 0.4rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 1.6rem;
}

.tab-button {
  border: none;
  background: transparent;
  padding: 0.55rem 1.2rem;
  border-radius: 999px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-button.is-active {
  background: var(--accent);
  color: white;
}

.tab-panel {
  display: none;
  animation: rise 0.5s ease both;
}

.tab-panel.is-active {
  display: block;
}

.panel-grid {
  display: grid;
  gap: 1.5rem;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.6rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  animation: rise 0.7s ease both;
  animation-delay: calc(var(--order, 0) * 0.08s);
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(47, 111, 85, 0.06), transparent 55%);
  opacity: 0.6;
  pointer-events: none;
}

.card > * {
  position: relative;
  z-index: 1;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.form-grid {
  display: grid;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.field.inline {
  min-width: 220px;
}

.field label {
  font-size: 0.92rem;
  font-weight: 600;
}

input,
select,
button {
  font-family: inherit;
  font-size: 1rem;
}

input,
select {
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid #d5cdc4;
  background: white;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid rgba(47, 111, 85, 0.35);
  border-color: var(--accent);
}

.details-card {
  margin-top: 1.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid #e1d9cf;
  background: rgba(255, 255, 255, 0.75);
  padding: 0.6rem 1rem 1rem;
}

.details-card summary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.4rem 0;
}

.advanced-grid {
  display: grid;
  gap: 1.5rem;
  margin-top: 1rem;
}

.section-block h3 {
  margin-bottom: 0.8rem;
}

.field-grid {
  display: grid;
  gap: 0.9rem;
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.6rem;
  align-items: center;
}

.table-head {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.table-label {
  font-weight: 600;
  color: var(--muted);
}

.top-space {
  margin-top: 1rem;
}

.summary-card {
  position: relative;
}

.result-row {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  padding: 0.6rem 0;
  border-bottom: 1px dashed #e4ddd3;
  font-size: 0.98rem;
}

.result-row strong {
  font-weight: 700;
}

.result-row:last-of-type {
  border-bottom: none;
}

.unit {
  margin-left: 0.35rem;
  color: var(--muted);
}

.compare-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.4rem;
}

.leaderboard-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.4rem;
}

.leaderboard-table {
  overflow-x: auto;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 0.6fr 2.4fr 1.2fr 1fr;
  gap: 0.8rem;
  align-items: center;
  padding: 0.6rem 0.2rem;
  border-bottom: 1px dashed #e4ddd3;
  font-size: 0.95rem;
  min-width: 500px;
}

.leaderboard-row span:nth-child(3),
.leaderboard-row span:nth-child(4) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.leaderboard-row span:first-child {
  color: var(--muted);
  font-weight: 600;
}

.leaderboard-head {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.leaderboard-row.is-best {
  background: rgba(47, 111, 85, 0.12);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.6rem;
}

.leaderboard-row.leaderboard-empty {
  grid-template-columns: 1fr;
  border-bottom: none;
  font-style: italic;
  color: var(--muted);
}

.leaderboard-note {
  margin-top: 1rem;
}

.compare-grid {
  display: grid;
  gap: 1.4rem;
}

.option-card {
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid #e5ded4;
  background: rgba(255, 255, 255, 0.78);
}

.option-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.diff-card {
  margin-top: 1.4rem;
  padding: 1.2rem;
  border-radius: var(--radius-sm);
  background: rgba(47, 111, 85, 0.12);
}

.note,
.hint,
.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.small {
  font-size: 0.84rem;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.4rem;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(47, 111, 85, 0.2);
}

.btn.secondary {
  background: rgba(47, 111, 85, 0.12);
  color: var(--accent);
}

.source-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.5rem;
  display: grid;
  gap: 0.6rem;
}

.notice {
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: rgba(217, 139, 95, 0.12);
}

.footer {
  padding: 0 1.5rem 3rem;
  text-align: center;
  color: var(--muted);
}

.is-hidden {
  display: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 900px) {
  .panel-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  }

  .summary-card {
    position: sticky;
    top: 1.6rem;
    align-self: start;
  }

  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .compare-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .tabs {
    width: 100%;
    justify-content: center;
  }

  .tab-button {
    flex: 1;
  }

  .meta-strip {
    flex-direction: column;
  }

  .leaderboard-table {
    overflow-x: visible;
  }

  .leaderboard-head {
    display: none;
  }

  .leaderboard-row {
    grid-template-columns: 1fr;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.8rem;
    margin-bottom: 0.8rem;
    background: rgba(255, 255, 255, 0.78);
    border-bottom: none;
  }

  .leaderboard-row span {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.8rem;
    text-align: left;
  }

  .leaderboard-row span::before {
    content: attr(data-label);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
  }

  .leaderboard-row span:nth-child(3),
  .leaderboard-row span:nth-child(4) {
    text-align: left;
  }

  .leaderboard-row.is-best {
    border-color: rgba(47, 111, 85, 0.35);
    background: rgba(47, 111, 85, 0.12);
  }

  .leaderboard-row.leaderboard-empty {
    border: 1px dashed var(--border);
    margin-bottom: 0;
    padding: 0.9rem;
  }
}
