:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #243532;
  background: #f4f8f6;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(ellipse at 50% 0%, #e6f1ec 0%, transparent 65%); }
main { width: min(100% - 32px, 480px); margin: 0 auto; padding: 48px 0 32px; }
.page-header { text-align: center; margin-bottom: 28px; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; margin: 0 auto 18px; border: 1px solid #c7ded6; border-radius: 15px; color: #126b63; background: #e5f1eb; }
.brand-mark svg { width: 31px; height: 31px; }
h1 { font-size: clamp(1.65rem, 6.5vw, 2rem); letter-spacing: -0.055em; line-height: 1.2; margin: 0 0 12px; font-weight: 750; }
.page-header p { margin: 0; color: #566963; font-size: 0.96rem; line-height: 1.6; }
.calculator { background: #fff; border: 1px solid #dce7e1; border-radius: 24px; box-shadow: 0 12px 40px #244d3610, 0 2px 6px #244d3605; overflow: hidden; }
.bill-section { padding: 27px 28px 5px; }
.bill-section label { display: block; text-align: center; font-size: 0.88rem; font-weight: 650; margin-bottom: 12px; }
.bill-box { display: flex; justify-content: center; padding: 16px 18px; cursor: text; border: 1.5px solid #b6cec6; border-radius: 12px; background: #fcfefd; transition: border-color 120ms, box-shadow 120ms; }
.bill-box:focus-within { border-color: #126b63; box-shadow: 0 0 0 3px #126b6324; }
.bill-box:has([aria-invalid="true"]) { border-color: #a23228; }
.bill-entry { display: inline-grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; column-gap: 0.08em; min-width: 0; max-width: 100%; font-size: clamp(1.8rem, 8vw, 2.6rem); font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }
.currency { grid-column: 1; grid-row: 1; color: #688078; pointer-events: none; }
/* The invisible text sizes the input to its contents, keeping $ beside it.
   Both occupy the same grid cell; long amounts stay within the bill box. */
.bill-measure { grid-column: 2; grid-row: 1; visibility: hidden; white-space: pre; pointer-events: none; }
#bill { grid-column: 2; grid-row: 1; display: block; width: 0; min-width: 100%; padding: 0; border: 0; background: transparent; color: #243532; font: inherit; letter-spacing: inherit; text-align: left; outline: none; }
#bill::placeholder, .bill-measure.is-placeholder { font-size: inherit; font-weight: inherit; letter-spacing: inherit; }
#bill::placeholder { color: #60776e; opacity: 1; }
.error { color: #a23228; font-size: 0.8rem; line-height: 1.4; min-height: 1.4em; margin: 8px 0 0; text-align: center; }
.results { padding: 0 12px 12px; }
.result-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; align-items: center; gap: 10px; padding: 20px 16px; }
.result-row + .result-row { border-top: 1px solid #eaf0ec; }
.result-text { min-width: 0; text-align: center; }
.result-label { display: block; font-size: 0.81rem; font-weight: 550; color: #566963; margin-bottom: 5px; }
output { display: block; font-size: clamp(1.6rem, 7vw, 2rem); font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.045em; line-height: 1.2; overflow-wrap: anywhere; }
.step-button { display: grid; place-items: center; width: 48px; height: 48px; padding: 0; background: #f0f6f3; border: 1px solid #cfdfd7; border-radius: 12px; color: #126b63; cursor: pointer; touch-action: manipulation; transition: background 100ms, transform 100ms, border-color 100ms; -webkit-tap-highlight-color: transparent; }
.triangle { width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent; }
.triangle.down { border-top: 13px solid currentColor; }
.triangle.up { border-bottom: 13px solid currentColor; }
@media (hover: hover) { .step-button:hover:enabled { background: #dbece4; border-color: #82b5a6; } }
.step-button:focus-visible { outline: 3px solid #126b63; outline-offset: 3px; }
.step-button:active:enabled { background: #badccd; transform: scale(0.94); }
.step-button:disabled { opacity: 0.38; cursor: default; }
.total-row { background: #126b63; border-radius: 15px; margin-top: 4px; padding-top: 24px; padding-bottom: 24px; color: #fff; }
.result-row.total-row { border-top: 0; }
.total-row .result-label { color: #d5eee6; }
.total-row output { font-size: clamp(1.85rem, 8vw, 2.4rem); font-weight: 700; }
.total-row .step-button { background: #ffffff12; border-color: #83b4a8; color: #fff; }
.total-row .step-button:focus-visible { outline-color: #fff; }
@media (hover: hover) { .total-row .step-button:hover:enabled { background: #ffffff2b; border-color: #fff; } }
.total-row .step-button:active:enabled { background: #ffffff45; }
.total-row .step-button:disabled { opacity: 0.42; }
.explanation { text-align: center; padding: 26px 18px 0; }
.explanation h2 { margin: 0 0 9px; font-size: 0.88rem; font-weight: 650; }
.explanation p { margin: 0; font-size: 0.82rem; line-height: 1.65; color: #566963; }
.explanation .privacy-note { margin-top: 18px; font-size: 0.75rem; color: #62776e; }
.share-section { margin: 24px 18px 0; text-align: center; }
.share-button { min-height: 46px; padding: 11px 20px; border: 1px solid #cfdfd7; border-radius: 12px; background: #f0f6f3; color: #126b63; font: inherit; font-size: 0.85rem; font-weight: 650; cursor: pointer; touch-action: manipulation; }
@media (hover: hover) { .share-button:hover:enabled { background: #dbece4; border-color: #82b5a6; } }
.share-button:focus-visible, #share-url:focus-visible { outline: 3px solid #126b63; outline-offset: 3px; }
.share-button:active:enabled { background: #badccd; }
.share-button:disabled { opacity: 0.5; cursor: default; }
#share-fallback p, .share-status, #manual-copy label { color: #566963; font-size: 0.82rem; line-height: 1.6; }
.share-status { margin: 10px 0 0; }
.share-status:empty { margin: 0; }
#manual-copy label { display: block; margin-top: 10px; }
#share-url { width: 100%; min-width: 0; margin-top: 6px; padding: 12px 8px; border: 1px solid #b6cec6; border-radius: 8px; background: #fcfefd; color: #243532; font: inherit; font-size: 0.85rem; text-align: center; }
.noscript { color: #a23228; text-align: center; }
@media (max-width: 360px) {
  main { width: calc(100% - 24px); padding-top: 28px; }
  .bill-section { padding-right: 18px; padding-left: 18px; }
  .result-row { padding-right: 8px; padding-left: 8px; gap: 6px; }
  .desktop-break { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; } }
