:root {
  color-scheme: light;
  --paper: #f3efe5;
  --paper-deep: #e7dfd0;
  --ink: #171715;
  --muted: #6c675e;
  --iron: #242321;
  --iron-soft: #34322f;
  --ivory: #fffaf0;
  --red: #c94b35;
  --red-dark: #a93726;
  --line: #c9c0b1;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 25%, rgb(23 23 21 / 3%) 0 1px, transparent 1.5px) 0 0 / 21px 21px,
    radial-gradient(circle at 80% 70%, rgb(201 75 53 / 3%) 0 1px, transparent 1.4px) 0 0 / 29px 29px,
    var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.page-shell {
  width: min(100% - 36px, 920px);
  margin: 0 auto;
  padding: clamp(28px, 6vw, 64px) 0;
}

.masthead { margin-bottom: clamp(30px, 5vw, 50px); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 34px;
  color: inherit;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
}

.brand-mark, .mini-mark {
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ivory);
  background: var(--red);
  font-family: var(--sans);
  font-weight: 700;
  line-height: 1;
}

.brand-mark { width: 30px; height: 30px; font-size: 1.3rem; }

.eyebrow {
  margin: 0 0 13px;
  color: var(--red-dark);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .18em;
  text-transform: uppercase;
}

h1 {
  max-width: 680px;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.4rem, 7vw, 4.75rem);
  font-weight: 400;
  letter-spacing: -.045em;
  line-height: .97;
}

h1 em { color: var(--muted); font-weight: 400; }

.intro { margin: 20px 0 0; color: var(--muted); font-size: 1rem; }

.calculator-layout {
  display: grid;
  grid-template-columns: minmax(0, .88fr) minmax(360px, 1.12fr);
  gap: clamp(38px, 7vw, 78px);
  align-items: start;
}

.controls { min-width: 0; }

.control-group {
  min-width: 0;
  margin: 0;
  padding: 0 0 24px;
  border: 0;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

label, legend {
  margin-bottom: 10px;
  font-size: .82rem;
  font-weight: 750;
  letter-spacing: .06em;
}

legend { padding: 0; }

.hint { color: var(--muted); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }

.money-input, .percent-input {
  display: flex;
  align-items: center;
  min-height: 54px;
  border: 1px solid var(--ink);
  border-radius: 7px;
  background: rgb(255 250 240 / 55%);
  transition: border-color 150ms, box-shadow 150ms;
}

.money-input:focus-within, .percent-input:focus-within {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgb(201 75 53 / 18%);
}

.money-input > span { padding-left: 16px; color: var(--muted); font-family: var(--serif); font-size: 1.35rem; }

input {
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 7px;
  color: var(--ink);
  background: transparent;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.money-input input { height: 52px; padding: 0 14px 0 8px; font-family: var(--serif); font-size: 1.45rem; }

.tip-options { display: grid; grid-template-columns: repeat(4, minmax(60px, 1fr)); gap: 7px; }

.tip-button, .stepper button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  transition: transform 130ms, color 150ms, border-color 150ms, background 150ms;
}

.tip-button:hover, .stepper button:hover:not(:disabled) { border-color: var(--ink); }
.tip-button:active, .stepper button:active:not(:disabled) { transform: translateY(1px); }

.tip-button.is-selected {
  border-color: var(--red);
  color: var(--ivory);
  background: var(--red);
  font-weight: 750;
}

.custom-tip { margin-top: 12px; }
.custom-tip label { display: block; }
.percent-input { width: 150px; }
.percent-input input { height: 52px; padding: 0 8px 0 14px; text-align: right; }
.percent-input span { padding-right: 14px; color: var(--muted); }

.stepper { display: grid; grid-template-columns: 52px minmax(60px, 1fr) 52px; gap: 7px; }
.stepper button { font-size: 1.45rem; }
.stepper button:disabled { cursor: not-allowed; opacity: .35; }
.stepper input { height: 48px; border: 1px solid var(--ink); text-align: center; font-size: 1.05rem; }
.stepper input:focus-visible { border-color: var(--red); box-shadow: 0 0 0 3px rgb(201 75 53 / 18%); }

.field-error { min-height: 18px; margin: 6px 0 0; color: var(--red-dark); font-size: .75rem; line-height: 1.4; }

.reset-button {
  min-height: 44px;
  margin-top: -4px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  color: var(--muted);
  background: transparent;
  font-size: .79rem;
  cursor: pointer;
}

button:focus-visible, a:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

.result-area { min-width: 0; }

.result-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  min-width: 0;
  padding: clamp(26px, 5vw, 42px);
  border: 1px solid #161513;
  border-radius: 9px;
  color: var(--ivory);
  background:
    radial-gradient(circle at 20% 30%, rgb(255 255 255 / 4%) 0 1px, transparent 1.5px) 0 0 / 17px 17px,
    linear-gradient(145deg, var(--iron-soft), var(--iron));
  box-shadow: 0 22px 55px rgb(23 23 21 / 18%);
}

.result-card::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgb(255 250 240 / 8%);
  border-radius: 5px;
  pointer-events: none;
}

.card-topline {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--serif);
  font-size: .88rem;
  font-weight: 700;
}

.mini-mark { width: 23px; height: 23px; font-size: 1rem; }
.result-context { min-height: 20px; margin: 24px 0 28px; color: #c9c2b7; font-size: .75rem; line-height: 1.5; }
.share-block { padding-bottom: 29px; border-bottom: 1px solid rgb(255 250 240 / 18%); }
.result-label { margin: 0 0 4px; color: #d8d0c4; font-size: .75rem; letter-spacing: .11em; text-transform: uppercase; }
.share-amount {
  overflow-wrap: anywhere;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(3.3rem, 9vw, 5.2rem);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.055em;
  line-height: 1;
}

.breakdown { margin: 25px 0 0; font-size: .82rem; }
.breakdown div { display: flex; justify-content: space-between; gap: 18px; padding: 7px 0; }
.breakdown dt { color: #c9c2b7; }
.breakdown dd { margin: 0; font-variant-numeric: tabular-nums; }
.breakdown .grand-total { margin-top: 8px; padding-top: 15px; border-top: 1px solid rgb(255 250 240 / 18%); font-weight: 750; }
.breakdown .grand-total dt { color: var(--ivory); }
.card-foot { margin: 28px 0 0; color: #8f8980; font-family: var(--serif); font-size: .74rem; font-style: italic; text-align: center; }
.rounding-note { margin: 12px 0 0; color: var(--muted); font-size: .72rem; text-align: center; }
.noscript { padding: 15px; border: 1px solid var(--red); }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 760px) {
  .brand { margin-bottom: 27px; }
  .calculator-layout { grid-template-columns: 1fr; gap: 32px; }
  .controls { max-width: none; }
  .result-card { max-width: 520px; margin-inline: auto; }
}

@media (max-width: 410px) {
  .page-shell { width: min(100% - 24px, 920px); }
  .tip-options { grid-template-columns: repeat(2, 1fr); }
  .result-card { padding: 28px 24px; }
  .share-amount { font-size: clamp(2.9rem, 17vw, 4.3rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

