:root {
  --bg: #f7f8fa;
  --card: #ffffff;
  --text: #16181d;
  --muted: #545b67;
  --line: #d9dde3;
  --field: #ffffff;
  --accent: #1b5fd1;
  --accent-text: #ffffff;
  --accent-soft: #e8f0fd;
  --ok: #156a3a;
  --ok-soft: #e4f4ea;
  --warn: #8a5300;
  --warn-soft: #fff4e0;
  --bad: #b3261e;
  --bad-soft: #fdecea;
  --code: #eef0f3;
  --focus: #1b5fd1;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --card: #1d2026;
    --text: #e9ebef;
    --muted: #a6adb9;
    --line: #353a43;
    --field: #15171c;
    --accent: #7eaaf5;
    --accent-text: #0e1726;
    --accent-soft: #22304a;
    --ok: #7bd39b;
    --ok-soft: #1c3326;
    --warn: #f2bd63;
    --warn-soft: #3a2d15;
    --bad: #f39a92;
    --bad-soft: #3e1f1d;
    --code: #2a2e36;
    --focus: #9cc0ff;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161a; --card: #1d2026; --text: #e9ebef; --muted: #a6adb9; --line: #353a43; --field: #15171c;
  --accent: #7eaaf5; --accent-text: #0e1726; --accent-soft: #22304a; --ok: #7bd39b; --ok-soft: #1c3326;
  --warn: #f2bd63; --warn-soft: #3a2d15; --bad: #f39a92; --bad-soft: #3e1f1d; --code: #2a2e36; --focus: #9cc0ff;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}
a { color: var(--accent); }
code { background: var(--code); padding: 0.1em 0.35em; border-radius: 4px; font-size: 0.9em; word-break: break-word; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.top { padding: 28px 0 12px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.01em; }
h1 .sub { display: block; font-size: 1rem; font-weight: 500; color: var(--muted); margin-top: 4px; letter-spacing: 0; }
.lede { margin: 0; color: var(--muted); max-width: 70ch; }

.tabs { display: flex; gap: 4px; margin: 16px 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted);
  padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; border-radius: 6px 6px 0 0;
}
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.pill { display: inline-block; min-width: 1.6em; padding: 0 6px; border-radius: 999px; background: var(--code); font-size: 0.8em; text-align: center; }

.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; } .out { position: sticky; top: 12px; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h2 { margin-top: 0; font-size: 1.2rem; }

.field { margin-bottom: 14px; min-width: 0; }
.field label { display: block; font-weight: 600; margin-bottom: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92rem; }
.field label[for="f-url"], .field label[for="bulk-in"] { font-family: inherit; font-size: 1rem; }
.field small { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 3px; }
.req, .opt { font-family: system-ui, sans-serif; font-weight: 500; font-size: 0.75rem; padding: 1px 6px; border-radius: 999px; margin-left: 4px; vertical-align: 1px; }
.req { background: var(--accent-soft); color: var(--accent); }
.opt { background: var(--code); color: var(--muted); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--field);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; min-height: 44px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
input.has-warn { border-color: var(--warn); }
input.has-err { border-color: var(--bad); }
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88rem; }
select { width: auto; }
.two { display: grid; gap: 0 14px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .two { grid-template-columns: 1fr 1fr; } }

.presets { border: 0; padding: 0; margin: 0 0 14px; min-width: 0; }
.presets legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { font-size: 0.88rem; padding: 6px 11px; min-height: 36px; border-radius: 999px; }

button, .file-btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 9px 14px; min-height: 44px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); display: inline-flex; align-items: center; gap: 6px;
}
button:hover:not(:disabled), .file-btn:hover { border-color: var(--accent); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.ghost { background: transparent; }
button.danger { color: var(--bad); }
button.active { background: var(--accent-soft); border-color: var(--accent); }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.opts { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: 4px; }
.check { display: inline-flex; gap: 8px; align-items: center; }
.check input { width: 20px; height: 20px; min-height: 0; }
.inline { display: inline-flex; gap: 8px; align-items: center; font-weight: 600; }
.inline.grow { flex: 1 1 220px; }
.inline.grow input { flex: 1; }
.more { margin: 2px 0 12px; }
.more summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.more[open] summary { margin-bottom: 8px; }

.h-out { margin-bottom: 10px; }
.channel { border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--code); border-left: 5px solid var(--muted); }
.channel strong { display: block; font-size: 1.15rem; }
.channel.ok { background: var(--ok-soft); border-left-color: var(--ok); }
.channel.warn { background: var(--warn-soft); border-left-color: var(--warn); }
.ch-label { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.ch-why { margin: 4px 0 0; font-size: 0.9rem; color: var(--text); }
#out-url { word-break: break-all; }

.warnings { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; }
.warnings li { padding: 8px 10px 8px 12px; border-radius: 8px; font-size: 0.92rem; border-left: 4px solid; }
.warnings li.err { background: var(--bad-soft); border-color: var(--bad); }
.warnings li.warn { background: var(--warn-soft); border-color: var(--warn); }
.warnings li.info { background: var(--accent-soft); border-color: var(--accent); }
.warnings b { margin-right: 4px; }
.warnings button { min-height: 32px; padding: 3px 9px; font-size: 0.85rem; margin-left: 6px; }

.qr { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; }
.qr-view { width: 168px; height: 168px; background: #fff; border-radius: 8px; padding: 0; flex: none; }
.qr-view svg { width: 100%; height: 100%; display: block; }
.qr-side { flex: 1 1 200px; min-width: 0; }
.qr-side h3 { margin: 0 0 8px; font-size: 1rem; }
.hint { color: var(--muted); font-size: 0.88rem; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--code); font-weight: 600; }
#bulk-table td:nth-child(2) { word-break: break-all; min-width: 240px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; background: var(--ok-soft); color: var(--ok); white-space: nowrap; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

.hist { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 10px; }
.hist li { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.hist .h-url { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.82rem; word-break: break-all; margin: 4px 0 8px; }
.hist .h-meta { font-size: 0.85rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; }
.hist .row-btns { margin: 6px 0 0; }
.hist button { min-height: 36px; padding: 4px 10px; font-size: 0.88rem; }

.privacy { margin: 18px 0; padding: 12px 14px; border-radius: 8px; background: var(--ok-soft); border: 1px solid var(--line); }
.content { max-width: 860px; margin: 32px 0 24px; }
.content h2 { margin-top: 36px; font-size: 1.4rem; }
.content h3 { font-size: 1.05rem; margin: 20px 0 4px; }
.content li { margin-bottom: 6px; }
.updated { color: var(--muted); font-size: 0.9rem; margin-top: 28px; }

.foot { border-top: 1px solid var(--line); padding: 20px 0 36px; color: var(--muted); font-size: 0.92rem; }
.foot ul { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 0; margin: 4px 0 0; }
.foot nav p { margin: 12px 0 0; }

.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600;
  transition: opacity 0.15s, transform 0.15s; pointer-events: none; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
