:root {
  --bg: #120d0b;
  --card: #1e1512;
  --card-raised: #251a16;
  --border: #33241f;
  --accent: #7a1f2b;
  --accent-hover: #9b2a3a;
  --glow: rgba(155, 42, 58, 0.35);
  --text: #efe6e1;
  --muted: #a8968d;
  --ok: #b9c99a;
  --warn: #e0a76a;
  --error: #e7838e;

  --radius: 14px;
  --font: 'Bricolage Grotesque', 'Iowan Old Style', Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  color-scheme: dark;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(122, 31, 43, 0.22), transparent 60%),
    radial-gradient(800px 400px at -10% 110%, rgba(122, 31, 43, 0.1), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  font-optical-sizing: auto;
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent-hover);
  outline-offset: 3px;
}

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 28px 16px 40px;
}

/* Masthead */

.masthead {
  margin-bottom: 28px;
}

.brand {
  margin: 0 0 28px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.brand-dot {
  color: var(--accent-hover);
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(2.2rem, 9vw, 4.2rem);
  line-height: 0.98;
  font-weight: 800;
  letter-spacing: -0.035em;
  font-variation-settings: 'opsz' 96;
}

h1 em {
  font-style: normal;
  color: var(--muted);
  font-weight: 500;
}

.lede {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  font-size: 1.05rem;
}

/* Cards & settings */

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

.settings {
  display: grid;
  gap: 20px;
  padding: 18px;
  margin-bottom: 14px;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.field label {
  font-weight: 600;
}

.hint,
.range-hints {
  color: var(--muted);
  font-size: 0.85rem;
}

.range-hints {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
}

output {
  font-size: 1.1rem;
  font-weight: 600;
  min-width: 3ch;
  text-align: right;
}

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 28px;
  background: transparent;
  cursor: pointer;
  --fill: 80%;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--border) var(--fill));
}

input[type='range']::-moz-range-track {
  height: 6px;
  border-radius: 99px;
  background: var(--border);
}

input[type='range']::-moz-range-progress {
  height: 6px;
  border-radius: 99px;
  background: var(--accent);
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  background: var(--text);
  border: 4px solid var(--accent);
  transition: transform 0.15s;
}

input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  border: 4px solid var(--accent);
}

input[type='range']:active::-webkit-slider-thumb {
  transform: scale(1.12);
}

input[type='number'] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: 500 1rem var(--mono);
}

input[type='number']::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

input[type='number']:focus {
  outline: none;
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 3px var(--glow);
}

/* Dropzone */

.dropzone {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 44px 20px;
  text-align: center;
  background:
    repeating-linear-gradient(-45deg, transparent 0 14px, rgba(51, 36, 31, 0.35) 14px 15px),
    var(--card);
  border: 2px dashed var(--border);
  border-radius: calc(var(--radius) + 4px);
  cursor: pointer;
  transition:
    border-color 0.2s,
    box-shadow 0.25s,
    transform 0.2s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.dropzone:hover {
  border-color: var(--accent);
}

.dropzone.is-active {
  border-color: var(--accent-hover);
  border-style: solid;
  box-shadow:
    0 0 0 4px var(--glow),
    0 0 60px var(--glow);
  transform: scale(1.01);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  fill: none;
  stroke: var(--accent-hover);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.25s;
}

.dropzone.is-active .dropzone-icon {
  transform: translateY(-4px);
}

.dropzone-title {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.dropzone-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.only-touch {
  display: none;
}

@media (hover: none) and (pointer: coarse) {
  .only-pointer {
    display: none;
  }
  .only-touch {
    display: inline;
  }
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font: 600 0.95rem var(--font);
  text-decoration: none;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s,
    opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover {
  border-color: var(--accent-hover);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-small {
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.875rem;
}

/* Results */

.results {
  margin-top: 28px;
}

.results-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.results-bar h2 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

.summary {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.summary strong {
  color: var(--ok);
  font-weight: 600;
}

.results-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.results-actions .btn-primary {
  flex: 1 1 100%;
  order: -1;
}

.results-actions .btn-ghost {
  flex: 1 1 0;
}

.file-head {
  display: none;
}

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

/* Mobile: each file is a small card. */
.file {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px 12px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  animation: slide-in 0.25s ease-out;
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.file-name {
  grid-column: 1 / -1;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.file-size,
.file-out,
.file-saving {
  font-size: 0.9rem;
}

.file-size::before,
.file-out::before,
.file-saving::before {
  content: attr(data-label);
  display: block;
  font-family: var(--font);
  font-size: 0.75rem;
  color: var(--muted);
}

.file-saving.is-good {
  color: var(--ok);
}

.file-saving.is-bad {
  color: var(--warn);
}

.file-status {
  grid-column: 1 / 3;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: var(--muted);
  min-width: 0;
}

.status-text {
  overflow-wrap: anywhere;
}

.status-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.file[data-status='working'] .status-dot {
  background: var(--accent-hover);
  animation: pulse 1s ease-in-out infinite;
}

.file[data-status='done'] .status-dot {
  background: var(--ok);
}

.file[data-status='done'] .file-status {
  color: var(--text);
}

.file[data-status='error'] .status-dot {
  background: var(--error);
}

.file[data-status='error'] .file-status {
  color: var(--error);
}

@keyframes pulse {
  50% {
    opacity: 0.3;
    transform: scale(0.7);
  }
}

.file-download {
  grid-column: 3;
  justify-self: end;
}

.footer {
  margin-top: 48px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* Desktop */

@media (min-width: 760px) {
  .page {
    padding: 56px 32px 56px;
  }

  .masthead {
    margin-bottom: 36px;
  }

  .settings {
    grid-template-columns: 1.6fr 1fr;
    gap: 32px;
    padding: 22px 26px;
  }

  .dropzone {
    padding: 72px 32px;
  }

  .dropzone-title {
    font-size: 1.6rem;
  }

  .results-actions {
    width: auto;
  }

  .results-actions .btn,
  .results-actions .btn-primary {
    flex: none;
    order: 0;
  }

  .file-head,
  .file {
    grid-template-columns: minmax(0, 1fr) 90px 90px 104px 200px 96px;
    gap: 16px;
    align-items: center;
  }

  .file-head {
    display: grid;
    padding: 0 18px 8px;
    color: var(--muted);
    font-size: 0.8rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
  }

  .file-list {
    gap: 6px;
  }

  .file {
    padding: 12px 18px;
    border-radius: 10px;
  }

  .file-name {
    grid-column: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .file-size::before,
  .file-out::before,
  .file-saving::before {
    display: none;
  }

  .file-status,
  .file-download {
    grid-column: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
