:root {
  --bg: #14171c;
  --panel: #1b1f26;
  --panel-2: #222731;
  --line: #2e3542;
  --text: #dde3ec;
  --muted: #8f9bad;
  --accent: #ffcf6b;
  --accent-dim: #6b5628;
  --ok: #78c48a;
  --bad: #e88b7d;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
}

header {
  padding: 18px 20px 10px;
  border-bottom: 1px solid var(--line);
}
header h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: .5px;
  font-weight: 650;
}
header h1 span { color: var(--accent); }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

main {
  display: grid;
  grid-template-columns: minmax(330px, 420px) 1fr;
  gap: 16px;
  padding: 16px 20px 24px;
  align-items: start;
}
@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

/* ---------------------------------------------------------------- dropzone */

.drop {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.drop:hover, .drop:focus-visible { border-color: var(--accent); outline: none; }
.drop.over { border-color: var(--accent); background: rgba(255, 207, 107, .07); }
.drop strong { font-weight: 600; }
.drop span { color: var(--muted); font-size: 13px; }

/* ------------------------------------------------------------------- files */

.files { list-style: none; margin: 12px 0 0; padding: 0; }
.files:empty { display: none; }
.files li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  align-items: center;
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
}
.files li.active { border-color: var(--accent-dim); }
.files li .name {
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.files li .meta { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.files li .state { font-size: 12px; color: var(--muted); }
.files li .state.ok { color: var(--ok); }
.files li .state.bad { color: var(--bad); }
.files li a {
  grid-column: 1 / -1;
  justify-self: start;
  color: var(--accent);
  font-size: 13px;
  margin-top: 2px;
}

/* ---------------------------------------------------------------- settings */

.settings {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 14px 0 0;
  padding: 10px 12px 12px;
}
.settings legend { color: var(--muted); font-size: 12px; padding: 0 4px; }

.row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 10px;
  align-items: center;
  margin: 8px 0;
  font-size: 14px;
}
.row.check { grid-template-columns: auto 1fr; gap: 8px; }
.row.detect .boxes { display: flex; flex-wrap: wrap; gap: 10px; font-size: 13px; }
.row.detect .boxes label { display: inline-flex; gap: 4px; align-items: center; }

select, input[type="number"] {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font: inherit;
  font-size: 13px;
  width: 100%;
}
input[type="number"]:disabled { opacity: .45; }
input[type="checkbox"] { accent-color: var(--accent); }

.help { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

/* ----------------------------------------------------------------- buttons */

.actions { display: flex; gap: 8px; margin-top: 12px; }
button {
  font: inherit;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #241d08;
  font-weight: 600;
}
button.ghost { padding: 4px 10px; font-size: 13px; }

/* ------------------------------------------------------------------ viewer */

.viewer { display: flex; flex-direction: column; }
.viewtools {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 10px;
}
.viewtools label { display: inline-flex; gap: 5px; align-items: center; }
.viewtools button { margin-left: auto; }

#canvasWrap {
  position: relative;
  background: #1b1e23;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  min-height: 420px;
  height: 52vh;
}
#view { display: block; width: 100%; height: 100%; }
.caption {
  position: absolute;
  left: 12px;
  bottom: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 12.5px;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

.spinner {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(20, 23, 28, .55);
}
/* The `hidden` attribute is only `display: none` in the UA stylesheet, and any
   author rule setting `display` beats it. Without this the spinner above is
   permanently visible. */
[hidden] {
  display: none !important;
}
.spinner div {
  width: 34px;
  height: 34px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner div { animation-duration: 2.4s; }
}

.loglabel {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
  margin: 14px 0 6px;
  text-transform: uppercase;
  letter-spacing: .6px;
}
.log {
  margin: 0;
  background: #14171c;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  height: 150px;
  overflow: auto;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.log .bad { color: var(--bad); }
.log .ok { color: var(--ok); }
