:root {
  --petrol: #1e4a55;
  --petrol-deep: #143740;
  --mint: #9ed8cb;
  --sunset: #e8791e;
  --sunset-press: #c9620f;
  --paper: #f2f4f3;
  --ink: #16262b;
  --line: #c9d3d2;
  --muted: #5b6d72;
  --good: #2b8a57;
  --warn: #b7791f;
  --bad: #c8323c;
  --cut: #e6007e;
  --radius-s: 6px;
  --radius-m: 10px;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.top {
  display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  padding: .9rem 1.25rem; background: var(--petrol); color: #fff;
}
.top h1 { margin: 0; font-size: 1.15rem; font-weight: 650; letter-spacing: .01em; }
.top .back { color: var(--mint); font-size: .9rem; }

.app { display: grid; grid-template-columns: minmax(0, 1fr) 360px; min-height: calc(100vh - 52px); }
.bench {
  position: relative; background: var(--petrol-deep);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1rem;
}
.stage { width: 100%; max-width: min(100%, calc(100vh - 140px)); aspect-ratio: 1; outline: none; touch-action: none; }
.stage:focus-visible { box-shadow: 0 0 0 3px var(--mint); border-radius: var(--radius-s); }
.empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .9rem; color: #fff; text-align: center; padding: 2rem; pointer-events: none;
}
.empty p { max-width: 26ch; margin: 0; font-size: 1.05rem; }
.empty .btn { pointer-events: auto; }
.dropzone {
  position: absolute; inset: 1rem; border: 3px dashed var(--mint); border-radius: var(--radius-m);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.2rem;
  background: rgba(20, 55, 64, .75); pointer-events: none;
}
.legend { color: #d4e4e1; font-size: .8rem; margin: .6rem 0 0; display: flex; gap: .4rem 1rem; flex-wrap: wrap; justify-content: center; align-items: center; }
.sw { display: inline-block; width: 14px; height: 10px; margin-right: .35rem; vertical-align: middle; border-radius: 2px; }
.sw-cut { background: var(--cut); height: 3px; }
.sw-off { background: #0b2128; border: 1px solid #567a82; }
.sw-miss { background: var(--bad); border-radius: 50%; width: 10px; }

.panel { background: #fff; border-left: 1px solid var(--line); padding: 1rem 1.25rem 2rem; overflow-y: auto; max-height: calc(100vh - 52px); }
.step { padding: .4rem 0 1.2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.step:last-of-type { border-bottom: 0; }
.step h2 { font-size: 1.05rem; margin: .3rem 0 .8rem; display: flex; align-items: center; gap: .55rem; }
.num {
  display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--petrol); color: #fff; font-size: .85rem; font-weight: 700;
}
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.tools { margin-top: .9rem; display: grid; gap: .8rem; }
.btn-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.small { font-size: .82rem; }
.muted { color: var(--muted); font-weight: 400; }

.btn {
  font: inherit; font-size: .9rem; cursor: pointer; padding: .5rem .75rem; min-height: 40px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: var(--radius-s);
}
.btn:hover:not(:disabled) { border-color: var(--petrol); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--mint); outline-offset: 1px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--sunset); border-color: var(--sunset); color: #fff; font-weight: 650; }
.btn.primary:hover:not(:disabled) { background: var(--sunset-press); border-color: var(--sunset-press); }
.btn.ghost { border-color: transparent; text-decoration: underline; }
.btn.danger { color: var(--bad); justify-self: start; }
.btn.wide { width: 100%; display: block; text-align: center; text-decoration: none; padding: .75rem; }
.btn[aria-pressed="true"] { background: var(--petrol); border-color: var(--petrol); color: #fff; }

.slider { display: grid; grid-template-columns: 4.5rem 1fr auto; align-items: center; gap: .6rem; font-size: .9rem; }
.slider input { width: 100%; accent-color: var(--petrol); }
.slider output { font-variant-numeric: tabular-nums; min-width: 3.5rem; text-align: right; color: var(--muted); font-size: .85rem; }
.field { display: grid; gap: .3rem; font-size: .9rem; }
textarea { font: inherit; padding: .5rem; border: 1px solid var(--line); border-radius: var(--radius-s); resize: vertical; }

.font-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .35rem; }
.font-grid .btn { font-size: 1.05rem; padding: .35rem .5rem; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swatches { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--petrol); }
.swatches input[type="color"] { width: 40px; height: 34px; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 2px; background: #fff; }
.seg { display: inline-flex; }
.seg .btn { border-radius: 0; margin-left: -1px; }
.seg .btn:first-child { border-radius: var(--radius-s) 0 0 var(--radius-s); margin-left: 0; }
.seg .btn:last-child { border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.check { display: flex; gap: .5rem; align-items: flex-start; font-size: .88rem; margin: .5rem 0; }
.check input { margin-top: .2rem; accent-color: var(--petrol); width: 18px; height: 18px; flex: none; }

.quality { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: var(--radius-s); background: var(--paper); font-size: .9rem; }
.quality::before { content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--q, var(--muted)); flex: none; }
.quality.good { --q: var(--good); }
.quality.ok { --q: var(--warn); }
.quality.bad { --q: var(--bad); }

.checks { list-style: none; padding: 0; margin: 0 0 .5rem; display: grid; gap: .3rem; font-size: .88rem; }
.checks li { display: flex; gap: .5rem; }
.checks li::before { content: "✓"; color: var(--good); font-weight: 700; width: 1rem; }
.checks li.no::before { content: "✕"; color: var(--bad); }

.progress { height: 6px; background: var(--paper); border-radius: 3px; overflow: hidden; margin-top: .6rem; }
.progress div { height: 100%; width: 0; background: var(--petrol); transition: width .15s; }
.crop-bar { padding: .6rem; border: 1px dashed var(--petrol); border-radius: var(--radius-s); }
.crop-bar p { margin: 0 0 .5rem; }
.result { margin-top: .8rem; padding: .8rem; background: #eaf5f1; border-radius: var(--radius-s); }
.result p { margin: .5rem 0; }
.msg { color: var(--bad); font-size: .9rem; margin: .7rem 0 0; }
.msg.info { color: var(--petrol); }
.foot { margin-top: 1rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .stage { max-width: 100%; }
  .panel { max-height: none; border-left: 0; }
  .btn { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
