:root {
  --paper: #f3eee4;
  --card: #fffaf2;
  --ink: #1c1915;
  --muted: #5c564c;
  --line: #d9cfc0;
  --accent: #0f5f54;
  --accent-hover: #0a4a41;
  --accent-soft: #e4f1ee;
  --warn: #8a4b12;
  --warn-bg: #f8ecd8;
  --error: #8a1f1f;
  --error-bg: #f8e4e1;
  --info-bg: #e8f0ee;
  --shadow: 0 10px 30px rgba(48, 38, 22, 0.08);
  --radius: 16px;
  --focus: 0 0 0 3px rgba(15, 95, 84, 0.35);
}

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

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(15, 95, 84, 0.08), transparent 28rem),
    var(--paper);
  line-height: 1.6;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  padding: 0.4rem 0.7rem;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  z-index: 10;
}

.skip:focus {
  top: 0.75rem;
}

.page {
  width: min(68rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 3.5rem;
}

.hero {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.eyebrow {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  letter-spacing: -0.03em;
}

.lead,
.privacy,
.hint,
.preview-note,
.source {
  margin: 0;
  color: var(--muted);
}

.privacy {
  max-width: 44rem;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.file-field {
  display: inline-flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: min(100%, 16rem);
}

button,
input[type="file"] {
  font: inherit;
}

input[type="file"] {
  max-width: 100%;
}

input[type="file"]:focus-visible,
button:focus-visible,
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

button {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 0.55rem 1rem;
  min-height: 2.75rem;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.options {
  display: grid;
  gap: 0.7rem;
  margin-top: 1.1rem;
}

.option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 0.7rem;
  align-items: start;
}

.option input {
  width: 1.15rem;
  height: 1.15rem;
  margin: 0.2rem 0 0;
}

.option .label {
  font-weight: 650;
}

.option .hint {
  grid-column: 2;
  font-size: 0.92rem;
}

.source {
  margin-top: 1rem;
}

#message {
  margin: 0;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
}

#message[data-kind="info"] {
  background: var(--info-bg);
  border-color: #c6ddd8;
}

#message[data-kind="warn"] {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: #e4d0aa;
}

#message[data-kind="error"] {
  background: var(--error-bg);
  color: var(--error);
  border-color: #e3b8b4;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  background: var(--accent-soft);
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.stat-label {
  color: var(--muted);
  font-size: 0.85rem;
}

.stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.preview-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

h2 {
  margin: 0;
  font-size: 1.15rem;
}

.table-scroll {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-height: min(28rem, 70vh);
  background: #fff;
}

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

th,
td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 16rem;
}

thead th {
  position: sticky;
  top: 0;
  background: #f7f1e6;
  z-index: 1;
  font-weight: 650;
}

tbody th {
  background: #fbf7ef;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

tbody tr:hover td,
tbody tr:hover th {
  background: #f3f8f6;
}

.preview-note {
  margin-top: 0.75rem;
  font-size: 0.92rem;
}

footer {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 640px) {
  .page {
    width: min(68rem, calc(100% - 1.25rem));
    padding-top: 1.25rem;
  }

  .panel {
    padding: 1rem;
  }

  button,
  .file-field {
    width: 100%;
  }
}
