:root {
  color-scheme: light;
  --canvas: #f5f8f5;
  --paper: #fff;
  --ink: #182a28;
  --muted: #475b55;
  --green: #075c49;
  --green-dark: #064638;
  --green-soft: #e7f5ed;
  --card-hover: #edf6ef;
  --hero-intro: #e0f3e9;
  --line: #cbdcd3;
  --control: #5e746c;
  --focus: #174aab;
  --warn: #984413;
  --warn-bg: #fff2e7;
  --error: #9f2d33;
  --error-bg: #fff1f1;
  font-family: system-ui, "Microsoft JhengHei", sans-serif;
  font-size: 100%;
  line-height: 1.65;
  color: var(--ink);
  background: var(--canvas);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
main { flex: 1; }
a { color: var(--green); text-underline-offset: .2em; }
a:hover { color: var(--green-dark); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 2px var(--paper); }
.skip-link { position: fixed; z-index: 2; inset: 8px auto auto 8px; transform: translateY(calc(-100% - 16px)); padding: 10px 16px; border-radius: 8px; background: var(--paper); }
.skip-link:focus { transform: none; }
.shell { width: min(calc(100% - 32px), 1080px); margin-inline: auto; }
p { margin: 0 0 1rem; }
h1, h2, h3 { line-height: 1.28; margin: 0 0 .7em; overflow-wrap: anywhere; }
h1 { font-size: clamp(1.75rem, 4.5vw, 2.5rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.375rem, 3vw, 1.75rem); letter-spacing: -.02em; }
h3 { font-size: clamp(1.125rem, 2.3vw, 1.25rem); }
ul { padding-inline-start: 1.35em; }

.site-header { background: var(--paper); border-bottom: 1px solid var(--line); }
.header-inner, .footer-inner { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; column-gap: 20px; }
.brand, .main-nav, .main-nav a, .site-footer nav, .site-footer a { display: flex; align-items: center; }
.brand { gap: 9px; color: var(--ink); min-height: 48px; font-weight: 750; text-decoration: none; }
.brand-mark { background: var(--green); width: 25px; height: 25px; border-radius: 7px; display: grid; place-items: center; }
.brand-mark::before { content: ''; width: 11px; height: 11px; background: linear-gradient(var(--paper), var(--paper)) center / 100% 2px no-repeat, linear-gradient(var(--paper), var(--paper)) center / 2px 100% no-repeat; }
.main-nav, .site-footer nav { flex-wrap: wrap; column-gap: 16px; }
.main-nav a, .site-footer a { min-height: 44px; font-weight: 650; font-size: .875rem; }
.main-nav a:not(:hover), .site-footer a:not(:hover) { text-decoration-thickness: 1px; }
.site-footer { margin-top: 3rem; border-top: 1px solid var(--line); background: var(--paper); }
.footer-inner { padding-block: 14px; }
.footer-inner p { margin: 0; font-weight: 700; }
.footer-inner p span { color: var(--muted); font-weight: 500; font-size: .875rem; }

.hero { position: relative; isolation: isolate; overflow: hidden; display: grid; align-items: center; min-height: 214px; margin-block: 28px 32px; padding: clamp(24px, 5vw, 60px); border-radius: 18px; color: var(--paper); background: var(--green-dark); }
.hero h1 { font-size: clamp(1.9rem, 6vw, 3.6rem); margin-bottom: .24em; }
.hero .intro { color: var(--hero-intro); }
.hero-pattern { display: none; }
.intro { color: var(--muted); max-width: 42rem; margin: 0; font-size: clamp(1rem, 2.4vw, 1.125rem); }
.tools > section + section { margin-top: 28px; }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 0; padding: 0; list-style: none; }
.tool-card { display: block; height: 100%; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); text-decoration: none; }
.tool-card:hover { border-color: var(--control); background: var(--card-hover); }
.tool-card:hover .tool-name { text-decoration: underline; }
.tool-name { display: flex; justify-content: space-between; gap: 8px; color: var(--green); font-weight: 750; font-size: 1.125rem; overflow-wrap: anywhere; }
.arrow { flex: none; }
.tool-summary { display: block; margin-top: 6px; color: var(--muted); }

.breadcrumbs ol { display: flex; align-items: center; flex-wrap: wrap; list-style: none; padding: 0; margin: 7px 0 0; font-size: .875rem; color: var(--muted); }
.breadcrumbs a { display: inline-flex; align-items: center; min-height: 44px; }
.breadcrumbs li + li::before { content: ''; display: inline-block; height: 6px; width: 6px; margin: 0 12px 2px; transform: rotate(45deg); border: solid var(--control); border-width: 1px 1px 0 0; }
.page-heading { padding-block: 12px 24px; }
.page-heading h1 { margin-bottom: .4em; }
.calculator { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 14px; }
.form-card, .result-card { min-width: 0; padding: clamp(16px, 3vw, 24px); background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.form-card h2, .result-card h2 { font-size: 1.375rem; }
.result-card { background: var(--green-soft); border-block-start: 4px solid var(--green); }
.result-placeholder, .result-note { color: var(--muted); margin: 0; }
.result-label { color: var(--ink); margin-bottom: 4px; font-weight: 650; }
.result-value { color: var(--green); font-weight: 800; font-size: clamp(2rem, 5vw, 2.75rem); line-height: 1.18; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result-details, .rules { margin: 0 0 16px; }
.result-details div, .rules div { display: flex; justify-content: space-between; column-gap: 12px; flex-wrap: wrap; border-block-start: 1px solid var(--line); padding-block: 6px; }
.result-details dd, .rules dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; max-width: 100%; }
.result-warning, .notice { color: var(--warn); background: var(--warn-bg); border-inline-start: 3px solid currentColor; padding: 8px 12px; }
.result-warning { margin-bottom: 0; }

form { display: grid; gap: 14px; }
.field { min-width: 0; }
.field label, legend { display: block; margin-bottom: 5px; font-weight: 700; }
.field input, .field select, button { font: inherit; min-height: 44px; border: 1px solid var(--control); border-radius: 8px; padding: 8px 10px; }
.field input, .field select { display: block; width: 100%; min-width: 0; color: var(--ink); background: var(--paper); }
.field input::placeholder { color: var(--muted); opacity: 1; }
.field input[aria-invalid], .field select[aria-invalid] { color: var(--ink); border-color: var(--error); background: var(--error-bg); }
.hint, .error { font-size: .875rem; margin: 4px 0 0; }
.hint { color: var(--muted); }
.error { color: var(--error); font-weight: 650; }
fieldset { min-width: 0; margin: 0; padding: 8px 12px 12px; border: 1px solid var(--line); border-radius: 8px; }
fieldset .field + .field { margin-top: 12px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.field-row .field + .field { margin-top: 0; }
.check-field { display: flex; align-items: center; gap: 8px; }
.check-field label { display: flex; align-items: center; min-height: 44px; flex: 1; cursor: pointer; }
.check-field input { inline-size: 22px; block-size: 22px; margin: 4px; accent-color: var(--green); cursor: pointer; }
button { width: 100%; color: var(--paper); background: var(--green); border: 1px solid var(--green); font-weight: 750; cursor: pointer; }
button:hover { background: var(--green-dark); border-color: var(--green-dark); }
button:disabled { color: var(--muted); background: var(--canvas); border-color: var(--line); cursor: default; }

.section-links { display: flex; flex-wrap: wrap; gap: 0 18px; padding-block: 12px; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.section-links a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 650; }
.prose { max-width: 42rem; overflow-wrap: anywhere; }
.info { padding-top: 12px; }
.home-guide { margin-top: 2rem; }
.info h2:not(:first-child), .prose section + section, .related { margin-top: 28px; }
.example { margin-bottom: 12px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); }
.example p { margin-bottom: 0; }
.formula { padding: 12px 16px; background: var(--green-soft); color: var(--green); border-radius: 8px; font-weight: 650; }
.faq-question { margin: 1em 0 .3em; }
#sources li + li { margin-top: 6px; }
#sources + .notice { margin-top: 20px; }

@media (min-width: 36rem) {
  .header-inner { min-height: 60px; }
  .tool-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 48rem) {
  .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .hero { min-height: 260px; grid-template-columns: 2fr 1fr; }
  .hero-pattern { display: block; position: absolute; z-index: -1; inset: 0 0 0 67%; overflow: hidden; background: repeating-linear-gradient(0deg, #c7fbde26 0 1px, transparent 1px 24px), repeating-linear-gradient(90deg, #c7fbde26 0 1px, transparent 1px 24px), radial-gradient(ellipse at 90% 80%, #368965, transparent 75%); mask-image: linear-gradient(to right, transparent, #000 46%); }
  .hero-pattern::after { content: ''; position: absolute; width: 220px; height: 220px; top: 20px; right: 24px; border: 1px solid #d2ffe183; border-radius: 50%; box-shadow: inset 0 0 0 32px #c7fbde11, 0 0 0 18px #c7fbde11; }
  .calculator { grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 20px; }
  .page-heading { padding-bottom: 32px; }
}
