/* osnapshot — one stylesheet, light + dark */
:root {
  --bg: #f5f5f3;
  --surface: #ffffff;
  --ink: #16161a;
  --muted: #6c6c75;
  --line: #e4e3df;
  --accent: #ff5a36;
  --accent-ink: #ffffff;
  --accent-soft: #fff0eb;
  --ok: #1f9d55;
  --ok-soft: #e7f6ee;
  --warn: #b7791f;
  --warn-soft: #fdf4e3;
  --bad: #d64545;
  --bad-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
  --font: ui-sans-serif, -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111114; --surface: #1a1a1f; --ink: #ececf0; --muted: #9a9aa5; --line: #2b2b33;
    --accent-soft: #3a1f18; --ok-soft: #13291e; --warn-soft: #2e2412; --bad-soft: #321718;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; letter-spacing: -.02em; margin: 8px 0 16px; }
h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 10px; font-weight: 600; }
h2:first-child { margin-top: 0; }
code, pre { font-family: var(--mono); font-size: 13px; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.bad-text { color: var(--bad); }
.hp { position: absolute; left: -9999px; }

/* ---------- top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 750; font-size: 18px; letter-spacing: -.02em; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand small { font-weight: 500; color: var(--muted); font-size: 14px; }
.brand.big { font-size: 24px; margin-bottom: 18px; }
.logo-dot { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); box-shadow: 5px 5px 0 -1px var(--ink); }
.topbar nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.topbar nav a, .subnav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 500; }
.topbar nav a:hover, .subnav a:hover { color: var(--ink); background: var(--bg); text-decoration: none; }
.topbar nav a.on, .subnav a.on { color: var(--ink); background: var(--bg); }
.subnav { display: flex; gap: 4px; padding: 8px 28px; border-bottom: 1px solid var(--line); background: var(--surface); align-items: center; overflow-x: auto; }
.subnav .ver { margin-left: auto; color: var(--muted); font-size: 12px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 28px 60px; }
.foot { text-align: center; padding: 20px; }

/* ---------- panels & grids */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.grid2.wide-left { grid-template-columns: 2fr 1fr; }
.grid2 > .panel, .grid2 > div > .panel:last-child { margin-bottom: 0; }
.grid2 { margin-bottom: 20px; }
@media (max-width: 860px) { .grid2, .grid2.wide-left { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }

/* ---------- forms */
.form { display: flex; flex-direction: column; gap: 12px; }
.form h2 { margin-bottom: 0; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 550; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { font-family: var(--mono); font-size: 13px; }
input[disabled] { opacity: .6; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input[type="color"] { width: 44px; height: 36px; padding: 2px; }
input[type="range"] { padding: 0; border: 0; accent-color: var(--accent); }
input[type="file"] { padding: 8px; }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.search { display: flex; gap: 8px; margin-bottom: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: transform .05s, background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--ink); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(.95); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.wide { width: 100%; margin-top: 18px; padding: 12px; font-size: 16px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; width: 18px; height: 18px; border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 0; }

/* ---------- notices & pills */
.notice { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid transparent; }
.notice.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.notice.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.toast { position: fixed; right: 20px; bottom: 20px; max-width: 380px; z-index: 50; box-shadow: 0 8px 30px rgba(0,0,0,.15); animation: pop .2s ease-out; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } }
.pill { display: inline-block; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; padding: 2px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .actions select { width: auto; padding: 5px 8px; font-size: 13px; }
.table.files td { padding: 5px 10px; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow: auto; max-height: 420px; white-space: pre-wrap; }
details summary { cursor: pointer; margin: 10px 0; font-weight: 600; }
ul.tight { padding-left: 18px; margin: 0 0 14px; } ul.tight li { margin: 4px 0; }

.meter { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.meter > div { height: 100%; background: var(--ok); border-radius: 99px; transition: width .3s; }
.meter > div.hot { background: var(--bad); }

/* ---------- auth pages */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-page .card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); }
.auth-page .card.install { max-width: 620px; }
.auth-page h1 { font-size: 22px; margin-top: 0; }
.auth-page .links { margin-top: 18px; color: var(--muted); }
.checks { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
.checks td { padding: 7px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.checks td:first-child { width: 90px; }
ol.steps { padding-left: 20px; } ol.steps li { margin: 6px 0; }

/* ---------- converter */
.convert-layout { display: grid; grid-template-columns: 1fr 340px; gap: 22px; align-items: start; }
@media (max-width: 960px) { .convert-layout { grid-template-columns: 1fr; } }
.options { position: sticky; top: 80px; }
.options h2 { margin-top: 22px; }
.options > h2:first-child { margin-top: 0; }
#qualityRow h2 { margin-top: 22px; }
h2 .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.options select { margin-bottom: 4px; }

.dropzone {
  position: relative; border: 2px dashed var(--line); border-radius: 16px; background: var(--surface);
  padding: 40px 20px; text-align: center; cursor: pointer; transition: border-color .15s, background .15s; outline: none;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--muted); }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dz-inner { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.dz-icon { width: 46px; height: 46px; border-radius: 12px; background: var(--accent); color: #fff; font-size: 26px; display: grid; place-items: center; line-height: 1; }
.dz-progress { position: absolute; inset: 0; background: var(--surface); border-radius: 14px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; padding: 30px; }
.dz-progress .bar { height: 6px; background: var(--accent); border-radius: 99px; width: 0; transition: width .2s; align-self: flex-start; }

.toolbar { display: flex; align-items: center; gap: 10px; margin: 18px 0 10px; }
.toolbar .spacer { flex: 1; }
.image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.img-card {
  position: relative; display: flex; flex-direction: column; gap: 0; background: var(--surface); border: 2px solid var(--line);
  border-radius: 12px; overflow: hidden; cursor: pointer; transition: border-color .12s, transform .12s; font-weight: 400;
}
.img-card:hover { transform: translateY(-1px); }
.img-card.sel { border-color: var(--accent); }
.img-card input { position: absolute; top: 10px; left: 10px; width: 18px; height: 18px; z-index: 2; }
.thumb, .rthumb {
  aspect-ratio: 4/3; display: grid; place-items: center; overflow: hidden;
  background: conic-gradient(var(--line) 25%, transparent 0 50%, var(--line) 0 75%, transparent 0) 0 0 / 16px 16px;
}
.thumb img, .rthumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.fmt { font-weight: 700; text-transform: uppercase; color: var(--muted); background: var(--surface); padding: 4px 10px; border-radius: 6px; }
.img-card .meta { padding: 9px 11px; }
.name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { flex-direction: row; cursor: pointer; font-weight: 500; }
.chip input { display: none; }
.chip span { display: inline-block; padding: 6px 10px; border: 1px solid var(--line); border-radius: 99px; font-size: 13px; transition: all .12s; user-select: none; }
.chip span em { font-style: normal; color: var(--muted); font-size: 12px; margin-left: 2px; }
.chip input:checked + span { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.chip input:checked + span em { color: inherit; opacity: .7; }
.custom-size { display: flex; align-items: center; gap: 6px; margin: 8px 0; }
.custom-size input { padding: 7px 9px; }
.custom-size .x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 4px 6px; }
#addSize { margin-top: 10px; }

.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg label { flex: 1; font-weight: 500; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 7px 4px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg input:checked + span { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.bg-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }

.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.results-head h2 { margin: 0; }
.result-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 10px; }
.result { display: flex; align-items: center; gap: 12px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.result .rthumb { width: 64px; height: 64px; aspect-ratio: auto; border-radius: 8px; flex: none; }
.result .meta { flex: 1; min-width: 0; }
.result.failed { border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: var(--bad-soft); }

@media (max-width: 600px) {
  .topbar { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .wrap { padding: 18px 16px 40px; }
  .row2 { grid-template-columns: 1fr; }
}
