:root {
  color-scheme: light;
  --paper: #f3f5f2;
  --ink: #101514;
  --muted: #64706c;
  --line: #cbd1cc;
  --panel: #ffffff;
  --dark: #121817;
  --acid: #b9ef48;
  --coral: #f06d51;
  --blue: #3478f6;
  --shadow: 0 18px 50px rgba(20, 32, 28, .09);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-family: Arial, Helvetica, sans-serif; background: var(--paper); color: var(--ink); }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input { font: inherit; }
button { letter-spacing: 0; }

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 32px;
  border-bottom: 1px solid var(--line);
}
.brand { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 11px; font-size: .82rem; font-weight: 800; }
.brand-mark { width: 25px; height: 25px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; }
.brand-mark i { display: block; background: var(--ink); }
.brand-mark i:nth-child(2), .brand-mark i:nth-child(3) { background: var(--coral); }
.runtime-status { display: inline-flex; align-items: center; gap: 9px; color: var(--muted); font-size: .78rem; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #e0a234; box-shadow: 0 0 0 4px rgba(224,162,52,.12); }
.status-dot.ready { background: #38a76b; box-shadow: 0 0 0 4px rgba(56,167,107,.12); }
.status-dot.error { background: #d9534f; box-shadow: 0 0 0 4px rgba(217,83,79,.12); }

.workspace { width: min(1260px, calc(100% - 48px)); margin: 0 auto; padding: 52px 0 24px; }
.intro { max-width: 770px; margin-bottom: 34px; }
.eyebrow { margin: 0 0 11px; color: var(--coral); font-size: .72rem; font-weight: 800; letter-spacing: .13em; }
h1 { max-width: 700px; margin: 0; font-size: clamp(2.35rem, 5vw, 4.9rem); line-height: .96; letter-spacing: 0; font-weight: 800; }
.lede { max-width: 620px; margin: 20px 0 0; color: var(--muted); font-size: 1.03rem; line-height: 1.65; }

.tool-shell { min-height: 520px; display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(300px, .75fr); border: 1px solid var(--ink); background: var(--panel); box-shadow: var(--shadow); }
.viewer { min-height: 520px; position: relative; display: grid; place-items: center; overflow: hidden; background-color: var(--dark); background-image: linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px); background-size: 28px 28px; }
.viewer.dragging { outline: 3px solid var(--acid); outline-offset: -8px; }
.empty-state { width: min(440px, 86%); color: #f5faf7; text-align: center; }
.empty-state h2 { margin: 24px 0 8px; font-size: 1.45rem; }
.empty-state p { margin: 0 auto 24px; color: #9ba6a2; font-size: .94rem; line-height: 1.5; }
.scan-icon { width: 86px; height: 86px; margin: 0 auto; position: relative; border: 1px solid #65706c; }
.scan-icon::before, .scan-icon::after { content: ""; position: absolute; width: 21px; height: 21px; border-color: var(--acid); }
.scan-icon::before { left: -4px; top: -4px; border-left: 4px solid var(--acid); border-top: 4px solid var(--acid); }
.scan-icon::after { right: -4px; bottom: -4px; border-right: 4px solid var(--acid); border-bottom: 4px solid var(--acid); }
.scan-icon span { position: absolute; left: 13px; right: 13px; top: 42px; height: 2px; background: var(--coral); box-shadow: 0 0 16px var(--coral); animation: scan 2.2s ease-in-out infinite; }
@keyframes scan { 0%,100% { transform: translateY(-22px); } 50% { transform: translateY(22px); } }
.primary-action, .run-button { min-height: 46px; border: 0; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 0 19px; font-size: .84rem; font-weight: 800; cursor: pointer; transition: transform .15s ease, background .15s ease; }
.primary-action { background: var(--acid); color: #101510; }
.primary-action:hover { background: #c7fa5c; transform: translateY(-1px); }
.primary-action svg, .run-button svg, .icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: square; stroke-linejoin: miter; }
.run-button svg { fill: currentColor; stroke: none; }

.canvas-wrap { width: 100%; height: 100%; position: absolute; inset: 0; display: grid; place-items: center; }
#resultCanvas { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; }
.processing { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 12px; color: white; background: rgba(9, 14, 13, .74); backdrop-filter: blur(5px); font-size: .85rem; font-weight: 700; }
.spinner { width: 20px; height: 20px; border: 2px solid rgba(255,255,255,.25); border-top-color: var(--acid); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.control-panel { display: flex; flex-direction: column; min-width: 0; padding: 28px; border-left: 1px solid var(--ink); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 23px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 0; font-size: 1.55rem; }
.count-badge { min-width: 36px; height: 36px; display: grid; place-items: center; background: var(--ink); color: white; font-size: .8rem; font-weight: 800; }
.setting { padding: 22px 0; border-bottom: 1px solid var(--line); }
.setting-label, .range-labels { display: flex; justify-content: space-between; align-items: center; }
.setting-label label { font-size: .86rem; font-weight: 800; }
.setting-label output { font-family: Consolas, monospace; color: var(--coral); font-size: .82rem; }
input[type="range"] { width: 100%; height: 4px; margin: 18px 0 9px; accent-color: var(--coral); cursor: pointer; }
.range-labels { color: #87918e; font-size: .68rem; }
.results-list { flex: 1; min-height: 180px; max-height: 300px; padding: 10px 0; overflow-y: auto; }
.results-empty { display: flex; gap: 13px; align-items: flex-start; padding: 17px 0; color: var(--muted); }
.results-empty span { font-family: Consolas, monospace; color: #a4aca9; font-size: .72rem; }
.results-empty p { margin: 0; font-size: .8rem; line-height: 1.55; }
.result-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 11px 3px; border-bottom: 1px solid #e7eae7; }
.result-swatch { width: 8px; height: 24px; }
.result-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; font-weight: 700; text-transform: capitalize; }
.result-score { color: var(--muted); font-family: Consolas, monospace; font-size: .72rem; }
.actions { display: grid; grid-template-columns: 1fr 46px; gap: 8px; margin-top: 14px; }
.run-button { width: 100%; color: white; background: var(--ink); }
.run-button:hover:not(:disabled) { background: #28312e; }
.run-button:disabled, .icon-button:disabled { opacity: .4; cursor: not-allowed; }
.icon-button { width: 46px; height: 46px; display: grid; place-items: center; border: 1px solid var(--line); color: var(--ink); background: white; cursor: pointer; }
.icon-button:hover:not(:disabled) { border-color: var(--coral); color: var(--coral); }

footer { min-height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 20px; color: var(--muted); font-family: Consolas, monospace; font-size: .7rem; }
footer a { color: inherit; text-underline-offset: 3px; }

@media (max-width: 800px) {
  .topbar { padding: 0 18px; }
  .workspace { width: min(100% - 28px, 650px); padding-top: 34px; }
  .intro { margin-bottom: 25px; }
  h1 { font-size: clamp(2.25rem, 12vw, 4rem); }
  .tool-shell { grid-template-columns: 1fr; }
  .viewer { min-height: 390px; }
  .control-panel { border-left: 0; border-top: 1px solid var(--ink); }
  .results-list { max-height: 220px; }
}

@media (max-width: 480px) {
  .runtime-status { max-width: 145px; justify-content: flex-end; text-align: right; }
  .workspace { width: calc(100% - 20px); padding-top: 28px; }
  .lede { font-size: .95rem; }
  .viewer { min-height: 330px; }
  .control-panel { padding: 22px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
