:root {
  color-scheme: light;
  font-family: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  color: #172a24;
  background: #f5f7f4;
  --ink: #172a24;
  --muted: #4d6259;
  --green: #17604e;
  --green-dark: #0d493a;
  --line: #dce5dc;
  --white: #fff;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
a { color: inherit; }
button { cursor: pointer; }
h1, h2, p { margin: 0; }
:focus-visible { outline: 3px solid #ad661a; outline-offset: 3px; }
[id] { scroll-margin-top: 24px; }

.shell { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.site-header { background: #0d332c; color: var(--white); }
.header-inner, .footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 70px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  font-size: 0.98rem;
  font-weight: 700;
}
.brand-mark {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: #cbf2a5;
  color: #123c30;
  font-size: 1.12rem;
  font-weight: 800;
}
.site-header nav { display: flex; flex-wrap: wrap; gap: 1.4rem; }
.site-header nav a, .site-footer a:not(.brand) {
  font-size: 0.92rem;
  text-underline-offset: 4px;
}
.site-header nav a { color: #e5f3ec; text-decoration: none; }
.site-header nav a:hover, .tool-index a:hover { text-decoration: underline; }
.skip-link {
  position: fixed;
  z-index: 1;
  left: 1rem;
  top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background: var(--white);
  transform: translateY(-180%);
}
.skip-link:focus { transform: translateY(0); }

.hero {
  background: radial-gradient(ellipse at 90% 0%, #dbedcc, transparent 66%), #eaf3e7;
  border-bottom: 1px solid #dce9d9;
}
.hero-inner { padding-block: clamp(38px, 6vw, 72px) 46px; }
.hero-intro { max-width: 760px; }
h1 {
  font-size: clamp(2rem, 5.8vw, 4rem);
  font-weight: 750;
  letter-spacing: -0.05em;
  line-height: 1.03;
}
.hero-intro p {
  margin-top: 1rem;
  color: #39554a;
  font-size: clamp(1rem, 2.5vw, 1.16rem);
  line-height: 1.55;
}
.main-calculator {
  margin-top: 28px;
  padding: clamp(18px, 4vw, 30px);
  background: var(--white);
  border: 1px solid #d4e3d4;
  border-radius: 19px;
  box-shadow: 0 8px 22px #123c300b;
}
.equation {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: clamp(5px, 2vw, 24px);
}
.equation input { height: clamp(52px, 8vw, 66px); font-size: clamp(1rem, 3vw, 1.6rem); }
.operator {
  display: grid;
  align-items: center;
  min-height: clamp(52px, 8vw, 66px);
  white-space: nowrap;
  color: #3d6252;
  font-size: clamp(0.75rem, 2.4vw, 1.25rem);
  font-weight: 750;
}
.example { margin-top: 16px; color: var(--muted); font-size: 0.92rem; }
.example strong { margin-right: 0.42rem; color: var(--green-dark); }
.no-script { margin-top: 16px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(180px, 224px) minmax(0, 1fr);
  align-items: start;
  gap: 30px;
  padding-block: 36px 60px;
}
.tool-index {
  position: sticky;
  top: 20px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 12px;
}
.index-title {
  margin: 0 8px 8px;
  font-size: 1rem;
  font-weight: 700;
}
.tool-index a {
  display: block;
  padding: 8px;
  color: var(--muted);
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.3;
  text-decoration: none;
  text-underline-offset: 3px;
}
.tool-index a:hover { background: #eef5eb; color: var(--green-dark); }
.tools {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}
.wide { grid-column: 1 / -1; }
.tool-card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: clamp(18px, 3vw, 25px);
}
.tool-card:target, .formulas:target { scroll-margin-top: 24px; }
.tool-card:target { border-color: #79a889; }
h2 { font-size: clamp(1.25rem, 3vw, 1.56rem); line-height: 1.18; letter-spacing: -0.025em; }
.tool-card > p { margin: 7px 0 19px; color: var(--muted); line-height: 1.5; }
.tool-card form { margin-top: auto; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { display: block; min-width: 0; font-size: 0.9rem; font-weight: 650; }
input, select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  margin-top: 7px;
  padding: 10px 12px;
  color: var(--ink);
  background: #f7faf6;
  border: 1px solid #b8cabf;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
input::placeholder, textarea::placeholder { color: #637a70; opacity: 1; }
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: #a64136; }
textarea { resize: vertical; line-height: 1.4; }

.actions, .quick-rates { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.actions button {
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.93rem;
  font-weight: 680;
}
button[type="submit"] { background: var(--green); color: var(--white); }
button[type="submit"]:hover { background: var(--green-dark); }
button[type="reset"] { background: var(--white); color: var(--green-dark); border-color: #c7d8cd; }
button[type="reset"]:hover, .quick-rates button:hover { background: #e6f2e9; }
.quick-rates button {
  min-height: 38px;
  padding: 5px 11px;
  border: 1px solid #c5d9cb;
  border-radius: 7px;
  background: #f3f8f1;
  color: var(--green-dark);
  font-size: 0.88rem;
  font-weight: 650;
}
output { display: block; overflow-wrap: anywhere; }
output[data-state] {
  margin-top: 14px;
  padding: 12px 14px;
  background: #eaf5e9;
  color: var(--green-dark);
  border-radius: 8px;
  line-height: 1.45;
}
output[data-state="error"] { background: #fff0ed; color: #8b3029; }
.result-value { display: block; font-size: 1.15rem; }
.result-details { display: block; margin-top: 0.25rem; font-size: 0.9rem; }
.result-list { margin: 0; padding-left: 1.25em; }
.result-list li + li { margin-top: 0.3em; }

.formulas { padding: 17px 0 0; }
.formulas h2 { margin-bottom: 14px; }
.formulas details { border-bottom: 1px solid var(--line); }
.formulas summary {
  cursor: pointer;
  padding: 14px 6px;
  color: var(--green-dark);
  font-weight: 650;
}
.formulas p { padding: 0 6px 16px; line-height: 1.6; color: var(--muted); }
.site-footer { background: #e9efe8; border-top: 1px solid var(--line); }

@media (max-width: 850px) {
  .workspace { grid-template-columns: 1fr; gap: 18px; }
  .tool-index { position: static; }
  .tool-index nav { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; }
  .index-title { flex-basis: 100%; margin-bottom: 5px; }
}
@media (max-width: 550px) {
  .shell { width: calc(100% - 28px); }
  .header-inner, .footer-inner { min-height: 61px; }
  .site-header nav { gap: 0.65rem; }
  .site-header nav a, .site-footer a:not(.brand) { font-size: 0.82rem; }
  .brand { gap: 0.4rem; font-size: 0.86rem; }
  .brand-mark { width: 27px; height: 27px; }
  .tools { grid-template-columns: 1fr; gap: 14px; }
  .workspace { padding-block: 20px 36px; }
  .equation label { font-size: 0.76rem; }
  .equation input { padding-inline: 8px; }
  .fields { gap: 10px; }
}
