:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1d2733;
  --muted: #667485;
  --line: #dfe4ea;
  --accent: #1b75bb;
  --accent-dark: #145d95;
  --ok: #2e7d32;
  --warn: #b4590a;
  --err: #c0272d;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(29,39,51,.06), 0 4px 14px rgba(29,39,51,.06);
}

* { box-sizing: border-box; }

/* Several things below are flex containers, and `display: flex` in a stylesheet
   outranks the user agent's `[hidden] { display: none }`. Without this, hiding
   an element by setting .hidden quietly does nothing. */
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: #eef1f4; padding: 1px 5px; border-radius: 4px; }
.lead { color: var(--muted); max-width: 70ch; margin: 0 0 16px; }
.hint { color: var(--muted); font-size: 13px; }
.dim { color: #96a1ae; }

/* ── top bar ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 14px 26px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.logo {
  flex: none; width: 34px; height: 34px; border-radius: 8px;
  background: var(--accent); color: #fff;
  font: 700 20px/34px Georgia, serif; text-align: center;
}
.privacy { margin: 0; font-size: 13px; color: var(--muted); }

main { padding: 26px; max-width: 880px; margin: 0 auto; }

section {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin: 0 0 18px;
}

/* ── dropzone ────────────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed #c6cfd8; border-radius: var(--radius);
  padding: 34px 20px; text-align: center; cursor: pointer;
  background: #fbfcfd; transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--accent); background: #f2f8fd; outline: none; }
.dropzone.is-over { border-color: var(--accent); background: #e8f3fc; }
.dz-title { margin: 0; font-weight: 600; }
.dz-sub { margin: 5px 0 0; font-size: 13px; color: var(--muted); }
.link { color: var(--accent); text-decoration: underline; }

/* ── file list ───────────────────────────────────────────────────────── */
.file-list { list-style: none; margin: 16px 0 0; padding: 0; }
.file-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px;
  margin-bottom: 6px; background: #fbfcfd;
}
.file-list .idx { color: var(--muted); font-size: 13px; min-width: 1.6em; }
.file-list .name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .meta { color: var(--muted); font-size: 13px; margin-left: auto; white-space: nowrap; }
.file-list .drop-btn {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 18px; line-height: 1; padding: 0 2px;
}
.file-list .drop-btn:hover { color: var(--err); }
.file-list li.is-bad { border-color: #eccbcb; background: #fdf5f5; }
.file-list li.is-bad .meta { color: var(--err); }

/* ── settings ────────────────────────────────────────────────────────── */
.settings { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; }
.settings-checks { margin-top: 16px; gap: 8px 22px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field-wide { margin-top: 16px; max-width: 340px; }
select, input[type=number], input[type=text] {
  font: inherit; font-size: 14px; color: var(--ink);
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface);
}
input[type=number] { width: 110px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }

/* ── buttons ─────────────────────────────────────────────────────────── */
.actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
button {
  font: inherit; cursor: pointer; padding: 9px 17px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
button:hover:not(:disabled) { border-color: #c3cbd4; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.primary:hover:not(:disabled) { background: var(--accent-dark); border-color: var(--accent-dark); }
.ghost { border-color: transparent; color: var(--muted); }

.status { font-size: 14px; color: var(--muted); }
.status.is-ok { color: var(--ok); }

/* ── messages ────────────────────────────────────────────────────────── */
.msg { margin: 14px 0 0; padding: 10px 13px; border-radius: 7px; font-size: 14px; }
.msg.error { background: #fdf1f1; border: 1px solid #eccbcb; color: var(--err); }
.msg.warn  { background: #fdf7ee; border: 1px solid #ecdcc0; color: var(--warn); }

/* ── result ──────────────────────────────────────────────────────────── */
.result-list { list-style: none; margin: 0; padding: 0; }
.result-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border: 1px solid #cfe3d2; border-radius: 7px;
  margin-bottom: 8px; background: #f4faf5;
}
.result-list .name { font-weight: 600; }
.result-list .meta { color: var(--muted); font-size: 13px; margin-left: auto; }
.result-list a.dl {
  padding: 6px 13px; border-radius: 7px; background: var(--accent); color: #fff;
  text-decoration: none; font-size: 14px; font-weight: 600;
}
.result-list a.dl:hover { background: var(--accent-dark); }

.preview-wrap { margin-top: 14px; border: 1px solid var(--line); border-radius: 7px; overflow: hidden; }
.preview-wrap iframe { display: block; width: 100%; height: 620px; border: 0; background: #525659; }

/* ── help ────────────────────────────────────────────────────────────── */
.help { background: transparent; border: 0; box-shadow: none; padding: 0 4px; margin-bottom: 18px; }
.help summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.help ol { color: var(--muted); font-size: 14px; max-width: 70ch; }
.help li { margin-bottom: 5px; }
.help .hint { max-width: 70ch; }

footer { padding: 4px 26px 34px; max-width: 880px; margin: 0 auto; }
footer p { margin: 0; font-size: 13px; color: var(--muted); }

/* The measuring iframe must be laid out — display:none gives every element a
   zero-sized rect — so park it off-screen instead. */
#measure-frame {
  position: fixed; left: -20000px; top: 0;
  width: 2400px; height: 2400px; border: 0; visibility: hidden;
}

@media (max-width: 620px) {
  main, footer { padding-left: 16px; padding-right: 16px; }
  .topbar { padding: 12px 16px; }
  .privacy { display: none; }
}
