:root {
  color-scheme: light;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --subtle: #86868b;
  --paper: #f5f5f7;
  --panel: #ffffff;
  --panel-soft: rgba(255, 255, 255, 0.86);
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --blue: #0071e3;
  --blue-dark: #005bb5;
  --amber: #fff4c2;
  --amber-line: #d6a900;
  --danger: #b42318;
  --shadow: 0 20px 48px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: "SF Pro TC", "SF Pro Display", "PingFang TC", "Microsoft JhengHei", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

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

.app-shell {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 20px 16px 38px;
}

.hero {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 52px 10px 28px;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  max-width: 820px;
  font-size: clamp(2.35rem, 7vw, 5.2rem);
  font-weight: 800;
}

h2 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
  font-weight: 760;
}

.hero-copy {
  max-width: 650px;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.65;
}

.status-pill {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.lookup-panel,
.results-section,
.detail-section details,
.calc-strip {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--panel-soft);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.lookup-panel {
  padding: 22px;
}

.field-group label,
.number-field span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border-radius: 8px;
  background: #e9e9ee;
}

.segmented button,
.ghost-button,
.solid-button,
.step-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 760;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.segmented button {
  background: transparent;
  color: var(--muted);
}

.segmented button[aria-checked="true"] {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.13);
}

.segmented button:active,
.ghost-button:active,
.solid-button:active,
.step-button:active {
  transform: scale(0.985);
}

.input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.number-field {
  display: block;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #ffffff;
}

.number-field input {
  width: 100%;
  min-height: 62px;
  padding: 10px 12px;
  border: 1.5px solid var(--amber-line);
  border-radius: 8px;
  outline: 0;
  background: var(--amber);
  color: var(--ink);
  font-size: 1.7rem;
  font-weight: 800;
  text-align: center;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.number-field input:focus {
  border-color: var(--blue);
  background: #fff8d8;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.16);
}

.number-field small {
  display: block;
  min-height: 20px;
  margin-top: 10px;
  color: var(--subtle);
  font-size: 0.78rem;
  line-height: 1.45;
}

.input-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.step-button {
  background: #f5f5f7;
  color: var(--blue);
  font-size: 1.06rem;
}

.step-button:hover {
  background: #eeeeF3;
}

.tool-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.ghost-button {
  min-width: 88px;
  padding: 0 16px;
  background: #f5f5f7;
  color: var(--blue);
}

.ghost-button:hover {
  background: #eeeeF3;
}

.calc-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 14px;
  overflow: hidden;
}

.calc-strip div {
  padding: 18px 12px;
  border-right: 1px solid var(--line-soft);
  text-align: center;
}

.calc-strip div:last-child {
  border-right: 0;
}

.calc-strip span {
  display: block;
  min-height: 20px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.calc-strip strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 820;
  line-height: 1;
}

.primary-metric {
  background: #1d1d1f;
}

.primary-metric span,
.primary-metric strong {
  color: #ffffff;
}

.results-section {
  margin-top: 14px;
  padding: 22px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.solid-button {
  min-width: 82px;
  padding: 0 16px;
  background: var(--blue);
  color: #ffffff;
}

.solid-button:hover {
  background: var(--blue-dark);
}

.warning {
  margin-top: 14px;
  padding: 13px 14px;
  border: 1px solid #ffd8d3;
  border-radius: 8px;
  background: #fff1ef;
  color: var(--danger);
  font-weight: 760;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.result-card {
  min-height: 142px;
  padding: 16px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #ffffff;
}

.result-card h3 {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
  font-weight: 760;
  line-height: 1.35;
}

.result-value {
  display: flex;
  align-items: baseline;
  gap: 5px;
  margin-top: 12px;
  color: var(--ink);
}

.result-value strong {
  font-size: clamp(2.2rem, 5vw, 3.35rem);
  font-weight: 820;
  line-height: 0.95;
}

.result-value span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 760;
}

.result-note {
  margin-top: 12px;
  color: var(--subtle);
  font-size: 0.79rem;
  line-height: 1.42;
}

.detail-section {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

details {
  padding: 0;
}

summary {
  min-height: 50px;
  padding: 15px 18px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 760;
}

.detail-body {
  padding: 0 18px 18px;
  color: var(--muted);
  line-height: 1.65;
}

.detail-body p {
  margin: 0 0 8px;
}

.table-wrap {
  overflow-x: auto;
  padding: 0 12px 16px;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 10px 11px;
  border: 1px solid var(--line-soft);
  vertical-align: top;
  text-align: left;
  line-height: 1.45;
}

th {
  background: #f5f5f7;
  color: var(--ink);
  font-weight: 760;
  white-space: nowrap;
}

.history-list {
  display: grid;
  gap: 8px;
  padding: 0 18px 18px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 11px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: left;
}

.history-item strong {
  color: var(--ink);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 5;
  transform: translate(-50%, 18px);
  opacity: 0;
  max-width: calc(100vw - 28px);
  padding: 11px 15px;
  border-radius: 999px;
  background: rgba(29, 29, 31, 0.92);
  color: #ffffff;
  font-weight: 760;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  padding: 28px 10px 4px;
  color: var(--subtle);
  font-size: 0.86rem;
  font-weight: 700;
  text-align: center;
}

.site-footer div {
  position: relative;
}

.site-footer div:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -10px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #c7c7cc;
  transform: translateY(-50%);
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px 10px 30px;
  }

  .hero {
    padding: 38px 6px 22px;
  }

  .lookup-panel,
  .results-section {
    padding: 16px;
  }

  .input-grid,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .result-card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    min-height: 96px;
  }

  .result-value {
    justify-content: flex-end;
    margin-top: 0;
  }

  .result-note {
    grid-column: 1 / -1;
  }
}

@media (max-width: 430px) {
  .segmented {
    grid-template-columns: 1fr;
  }

  .calc-strip {
    grid-template-columns: 1fr;
  }

  .calc-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
  }

  .calc-strip div:last-child {
    border-bottom: 0;
  }

  .tool-row {
    justify-content: stretch;
  }

  .ghost-button {
    width: 100%;
  }

  .history-item {
    grid-template-columns: 1fr;
  }

  .site-footer {
    display: grid;
    gap: 6px;
  }

  .site-footer div::after {
    display: none;
  }
}
