:root {
  --bg: #0e0f12; --panel: #15171c; --panel-2: #0f1117; --border: #262a32; --text: #e6e8ee; --muted: #8b90a0;
  --accent: #95d600; --accent-dim: #6f9f02; --accent-2: #9147ff; --good: #aef13d; --warn: #ffb454; --bad: #ff6b6b;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); font: 15px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; background: var(--bg); }

.site { max-width: 1100px; margin: 0 auto; padding: 32px 20px 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.brand { display: block; line-height: 0; }
.brandLogo { width: min(480px, 86vw); height: auto; display: block; }
.crumbs { font: 12px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); letter-spacing: 0.02em; text-align: center; }
.crumbs a, .crumbs a:visited { color: var(--accent); text-decoration: none; }
.crumbs a:hover { color: var(--good); }
.crumbs .sep { color: #3a4150; margin: 0 4px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 36px 20px 48px; }
.head h1 { margin: 0 0 8px; font-size: 24px; font-weight: 650; }
.head h1::before { content: ">"; color: var(--accent); margin-right: 10px; }
.head .intro { margin: 0 0 24px; font-size: 13px; color: var(--muted); max-width: 720px; }
.grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
.col-right { position: sticky; top: 16px; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } .col-left, .col-right { display: contents; } #previewPanel { order: -1; } }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
.panel h2 { margin: 0 0 12px; font-size: 15px; font-weight: 650; }
.panel h2::before { content: ">"; color: var(--accent); margin-right: 8px; }
.adv-panel summary { cursor: pointer; list-style: none; }
.adv-panel summary::-webkit-details-marker { display: none; }
.adv-panel summary h2 { display: inline; margin: 0; }
.adv-panel summary::after { content: "  (show)"; color: var(--muted); font-size: 12px; }
.adv-panel[open] summary::after { content: "  (hide)"; }
.lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 12px; }
.note { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }
.note:empty { display: none; }
.hidden { display: none !important; }
.mt10 { margin-top: 10px; } .mb10 { margin-bottom: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.radios { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.field { margin-bottom: 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }
.in, .sel { width: 100%; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; font: 13px/1.5 ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.in:focus, .sel:focus { outline: none; border-color: var(--accent-dim); }
.in.num { width: 110px; }
.w-auto { width: auto; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; min-height: 24px; }
.check input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.check.small { font-size: 12px; color: var(--muted); }
.err { color: var(--bad); font-size: 12px; margin-top: 6px; }
.err:empty { display: none; }
.color input[type="color"] { width: 34px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); cursor: pointer; }
.range { width: 100%; accent-color: var(--accent); }
details.adv { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 10px; }
details.adv summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); }
details.adv summary:hover { color: var(--text); }

.btn { background: var(--accent); color: #10130a; border: 0; border-radius: 8px; padding: 10px 18px; font-family: inherit; font-size: 14px; font-weight: 700; cursor: pointer; min-height: 40px; }
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); font-weight: 600; }
.btn.sm { padding: 6px 10px; font-size: 12px; min-height: 32px; }
.btn.big { width: 100%; font-size: 16px; padding: 14px; }
.btn.fix { background: transparent; border: 1px solid var(--warn); color: var(--warn); font-size: 11px; padding: 4px 8px; font-weight: 700; min-height: 28px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; }
.statusline { color: var(--muted); font-size: 12px; min-height: 18px; }
.statusline.err { color: var(--warn); }

/* drop zone + file card */
.drop { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 26px 16px; border: 1px dashed #3a4150; border-radius: 10px; background: var(--panel-2); text-align: center; cursor: pointer; }
.drop:hover, .drop:focus-visible, body.dragging .drop { border-color: var(--accent); outline: none; }
.filecard { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.badge { font-size: 11px; color: var(--warn); border: 1px solid #4a3b1f; border-radius: 999px; padding: 2px 8px; cursor: help; }
.badge.info { color: var(--muted); border-color: var(--border); }

/* dimensions */
.dimrow .in.num { width: 120px; }
.lock { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 6px 10px; font: inherit; font-size: 12px; cursor: pointer; min-height: 36px; }
.lock[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }
.lock .lock-open { display: none; }
.lock[aria-pressed="false"] .lock-open { display: block; }
.lock[aria-pressed="false"] .lock-closed { display: none; }

/* fit options */
.fitgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.fitopt { display: flex; flex-direction: column; gap: 6px; text-align: left; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px; color: var(--text); font: inherit; cursor: pointer; }
.fitopt:hover { border-color: var(--accent-dim); }
.fitopt[aria-checked="true"] { border-color: var(--accent); background: rgba(149, 214, 0, 0.06); }
.fitopt canvas { width: 100%; height: 90px; object-fit: contain; background: #d8d8d8; background-image: linear-gradient(45deg, #b8b8b8 25%, transparent 25%, transparent 75%, #b8b8b8 75%), linear-gradient(45deg, #b8b8b8 25%, transparent 25%, transparent 75%, #b8b8b8 75%); background-size: 12px 12px; background-position: 0 0, 6px 6px; border-radius: 6px; }
.fitopt .t { font-weight: 650; font-size: 13px; }
.fitopt .d { font-size: 12px; color: var(--text); }
.fitopt .n { font-size: 11px; color: var(--muted); }
.fitopt.warn .t { color: var(--warn); }

/* preview stage */
.stage { position: relative; background: #d8d8d8; background-image: linear-gradient(45deg, #b8b8b8 25%, transparent 25%, transparent 75%, #b8b8b8 75%), linear-gradient(45deg, #b8b8b8 25%, transparent 25%, transparent 75%, #b8b8b8 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; border-radius: 10px; min-height: 220px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.stage canvas { display: block; max-width: 100%; max-height: 420px; }
.stage-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--panel-2); }
.overlay { position: absolute; border: 2px solid var(--accent); box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45); cursor: move; outline: none; touch-action: none; }
.overlay:focus-visible { border-color: var(--good); }
.overlay.focal { cursor: grab; }
.handle { position: absolute; width: 22px; height: 22px; background: var(--accent); border: 2px solid #10130a; border-radius: 4px; }
.handle.tl { left: -12px; top: -12px; cursor: nwse-resize; } .handle.tr { right: -12px; top: -12px; cursor: nesw-resize; }
.handle.bl { left: -12px; bottom: -12px; cursor: nesw-resize; } .handle.br { right: -12px; bottom: -12px; cursor: nwse-resize; }
.overlay.focal .handle { display: none; }
.tools .btn { min-height: 36px; touch-action: manipulation; }
#compareBtn { touch-action: manipulation; }
.msgs { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; }
.msgs li { padding: 4px 0; color: var(--muted); }
.msgs li.warn { color: var(--warn); }

/* result */
.result-stage { position: relative; background: #d8d8d8; background-image: linear-gradient(45deg, #b8b8b8 25%, transparent 25%, transparent 75%, #b8b8b8 75%), linear-gradient(45deg, #b8b8b8 25%, transparent 25%, transparent 75%, #b8b8b8 75%); background-size: 16px 16px; background-position: 0 0, 8px 8px; border-radius: 10px; min-height: 160px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.result-stage img { display: block; max-width: 100%; max-height: 420px; }
.receipt { list-style: none; margin: 12px 0 0; padding: 0; font-size: 13px; }
.receipt li { padding: 4px 0; }
.receipt li.ok::before { content: "✓ "; color: var(--good); }
.receipt li.bad::before { content: "✗ "; color: var(--bad); }
.receipt li.info { color: var(--muted); font-size: 12px; }
.tech { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12px; color: var(--muted); }
.tech li { padding: 3px 0; border-top: 1px solid var(--border); }
.tech li:first-child { border-top: 0; }
.fixes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.fixes:empty { display: none; }

.how summary { cursor: pointer; list-style: none; }
.how summary::-webkit-details-marker { display: none; }
.how summary h2 { display: inline; margin: 0; }
.how summary::after { content: "  (show)"; color: var(--muted); font-size: 12px; }
.how[open] summary::after { content: "  (hide)"; }
.how[open] summary { margin-bottom: 12px; }
.how p { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.legal { text-align: center; font-size: 11px; color: #5a6070; padding: 0 20px 8px; }
.contact { text-align: center; font-size: 13px; color: var(--accent-2); padding: 0 20px 28px; }
.contact a { color: var(--accent-2); text-decoration: none; }
@media (max-width: 520px) { .site { padding-top: 24px; } .wrap { padding-top: 28px; } .panel { padding: 16px; } .in.num, .dimrow .in.num { width: 96px; } }
@media (prefers-reduced-motion: no-preference) { .overlay { transition: border-color 0.15s; } }

/* touch devices: no iOS auto-zoom on focus, bigger crop handles */
@media (pointer: coarse) {
  .in, .sel { font-size: 16px; }
  .in.num, .dimrow .in.num { width: 108px; }
  .handle { width: 28px; height: 28px; }
  .handle.tl { left: -15px; top: -15px; } .handle.tr { right: -15px; top: -15px; }
  .handle.bl { left: -15px; bottom: -15px; } .handle.br { right: -15px; bottom: -15px; }
}
