:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1b1f27;
  --muted: #5d6576;
  --border: #d9dde5;
  --accent: #4f6bed;
  --accent-soft: #e6eafd;
  --accent-text: #ffffff;
  --ok: #1f8a4c;
  --warn: #9a6200;
  --error: #c0392b;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(20 24 40 / 6%), 0 4px 16px rgb(20 24 40 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111318;
    --surface: #1a1d24;
    --surface-2: #232730;
    --text: #e7e9ee;
    --muted: #9aa2b3;
    --border: #2f3440;
    --accent: #7289ff;
    --accent-soft: #262d4d;
    --accent-text: #0e1120;
    --ok: #4cc27f;
    --warn: #e0a640;
    --error: #ff6b5e;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }
code { font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

.site-header, main, .site-footer {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 16px;
}

.site-header { padding-top: 32px; padding-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.brand svg { width: 32px; height: 32px; }
.brand svg path { fill: var(--accent); }
.brand svg .edges { fill: none; stroke: var(--surface); stroke-width: 2; stroke-linejoin: round; }
.tagline { margin: 4px 0 0; color: var(--muted); }

main { flex: 1; display: flex; flex-direction: column; gap: 16px; }

.notice {
  padding: 12px 16px;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
  color: var(--warn);
  background: var(--surface);
}

/* Drop zone */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 44px 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.dragging { border-color: var(--accent); background: var(--accent-soft); }
.dropzone svg { width: 40px; height: 40px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; margin-bottom: 6px; }
.dropzone strong { font-size: 1.15rem; }
.dropzone span { color: var(--muted); }
.dropzone .formats { font-size: 0.85rem; margin-top: 8px; }

/* File cards */
.file-list { display: flex; flex-direction: column; gap: 12px; }
.file-list:empty { display: none; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card-head { display: flex; align-items: center; gap: 12px; }
.file-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); font-size: 0.85rem; }

.badge {
  flex: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.badge:empty { display: none; }
.badge.muted { background: var(--surface-2); color: var(--muted); }

.status { margin: 10px 0 0; color: var(--muted); font-size: 0.92rem; }
.status.ok { color: var(--ok); }
.status.warn { color: var(--warn); }
.status.error { color: var(--error); }
.status.busy::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  vertical-align: -1px;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.options { margin-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.options[hidden] { display: none; }

.targets { border: 0; padding: 0; margin: 0; }
.targets legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.target-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }

button, select { font: inherit; color: inherit; }

.target {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.target strong { font-size: 1.05rem; }
.target small { color: var(--muted); }
.target:hover { border-color: var(--accent); }
.target[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.target[aria-pressed="true"] strong::after { content: " ✓"; color: var(--accent); }

.settings { display: flex; flex-wrap: wrap; gap: 12px 20px; }
.setting { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.setting[hidden] { display: none; }
.setting select {
  min-width: 180px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.92rem;
}

.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.primary, .ghost {
  padding: 9px 18px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.primary { border: 0; background: var(--accent); color: var(--accent-text); }
.ghost { border: 1px solid var(--border); background: transparent; }
.primary:disabled, .ghost:disabled, .target:disabled, select:disabled { opacity: 0.5; cursor: not-allowed; }
.primary:not(:disabled):hover { filter: brightness(1.08); }
.ghost:not(:disabled):hover { background: var(--surface-2); }

.icon.remove {
  flex: none;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.icon.remove:hover { background: var(--surface-2); color: var(--text); }

.results { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.results:empty { display: none; }
.results li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--accent-soft);
  font-weight: 600;
  text-decoration: none;
  word-break: break-all;
}
.download svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.result-size { color: var(--muted); font-size: 0.85rem; }

/* Viewer */
.viewer-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.viewer-panel[hidden] { display: none; }
.viewer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.viewer-head h2 { margin: 0; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-head .ghost { padding: 5px 12px; font-size: 0.85rem; }
.viewer { height: min(460px, 60vh); background: linear-gradient(var(--surface-2), var(--surface)); }
.viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }

.site-footer { padding-top: 32px; padding-bottom: 24px; color: var(--muted); font-size: 0.85rem; }
