:root {
  --bg: #f7f7f8;
  --fg: #1f2937;
  --muted: #6b7280;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-press: #1e40af;
  --ring: rgba(37, 99, 235, 0.35);
  --border: #e5e7eb;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --card: #0b1220;
    --primary: #93c5fd;
    --primary-press: #60a5fa;
    --ring: rgba(147, 197, 253, 0.35);
    --border: #1f2937;
  }
}

body.theme-dark {
  --bg: #111827;
  --fg: #e5e7eb;
  --muted: #9ca3af;
  --card: #0b1220;
  --primary: #93c5fd;
  --primary-press: #60a5fa;
  --ring: rgba(147, 197, 253, 0.35);
  --border: #1f2937;
}

body.theme-light {
  --bg: #f7f7f8;
  --fg: #1f2937;
  --muted: #6b7280;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-press: #1e40af;
  --ring: rgba(37, 99, 235, 0.35);
  --border: #e5e7eb;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family:
    Inter,
    system-ui,
    -apple-system,
    Segoe UI,
    Roboto,
    "Helvetica Neue",
    Arial,
    "Noto Sans",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.wrap {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.site-header__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.bmc {
  display: flex;
  justify-content: flex-end;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
}

.brand__logo {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: inline-block;
  background-color: transparent;
  background-image: -webkit-image-set(
    url("images/apple-touch-icon.png") type("image/png") 1x,
    url("images/apple-touch-icon.png") type("image/png") 2x
  );
  background-image: url("images/apple-touch-icon.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}

.header-note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.site-footer .wrap {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--muted);
}

.site-footer a {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.site-footer a:hover {
  text-decoration-thickness: 2px;
}

.site-footer a:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
  border-radius: 4px;
}

.card {
  width: min(760px, 100%);
  margin: 28px auto;
  padding: 24px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

h1 {
  margin: 0;
  font-size: clamp(28px, 3.8vw, 40px);
}

.lead {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.file-picker {
  display: inline-flex;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  margin-top: 18px;
  width: auto;
}

.file-picker:hover {
  opacity: 0.85;
}

.file-picker input {
  display: none;
}

.file-picker--drag-over {
  border-color: var(--primary);
  border-style: dashed;
  opacity: 1;
  background: color-mix(in srgb, var(--primary) 8%, var(--card));
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  display: grid;
  gap: 10px;
}

.file-list__empty {
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  padding: 14px;
}

.file-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.file-row__details {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.file-row__details strong {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-row__details span {
  color: var(--muted);
  font-size: 13px;
}

.file-row__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.range-row {
  margin-top: 18px;
  display: grid;
  gap: 8px;
}

.range-row label {
  font-weight: 600;
  font-size: 14px;
}

.range-row input {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg);
  font: inherit;
  padding: 10px 12px;
}

.range-mode {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

.range-mode legend {
  font-weight: 600;
  font-size: 14px;
  padding: 0 6px;
}

.range-mode label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.range-mode__hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.range-mode__hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.content {
  display: grid;
  gap: 16px;
  width: min(760px, 100%);
  margin: 0 auto 28px;
}

.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.section h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.section p {
  margin: 10px 0;
  line-height: 1.6;
}

.controls {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  padding: 8px 12px;
}

.btn--ghost:hover {
  opacity: 0.7;
}

.btn--ghost:active {
  opacity: 0.9;
}

#theme-toggle {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  line-height: 1;
  font-size: 20px;
  flex-shrink: 0;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn:focus-visible,
.download-link:focus-visible,
.file-picker input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ring);
}

.btn--primary {
  border-color: transparent;
  background: var(--primary);
  color: #fff;
}

.btn--primary:active {
  background: var(--primary-press);
}

.btn--success {
  border-color: transparent;
  background: #166534;
  color: #fff;
}

.btn--success:active {
  background: #14532d;
}

.btn--success:disabled {
  opacity: 0.45;
}

.btn--tiny {
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.status {
  display: block;
  margin-top: 18px;
  min-height: 24px;
  color: var(--muted);
}

.status[data-state="error"] {
  color: #dc2626;
}

.download-link {
  display: inline-flex;
  margin-top: 10px;
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.output-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.output-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.output-row .download-link {
  margin: 0;
}

@media (max-width: 640px) {
  .card {
    margin-top: 16px;
    padding: 18px;
  }

  .content {
    margin-bottom: 16px;
  }

  .file-row {
    flex-direction: column;
    align-items: stretch;
  }

  .file-row__actions {
    justify-content: flex-start;
  }
}
