:root {
  color-scheme: light dark;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1b1b1a;
  --muted: #6b6b66;
  --border: #dddcd7;
  --accent: #1f5eff;
  --accent-text: #ffffff;
  --ok: #1d7a46;
  --ok-bg: #e3f3e9;
  --warn: #8a5a00;
  --warn-bg: #fdf0d5;
  --error: #b42318;
  --error-bg: #fde7e5;
  --neutral-bg: #ececea;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #1f1f1e;
    --text: #ececea;
    --muted: #a0a09a;
    --border: #353533;
    --accent: #6c95ff;
    --accent-text: #0b0b0b;
    --ok: #7fd3a1;
    --ok-bg: #173322;
    --warn: #f0c46b;
    --warn-bg: #3a2c0d;
    --error: #ff9a8f;
    --error-bg: #3d1714;
    --neutral-bg: #2b2b29;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 16px 64px;
}

h1 {
  margin: 0;
  font-size: 1.6rem;
}

header p {
  margin: 4px 0 24px;
}

.muted {
  color: var(--muted);
}

code {
  font-size: 0.9em;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 48px 16px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

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

.dropzone.active {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

.toolbar {
  margin: 24px 0;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  border: 0;
}

.segmented legend {
  margin-bottom: 8px;
  padding: 0;
  font-weight: 600;
}

.segmented label {
  cursor: pointer;
}

.segmented input {
  position: absolute;
  opacity: 0;
}

.segmented span {
  display: block;
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.segmented label:first-of-type span {
  border-radius: var(--radius) 0 0 var(--radius);
}

.segmented label:last-of-type span {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.segmented label + label span {
  border-left: 0;
}

.segmented input:checked + span {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.segmented input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hint {
  margin: 8px 0 0;
  font-size: 0.9rem;
}

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.summary p {
  margin: 0;
  font-weight: 600;
}

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

button {
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  cursor: pointer;
}

button.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

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

.file-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.file {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
}

.file + .file {
  border-top: 1px solid var(--border);
}

.thumb {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: repeating-conic-gradient(#e6e6e3 0 25%, #ffffff 0 50%) 0 0 / 12px 12px;
}

.thumb img {
  max-width: 40px;
  max-height: 40px;
}

.info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.sizes {
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.badge.ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.badge.warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.error {
  background: var(--error-bg);
  color: var(--error);
}

.badge.neutral {
  background: var(--neutral-bg);
  color: var(--muted);
}

@media (max-width: 600px) {
  .file {
    grid-template-columns: 48px minmax(0, 1fr) auto;
  }

  .badge {
    grid-column: 2 / 4;
    grid-row: 2;
    justify-self: start;
  }
}
