:root {
  --bg: #f3efe6;
  --ink: #1d1916;
  --muted: #5e564e;
  --line: #e3d9cc;
  --card: rgba(255, 252, 247, 0.94);
  --accent: #9d3415;
  --accent-dark: #7c270f;
  --focus: #e7b89a;
  --ok: #1d6b45;
  --sans: "PingFang TC", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei",
    "WenQuanYi Micro Hei", sans-serif;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at 0% -10%, #f8e6d2 0%, transparent 58%),
    radial-gradient(800px 420px at 100% 0%, #e4efe7 0%, transparent 52%),
    var(--bg);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

.wrap {
  width: min(1080px, calc(100% - 32px));
  margin-inline: auto;
}

.site-header {
  padding: 28px 0 8px;
}

.domain {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 2.4vw, 2.15rem);
  font-weight: 750;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.stamp {
  display: grid;
  place-items: center;
  flex: none;
  width: 3.25rem;
  height: 3.25rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  transform: rotate(-8deg);
}

.lede {
  max-width: 42rem;
  margin: 12px 0 0;
  color: var(--muted);
}

main {
  padding-bottom: 48px;
}

.workspace {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.workspace > * {
  min-width: 0;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 14px 36px rgba(80, 48, 20, 0.05);
}

.form-panel,
.results,
.notes {
  padding: 18px;
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  min-inline-size: 0;
}

legend,
.field-label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.checks {
  display: grid;
  gap: 8px;
}

.check {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
}

.check input {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.2rem;
  accent-color: var(--accent);
  flex: none;
}

.check-copy strong,
.check-copy span {
  display: block;
}

.check-copy strong {
  font-weight: 700;
}

.check-copy span {
  color: var(--muted);
  font-size: 0.92rem;
}

.field {
  margin-top: 16px;
}

input[type="number"] {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: inherit;
  font: inherit;
}

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

.segment {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segment-item {
  position: relative;
  display: block;
  cursor: pointer;
}

.segment-item input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.segment-item span {
  pointer-events: none;
}

.segment-item span {
  display: grid;
  place-items: center;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-weight: 700;
}

.segment-item input:checked + span {
  border-color: var(--accent);
  background: #fbf1ea;
  color: var(--accent-dark);
}

.segment-item input:focus-visible + span,
input[type="number"]:focus-visible,
.primary:focus-visible,
.ghost:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.primary {
  width: 100%;
  min-height: 48px;
  margin-top: 16px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: #fffaf7;
  font: inherit;
  font-weight: 750;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.primary:hover {
  background: var(--accent-dark);
}

.error {
  margin: 10px 0 0;
  color: var(--accent-dark);
  font-weight: 700;
}

.results-head {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 12px;
  align-items: center;
  justify-content: space-between;
}

.summary {
  margin: 0;
  font-weight: 700;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ghost {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.ghost:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.ghost:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.empty {
  margin: 28px 0 12px;
  color: var(--muted);
}

.scroll-hint {
  display: none;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

@media (max-width: 899px) {
  .scroll-hint:not([hidden]) {
    display: block;
  }
}

.table-wrap {
  margin-top: 8px;
  max-width: 100%;
  max-height: min(64vh, 640px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: #fbf7f1;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.notes {
  margin-top: 16px;
}

.notes h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.notes p,
.notes li {
  color: var(--ink);
}

.notes p {
  margin: 0 0 10px;
}

.notes ul {
  margin: 0;
  padding-left: 1.2rem;
}

.notes a {
  color: var(--accent-dark);
}

details {
  margin-top: 12px;
}

summary {
  cursor: pointer;
  font-weight: 700;
}

.source-list {
  margin-top: 10px;
}

.source-list li + li {
  margin-top: 6px;
}

@media (min-width: 900px) {
  .workspace {
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    align-items: start;
  }

  .form-panel {
    position: sticky;
    top: 16px;
  }
}

@media (max-width: 599px) {
  .wrap {
    width: min(100% - 24px, 1080px);
  }

  .actions {
    width: 100%;
  }

  .ghost {
    flex: 1 1 auto;
  }
}
