:root {
  color-scheme: light;
  --bg: #ffffff;
  --bg-alt: #f9fafb;
  --bg-soft: #f3f4f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #1f2937;
  --text-muted: #6b7280;
  --primary: #1c63ed;
  --primary-dark: #1557d6;
  --accent: #3b7eff;
  --good: #10b981;
  --danger: #ef4444;
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.06), 0 1px 2px -1px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.04);
  --radius: 8px;
  --radius-lg: 12px;
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.topbar a.brand { display: inline-flex; align-items: center; text-decoration: none; }
.topbar a.brand svg { height: 28px; width: auto; display: block; }
.topbar a.brand:focus-visible { outline: 2px solid var(--primary); outline-offset: 4px; border-radius: 4px; }
.topbar .pill {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 20px 64px;
  display: grid;
  gap: 24px;
}

header h1 {
  margin: 0 0 8px;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

header .sub {
  margin: 0;
  color: var(--text-muted);
  font-size: 1rem;
}

.form {
  display: grid;
  gap: 18px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text);
}

label > span {
  font-weight: 600;
  color: var(--text);
}

label em {
  color: var(--text-muted);
  font-style: normal;
  font-weight: 400;
  font-size: 0.8rem;
  margin-left: 4px;
}

select, textarea, input[type="range"], input[type="password"], input[type="file"] {
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

select:hover, textarea:hover, input[type="password"]:hover { border-color: var(--text-muted); }
select:focus, textarea:focus, input[type="password"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(28 99 237 / 0.12);
}

input[type="file"] { padding: 8px 12px; cursor: pointer; }
input[type="file"]::file-selector-button {
  background: var(--bg-alt); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 12px; margin-right: 12px; cursor: pointer; font-family: inherit;
  font-weight: 500; font-size: 0.85rem;
  transition: background 120ms ease, border-color 120ms ease;
}
input[type="file"]::file-selector-button:hover { background: var(--bg-soft); border-color: var(--primary); color: var(--primary-dark); }

.label-row { display: inline-flex; align-items: center; gap: 8px; }

.info {
  width: 18px; height: 18px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--bg-alt); color: var(--text-muted);
  font-size: 0.7rem; font-weight: 700; line-height: 1;
  cursor: pointer; padding: 0; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}
.info:hover, .info:focus-visible { color: var(--primary); border-color: var(--primary); outline: none; }
.info[aria-expanded="true"] {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

.tooltip {
  display: none;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.55;
}
.tooltip code {
  background: var(--bg-soft);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.82rem;
  color: var(--primary-dark);
  font-weight: 500;
}
.tooltip.open { display: block; }

.inline {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  margin-top: 4px;
  display: flex;
  color: var(--text-muted);
  font-weight: 400;
}
.inline input[type="checkbox"] { margin: 0; accent-color: var(--primary); }

.file-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.file-list li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
}
.file-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.file-size { color: var(--text-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.file-remove {
  background: transparent; color: var(--text-muted); border: none;
  cursor: pointer; font-size: 1.2rem; line-height: 1; padding: 0 4px;
  border-radius: 4px;
  transition: color 120ms ease, background 120ms ease;
}
.file-remove:hover { color: var(--danger); background: rgb(239 68 68 / 0.08); }

.output-help {
  margin-top: 8px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 0.85rem;
}
.output-help summary { cursor: pointer; color: var(--primary-dark); font-weight: 600; }
.output-help[open] summary { margin-bottom: 8px; }
.output-help p { margin: 6px 0; color: var(--text); }
.output-help ul { margin: 6px 0; padding-left: 20px; color: var(--text); }
.output-help li { margin: 3px 0; }
.output-help strong { color: var(--primary-dark); font-weight: 600; }
textarea { resize: vertical; min-height: 60px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }

.slider input[type="range"] {
  padding: 0;
  height: 6px;
  appearance: none;
  background: var(--bg-soft);
  border: none;
  border-radius: 3px;
}
.slider input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 1px 3px rgb(28 99 237 / 0.3);
}
.slider input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary); cursor: pointer; border: 2px solid #fff;
}
.slider span strong { color: var(--primary-dark); font-variant-numeric: tabular-nums; font-weight: 700; }

.result {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  background: var(--bg-alt);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  letter-spacing: -0.01em;
}

.metric.total {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: 1px solid var(--primary);
  color: #ffffff;
}
.metric.total .metric-label { color: rgb(255 255 255 / 0.85); }
.metric.total .metric-value { color: #ffffff; }

.status {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.2em;
}
.status.error { color: var(--danger); font-weight: 500; }
.status.loading { color: var(--primary-dark); font-weight: 500; }

.footer {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 40px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.footer a {
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 600;
}
.footer a:hover { text-decoration: underline; color: var(--primary); }
