:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #687382;
  --paper: #fffaf3;
  --panel: #ffffff;
  --line: #d8e0e8;
  --teal: #0b7f83;
  --teal-dark: #07585c;
  --coral: #e96543;
  --gold: #f3c762;
  --shadow: 0 24px 70px rgba(23, 33, 43, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 16%, rgba(243, 199, 98, 0.42), transparent 28rem),
    linear-gradient(135deg, #f6efe4 0%, #e8f1f1 48%, #f7f7f4 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1080px, calc(100% - 32px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  align-items: center;
  gap: 28px;
  padding: 48px 0;
}

.calculator-panel,
.summary-panel {
  border: 1px solid rgba(216, 224, 232, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.calculator-panel {
  padding: clamp(24px, 4vw, 42px);
}

.summary-panel {
  padding: clamp(24px, 4vw, 38px);
  background: #17212b;
  color: #ffffff;
}

.intro {
  margin-bottom: 30px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-panel .eyebrow {
  color: var(--gold);
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 4.65rem);
  line-height: 0.96;
  letter-spacing: 0;
}

.lede {
  max-width: 34rem;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.calculator-form {
  display: grid;
  gap: 22px;
}

.field-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

label,
legend {
  display: block;
  margin: 0 0 10px;
  color: #344152;
  font-size: 0.92rem;
  font-weight: 800;
}

.money-input,
.percent-input {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 0 16px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.money-input:focus-within,
.percent-input:focus-within,
.stepper:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(11, 127, 131, 0.14);
}

.money-input span,
.percent-input span {
  color: var(--muted);
  font-weight: 800;
}

input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 750;
}

input::placeholder {
  color: #a4adba;
}

.tip-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.tip-option,
.reset-button,
.stepper button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 850;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.tip-option:hover,
.reset-button:hover,
.stepper button:hover {
  transform: translateY(-1px);
  border-color: var(--teal);
}

.tip-option.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.custom-tip-label {
  margin-top: 4px;
}

.split-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.hint {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stepper {
  display: grid;
  grid-template-columns: 46px minmax(64px, 86px) 46px;
  align-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.stepper input {
  height: 48px;
  text-align: center;
}

.stepper button {
  min-height: 48px;
  border: 0;
  border-radius: 0;
  background: #f1f6f6;
  color: var(--teal-dark);
  font-size: 1.25rem;
}

.reset-button {
  width: 100%;
  background: #fff7ef;
  color: #8f331d;
  border-color: #f0c8b8;
}

.summary-header {
  padding-bottom: 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

#grand-total {
  display: block;
  overflow-wrap: anywhere;
  font-size: clamp(2.8rem, 8vw, 5.5rem);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0;
}

.summary-grid {
  display: grid;
  gap: 14px;
  margin: 26px 0;
}

.result-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.result-tile span {
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.92rem;
  font-weight: 750;
}

.result-tile strong {
  color: #ffffff;
  font-size: clamp(1.2rem, 4vw, 1.65rem);
  text-align: right;
  overflow-wrap: anywhere;
}

.summary-note {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.55;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    align-items: start;
    padding: 28px 0;
  }

  .summary-panel {
    order: -1;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1080px);
  }

  .calculator-panel,
  .summary-panel {
    padding: 22px;
  }

  .tip-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .split-row,
  .result-tile {
    align-items: stretch;
    flex-direction: column;
  }

  .stepper {
    width: 100%;
    grid-template-columns: 48px minmax(0, 1fr) 48px;
  }
}
