:root {
  --brand: #e5322d; --brand2: #ff8a1f; --ink: #1d2433; --muted: #6b7385; --line: #e4e7ee;
  --bg: #f5f6fa; --card: #fff; --side: #161b26; --ok: #12a150; --radius: 12px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { display: flex; background: var(--bg); color: var(--ink); font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* sidebar */
#side { width: 232px; flex: none; background: var(--side); color: #c9d0dd; display: flex; flex-direction: column; overflow-y: auto; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; text-decoration: none; color: #fff; border-bottom: 1px solid #252c3a; }
.brand img { width: 38px; height: 38px; }
.brand b { font-size: 17px; display: block; letter-spacing: .2px; }
.brand small { color: #8c95a8; font-size: 11.5px; }
#cats { padding: 10px 8px; flex: 1; }
.cat-title { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: #6e7891; margin: 14px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: none; border: 0; color: #c9d0dd; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.nav-item:hover { background: #222a39; color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(229,50,45,.28), rgba(229,50,45,.05)); color: #fff; }
.nav-item .e { width: 20px; text-align: center; }
.side-foot { padding: 14px 16px; font-size: 11.5px; color: #7d879b; border-top: 1px solid #252c3a; }

/* main */
#main { flex: 1; overflow-y: auto; }
.view { padding: 26px 32px 40px; max-width: 1280px; margin: 0 auto; }
.hero { text-align: center; padding: 18px 0 22px; }
.hero h1 { margin: 0 0 6px; font-size: 30px; }
.hero p { margin: 0 0 18px; color: var(--muted); }
#search { width: min(560px, 100%); padding: 12px 16px; border-radius: 30px; border: 1px solid var(--line); background: #fff; box-shadow: 0 2px 10px rgba(20,30,60,.05); outline: none; }
#search:focus { border-color: var(--brand2); }
.carry-note { margin: 14px auto 0; display: inline-block; background: #fff4e8; color: #8a4a08; border: 1px solid #ffd6a8; padding: 8px 14px; border-radius: 10px; }
.grid-cat { margin: 22px 0 10px; font-size: 15px; color: var(--muted); font-weight: 600; }
.tgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; display: flex; gap: 12px; align-items: flex-start; text-align: left; transition: .15s; }
.tcard:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(20,30,60,.09); border-color: #ffd0b0; }
.tcard .ic, .ticon { width: 40px; height: 40px; flex: none; border-radius: 10px; display: grid; place-items: center; font-size: 21px; background: #fff1e8; }
.tcard b { display: block; font-size: 14.5px; margin-bottom: 2px; }
.tcard span { color: var(--muted); font-size: 12.5px; line-height: 1.35; }

/* tool page */
.tool-head { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.tool-head h1, .tool-head h2 { margin: 0; font-size: 22px; }
.tool-head p { margin: 2px 0 0; color: var(--muted); }
.back { border: 1px solid var(--line); background: #fff; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 18px; }
.ticon { width: 46px; height: 46px; font-size: 24px; }
.tool-body { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
@media (max-width: 980px) { .tool-body { grid-template-columns: 1fr; } }
.drop { border: 2px dashed #ccd2df; border-radius: var(--radius); background: #fff; min-height: 170px; display: grid; place-items: center; transition: .15s; }
.drop.over { border-color: var(--brand); background: #fff6f2; }
.drop.compact { min-height: 70px; }
.drop.compact .drop-icon { display: none; }
.drop-in { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px; }
.drop.compact .drop-in { flex-direction: row; }
.drop-icon { font-size: 30px; color: var(--brand); }
#drop-sub { color: var(--muted); }
.btn { border: 1px solid var(--line); background: #fff; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; }
.btn:hover { border-color: #c5ccda; }
.btn.primary { background: linear-gradient(90deg, var(--brand), #f0532a); color: #fff; border: 0; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:disabled { background: #c9ced8; cursor: default; }
.btn.big { width: 100%; padding: 12px; font-size: 15.5px; margin-top: 4px; }
.btn.sm { padding: 5px 9px; font-size: 12.5px; }
.btn.ghost { background: transparent; }
.files { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.files li { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: flex; gap: 10px; align-items: center; }
.files li.dragging { opacity: .4; }
.files .fi { font-size: 20px; }
.files .fn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.files .fs { color: var(--muted); font-size: 12px; }
.files .x { border: 0; background: none; cursor: pointer; color: #9aa2b2; font-size: 16px; padding: 2px 6px; }
.files .x:hover { color: var(--brand); }

.opts { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 11px; }
.opts:empty { display: none; }
.opt label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
.opt input[type=text], .opt input[type=number], .opt input[type=password], .opt select, .opt textarea, .field input, .field select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe; outline: none; }
.opt textarea { min-height: 160px; resize: vertical; font-family: Consolas, monospace; font-size: 13px; }
.opt input:focus, .opt select:focus, .opt textarea:focus { border-color: var(--brand2); background: #fff; }
.opt .row { display: flex; gap: 8px; align-items: center; }
.opt input[type=range] { width: 100%; }
.opt .chk { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--ink); font-weight: 500; }
.opt .hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { border: 1px solid var(--line); background: #fbfcfe; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.seg button.on { border-color: var(--brand); background: #fff1ec; color: var(--brand); font-weight: 600; }

.progress { margin-top: 12px; background: #e9ecf2; border-radius: 8px; height: 26px; position: relative; overflow: hidden; }
.progress div { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand2), var(--brand)); transition: width .2s; }
.progress span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12.5px; font-weight: 600; color: #222; }
.error { margin-top: 12px; background: #fff0f0; border: 1px solid #ffc9c9; color: #a01818; padding: 10px 12px; border-radius: 10px; }
.results { margin-top: 14px; background: #fff; border: 1px solid #bfe8cf; border-radius: var(--radius); padding: 12px; }
.results h4 { margin: 0 0 8px; color: var(--ok); }
.res { display: flex; gap: 8px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.res .rn { flex: 1 1 100%; font-weight: 600; word-break: break-all; }
.res .rs { color: var(--muted); font-size: 12px; flex: 1; }
.res-all { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.note { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* organize */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 14px; }
.thumb { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px; text-align: center; cursor: grab; position: relative; user-select: none; }
.thumb.del { opacity: .35; }
.thumb.drag-over { outline: 2px solid var(--brand); }
.thumb .tw { height: 150px; display: grid; place-items: center; overflow: hidden; }
.thumb canvas { max-width: 100%; max-height: 150px; box-shadow: 0 1px 4px rgba(0,0,0,.18); transition: transform .2s; }
.thumb .tn { font-size: 12px; color: var(--muted); margin: 6px 0 4px; }
.thumb .tb { display: flex; justify-content: center; gap: 4px; }
.thumb .tb button { border: 1px solid var(--line); background: #fff; border-radius: 6px; cursor: pointer; padding: 2px 7px; }
.org-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

/* placer */
.placer-bar { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; align-items: center; }
.placer-wrap { background: #e9ecf2; border-radius: var(--radius); padding: 16px; overflow: auto; display: flex; justify-content: center; }
.placer-page { position: relative; box-shadow: 0 4px 18px rgba(0,0,0,.18); background: #fff; }
.placer-page canvas { display: block; }
.pitem { position: absolute; border: 1.5px dashed transparent; cursor: move; touch-action: none; }
.pitem:hover, .pitem.sel { border-color: var(--brand); }
.pitem img { width: 100%; height: 100%; display: block; pointer-events: none; }
.pitem .rh { position: absolute; right: -7px; bottom: -7px; width: 14px; height: 14px; background: var(--brand); border-radius: 50%; cursor: nwse-resize; display: none; }
.pitem.sel .rh { display: block; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 8px; }
.sel-panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sel-panel input[type=text] { flex: 1; min-width: 160px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; }

/* reader */
.reader-bar { display: flex; gap: 8px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.reader { background: #e9ecf2; border-radius: var(--radius); padding: 16px; height: 72vh; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.reader .rp { background: #fff; box-shadow: 0 3px 14px rgba(0,0,0,.16); position: relative; }
.reader .rp canvas { display: block; }
.reader .pn { position: absolute; bottom: -18px; width: 100%; text-align: center; font-size: 11px; color: var(--muted); }

/* forms / info */
.fields { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-top: 12px; display: grid; gap: 10px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.infobox { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; font-size: 13px; color: var(--muted); }

/* compare */
.diff { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-top: 12px; max-height: 70vh; overflow: auto; font: 12.5px/1.5 Consolas, monospace; }
.diff div { padding: 1px 10px; white-space: pre-wrap; }
.diff .a { background: #e6ffed; } .diff .d { background: #ffeef0; } .diff .h { background: #f1f3f8; color: var(--muted); font-weight: 700; }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(15,20,30,.55); display: grid; place-items: center; z-index: 50; }
.modal-box { background: #fff; border-radius: 14px; padding: 18px; width: min(620px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box h3 { margin: 0 0 10px; }
.sigpad { border: 1px solid var(--line); border-radius: 10px; background: #fff; touch-action: none; width: 100%; height: 200px; display: block; cursor: crosshair; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { border: 1px solid var(--line); background: #fff; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.tabs button.on { background: var(--ink); color: #fff; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* links styled like buttons */
a.nav-item, a.tcard { text-decoration: none; color: inherit; }
a.nav-item { color: #c9d0dd; }
a.tcard { color: var(--ink); }

/* website: top bar, SEO content, footer */
#topbar { display: none; }
#scrim { display: none; }
.seo { max-width: 920px; margin: 10px auto 0; padding: 10px 32px 30px; color: #3a4252; line-height: 1.65; }
.seo h1 { font-size: 24px; margin: 26px 0 8px; color: var(--ink); }
.seo h2 { font-size: 19px; margin: 24px 0 8px; color: var(--ink); }
.seo ol, .seo ul { padding-left: 22px; }
.seo li { margin: 4px 0; }
.seo details { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin: 8px 0; }
.seo summary { font-weight: 600; cursor: pointer; color: var(--ink); }
.seo .related { display: flex; flex-wrap: wrap; gap: 8px; }
.seo .related a { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 6px 12px; text-decoration: none; color: var(--ink); font-size: 13px; }
.seo .related a:hover { border-color: var(--brand); color: var(--brand); }
.site-foot { border-top: 1px solid var(--line); padding: 22px 32px; color: var(--muted); font-size: 13px; text-align: center; }
.site-foot a { color: var(--muted); margin: 0 8px; }
.trust { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-top: 14px; color: var(--muted); font-size: 13px; }

@media (max-width: 820px) {
  body { display: block; }
  #topbar { display: flex; position: sticky; top: 0; z-index: 30; background: var(--side); color: #fff; align-items: center; gap: 10px; padding: 10px 14px; }
  #topbar a { color: #fff; text-decoration: none; display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 17px; }
  #topbar img { width: 30px; height: 30px; }
  #menu-btn { background: none; border: 0; color: #fff; font-size: 24px; padding: 2px 6px; cursor: pointer; }
  #side { position: fixed; top: 0; bottom: 0; left: -270px; width: 260px; z-index: 50; transition: left .2s; }
  body.nav-open #side { left: 0; }
  body.nav-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 45; }
  #main { overflow: visible; }
  .view { padding: 16px 14px 30px; }
  .hero h1 { font-size: 24px; }
  .tgrid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tcard { flex-direction: column; gap: 6px; padding: 12px; }
  .tcard span { font-size: 12px; }
  .ticon { display: none; }
  .tool-head h2 { font-size: 19px; }
  .seo { padding: 6px 16px 24px; }
  .drop { min-height: 130px; }
  .placer-wrap, .reader { padding: 8px; }
  .modal-box { padding: 14px; }
}
