:root {
  --bg: #efe6d6;
  --bg-deep: #e4d8c4;
  --ink: #1d2a24;
  --muted: #5b6a61;
  --card: #fffaf1;
  --card-edge: #d8cdb8;
  --accent: #1e5f74;
  --accent-soft: #d5e8ed;
  --warm: #c56a27;
  --warm-soft: #f6e3cf;
  --danger: #8a3b2d;
  --shadow: 0 10px 30px rgba(48, 38, 22, 0.08);
  --radius: 18px;
  --max: 72rem;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.7), transparent 32%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 20;
  padding: 0.6rem 0.9rem;
  background: var(--ink);
  color: #fff;
  border-radius: 999px;
}

.skip-link:focus {
  top: 1rem;
}

.site-header,
.site-main,
.site-footer {
  width: min(var(--max), calc(100% - 1.5rem));
  margin-inline: auto;
}

.site-header {
  padding: 1.25rem 0 0.75rem;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: fit-content;
  margin: 0 0 0.15rem;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
}

.site-brand:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.site-brand .site-logo {
  display: block;
  width: 2.625rem;
  height: 2.625rem;
  flex: 0 0 2.625rem;
  border-radius: 12px;
}

.site-brand .eyebrow {
  margin: 0;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.7rem, 5vw, 2.4rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
}

.lede {
  max-width: 40rem;
  margin: 0.7rem 0 0;
  color: var(--muted);
}

.lede.tight {
  margin-top: 0;
}

.tool-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 0;
}

.tool-nav a,
.text-btn,
.more-tools > summary {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--card-edge);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  min-height: 2.5rem;
  padding: 0.4rem 0.95rem;
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.tool-nav a {
  padding: 0.4rem 0.7rem;
}

.tool-nav a[aria-current="page"],
.tool-nav a.is-current {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.soon,
.now {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.soon {
  background: var(--warm-soft);
  color: #7a4314;
}

.tool-nav a[aria-current="page"] .soon,
.tool-nav a.is-current .soon {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.now {
  background: var(--accent-soft);
  color: var(--accent);
}

.more-tools {
  margin: 0.7rem 0 0;
}

.more-tools > summary {
  list-style: none;
  width: fit-content;
  background: var(--warm-soft);
  border-color: #e3c19a;
}

.more-tools > summary::-webkit-details-marker {
  display: none;
}

.more-tools-list {
  list-style: none;
  margin: 0.65rem 0 0;
  padding: 0.7rem 0.85rem;
  display: grid;
  gap: 0.45rem;
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.more-tools-list a {
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}

.more-tools-list a:hover {
  color: var(--accent);
}

.layout {
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

.summary-stack {
  display: contents;
}

.totals-wrap {
  order: 1;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 0.65rem 0 0.85rem;
  background: linear-gradient(180deg, rgba(239, 230, 214, 0.96), rgba(239, 230, 214, 0.88));
  backdrop-filter: blur(10px);
}

.controls {
  order: 2;
}

.breakdown {
  order: 3;
}

.totals {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
}

.total-card,
.panel,
.help-card,
.disclaimer,
.soon-card {
  background: var(--card);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.total-card {
  padding: 1rem 1.05rem 1.05rem;
}

.total-card.primary {
  background: linear-gradient(160deg, #1e5f74 0%, #144454 100%);
  color: #f6f1e6;
  border-color: transparent;
}

.total-card .label,
.breakdown h2 {
  margin: 0;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.total-card .value {
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.total-card .value strong {
  font-size: clamp(2rem, 8vw, 3rem);
  letter-spacing: -0.04em;
  line-height: 1;
}

.total-card .value span,
.total-card .hint {
  color: inherit;
  opacity: 0.8;
}

.total-card .hint,
.save-state {
  margin: 0.45rem 0 0;
  font-size: 0.88rem;
}

.ah-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.ah-grid.tank-days .total-card:last-child {
  grid-column: 1 / -1;
}

.from-water .next-tool-link {
  margin-top: 0.7rem;
}

.panel {
  padding: 1rem;
}

.loads-panel,
.habits-panel {
  margin-top: 0.85rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.panel h2,
.help-card h2,
.soon-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
}

.field-heading {
  margin: 1.1rem 0 0.45rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-hint {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.field > span:not(.field-control),
.field > .label-text {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.field-control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.field-control input,
.field-control select {
  width: 100%;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.field-control em {
  font-style: normal;
  color: var(--muted);
  min-width: 1.4rem;
}

.field-control em.unit-wide {
  min-width: 3.4rem;
}

.loss-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  margin-top: 0.9rem;
  padding: 0.8rem 0.9rem;
  background: var(--accent-soft);
  border-radius: 14px;
}

.loss-toggle input {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.15rem;
  accent-color: var(--accent);
}

.loss-toggle strong {
  display: block;
}

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

.preset-row,
.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.preset-row button,
.choice-row button,
.add-btn,
.print-btn {
  appearance: none;
  border: 1px solid var(--card-edge);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  min-height: 2.75rem;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.preset-row button {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 100%;
  padding: 0.6rem 1.05rem;
  text-align: left;
  line-height: 1.3;
  text-wrap: pretty;
  white-space: normal;
}

.preset-sublabel {
  display: block;
  font-size: 0.82em;
  font-weight: 600;
  opacity: 0.82;
}

.preset-row button.is-selected,
.preset-row button[aria-pressed="true"],
.choice-row button.is-selected,
.choice-row button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.preset-row button.is-selected span,
.preset-row button[aria-pressed="true"] span,
.choice-row button.is-selected span,
.choice-row button[aria-pressed="true"] span {
  color: inherit;
}

.print-btn {
  background: var(--warm-soft);
  border-color: #e3c19a;
}

.add-btn {
  width: 100%;
  margin-top: 0.85rem;
  background: var(--warm-soft);
  border-color: #e3c19a;
}

.preset-row button:focus-visible,
.choice-row button:focus-visible,
.add-btn:focus-visible,
.print-btn:focus-visible,
.tool-nav a:focus-visible,
.more-tools > summary:focus-visible,
.faq-list summary:focus-visible,
input:focus-visible {
  outline: 3px solid #f0b25a;
  outline-offset: 2px;
}

.breakdown {
  margin-top: 1rem;
}

.breakdown ol {
  list-style: none;
  margin: 0.7rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.breakdown-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.95rem;
}

.breakdown-bar {
  height: 0.45rem;
  margin-top: 0.3rem;
  background: #efe4d3;
  border-radius: 999px;
  overflow: hidden;
}

.breakdown-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.help-grid,
.faq-card,
.disclaimer,
.next-tool,
.soon-card {
  position: relative;
  z-index: 1;
}

.help-grid {
  display: grid;
  gap: 0.75rem;
  margin: 1rem 0;
}

.help-card,
.disclaimer,
.soon-card {
  padding: 1rem 1.05rem;
}

.help-card ol,
.help-card ul,
.soon-card ul {
  margin: 0.4rem 0 0;
  padding-left: 1.15rem;
}

.faq-card,
.soon-card {
  margin: 0 0 1rem;
}

.faq-list {
  margin: 0.55rem 0 0;
  display: grid;
  gap: 0.55rem;
}

.faq-list details {
  background: #fff;
  border: 1px solid var(--card-edge);
  border-radius: 12px;
  padding: 0.7rem 0.9rem;
}

.faq-list summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-weight: 750;
}

.faq-list summary::-webkit-details-marker {
  display: none;
}

.faq-list summary::after {
  content: "";
  flex: 0 0 0.55rem;
  width: 0.55rem;
  height: 0.55rem;
  margin-top: -4px;
  border-right: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.faq-list details[open] > summary::after {
  margin-top: 4px;
  transform: rotate(-135deg);
}

.faq-list details p {
  margin: 0.45rem 0 0.15rem;
  color: var(--muted);
}

.faq-list a,
.help-card a:not(.add-btn) {
  color: var(--accent);
  font-weight: 650;
}

.print-only {
  display: none;
}

.disclaimer {
  background: #f7efe3;
  border-color: #e2d1b4;
}

.disclaimer p,
.soon-card p {
  margin: 0.4rem 0 0;
}

.save-state {
  color: var(--muted);
}

.next-tool {
  margin: 1rem 0 0;
}

.next-tool p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.next-tool-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 12rem;
  margin-top: 0.85rem;
  margin-right: 0.55rem;
  text-decoration: none;
}

.site-footer {
  padding: 0 0 2rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.site-footer p {
  margin: 0.35rem 0 0;
}

.rotate-gate {
  display: none;
}

.rotate-gate-card {
  width: min(28rem, 100%);
  padding: 1.35rem 1.25rem 1.4rem;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--card-edge);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.rotate-gate-icon {
  display: block;
  width: 3.4rem;
  height: 3.4rem;
  margin: 0 auto 0.7rem;
  color: var(--accent);
}

.rotate-gate-card h2 {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.rotate-gate-card p {
  margin: 0.55rem 0 0;
  color: var(--muted);
}

@media (orientation: landscape) and (max-height: 540px) and (max-width: 1000px) {
  html,
  body {
    overflow: hidden;
    height: 100%;
    overscroll-behavior: none;
    touch-action: none;
  }

  .skip-link,
  .site-header,
  .site-main,
  .site-footer {
    pointer-events: none;
    user-select: none;
  }

  .rotate-gate {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(20, 42, 48, 0.92);
    text-align: center;
  }
}

@media (min-width: 640px) {
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

  .totals {
    grid-template-columns: 1.3fr 1fr;
  }

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

  .ah-grid.tank-days {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-height: 699px) {
  .totals-wrap {
    position: static;
    z-index: auto;
    padding: 0.4rem 0 0.55rem;
  }

  .totals {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1fr);
  }

  .ah-grid {
    display: contents;
  }

  .totals:has(.tank-days) {
    grid-template-columns: 1fr;
  }

  .ah-grid.tank-days {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .total-card {
    padding: 0.7rem 0.8rem 0.75rem;
  }

  .total-card .value strong {
    font-size: clamp(1.35rem, 5.5vw, 2.1rem);
  }
}

@media (min-width: 768px) and (min-height: 700px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(16.5rem, 20rem) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
  }

  .summary-stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: sticky;
    top: 0.75rem;
    z-index: 1;
    align-self: start;
    max-height: calc(100vh - 1.5rem);
    max-height: calc(100dvh - 1.5rem);
    min-height: 0;
    overflow: auto;
  }

  .totals-wrap {
    order: unset;
    position: static;
    z-index: auto;
    padding: 0;
    background: none;
    backdrop-filter: none;
    flex: 0 0 auto;
  }

  .controls {
    order: unset;
    position: relative;
    z-index: 2;
    min-width: 0;
  }

  .breakdown {
    order: unset;
    margin-top: 0;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .breakdown ol {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .totals,
  .ah-grid {
    grid-template-columns: 1fr;
  }

  .ah-grid.tank-days .total-card:last-child {
    grid-column: auto;
  }
}

@media (min-width: 960px) and (min-height: 700px) {
  .layout {
    grid-template-columns: minmax(18rem, 22rem) minmax(0, 1fr);
  }
}

@media print {
  :root {
    color-scheme: light;
  }

  @page {
    margin: 12mm;
  }

  * {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  html {
    scroll-behavior: auto;
  }

  body {
    background: #fff;
    color: #111;
    font-size: 12pt;
    line-height: 1.4;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .no-print {
    display: none !important;
  }

  .print-only {
    display: block;
  }

  .print-meta {
    margin: 0.4rem 0 0;
    color: #444;
    font-size: 10pt;
  }

  .site-header,
  .site-main,
  .site-footer {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  .site-header {
    padding: 0 0 0.6rem;
  }

  .site-header h1 {
    font-size: 20pt;
  }

  .summary-stack,
  .totals-wrap,
  .controls,
  .breakdown {
    display: block;
    order: unset;
    position: static;
    max-height: none;
    overflow: visible;
  }

  .totals-wrap {
    padding: 0;
    background: none;
    backdrop-filter: none;
  }

  .layout,
  .totals,
  .ah-grid,
  .help-grid {
    display: block;
  }

  .breakdown ol {
    overflow: visible;
    max-height: none;
  }

  .total-card,
  .panel,
  .disclaimer {
    break-inside: avoid;
    box-shadow: none;
    background: #fff;
    border: 1px solid #bbb;
    border-radius: 0;
    margin: 0 0 0.7rem;
    padding: 0.65rem 0.75rem;
  }

  .total-card.primary {
    background: #fff;
    color: #111;
    border-color: #bbb;
  }

  .total-card .value strong {
    font-size: 18pt;
  }

  .total-card .value span,
  .total-card .hint {
    opacity: 1;
    color: #444;
  }

  .breakdown-bar {
    background: #e6e6e6;
  }

  .breakdown-bar span {
    background: #333;
  }

  .disclaimer {
    background: #fff;
    border-color: #bbb;
  }
}
