/* Odstranění pozadí: vzhled stránky. Vlastní, bez cizích písem a obrázků. */

:root {
  --mat: #1e6650;
  --mat-line: rgba(255, 255, 255, 0.08);
  --mat-line-strong: rgba(255, 255, 255, 0.17);
  --ink: #10233a;
  --muted: #4b5d6b;
  --paper: #ffffff;
  --wash: #f2f5f3;
  --line: #d6ded9;
  --cut: #ffd43b;
  --cut-hover: #ffdd66;
  --error: #b42318;
  --focus: #1a5fd6;
  --check-a: #e4e9ee;
  --check-b: #ffffff;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--wash);
}

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

kbd {
  font: inherit;
  font-size: 0.9em;
  padding: 0 0.4em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--paper);
}

code {
  font-family: ui-monospace, Consolas, 'Courier New', monospace;
  font-size: 0.92em;
  padding: 0 0.3em;
  border-radius: 4px;
  background: var(--paper);
}

/* ---------- řezací podložka */

.mat {
  color: #fff;
  background-color: var(--mat);
  background-image:
    linear-gradient(var(--mat-line-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--mat-line-strong) 1px, transparent 1px),
    linear-gradient(var(--mat-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--mat-line) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  background-position: -1px -1px;
}
.mat :focus-visible { outline-color: var(--cut); }

.mat-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 24px 72px;
}

.home {
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}
.home:hover { text-decoration: underline; text-underline-offset: 4px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
  gap: 56px;
  align-items: center;
  margin-top: 44px;
}

h1 {
  margin: 0 0 22px;
  max-width: 11ch;
  font-size: clamp(2.5rem, 1.3rem + 4vw, 4.4rem);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.03em;
}

.lead {
  margin: 0;
  max-width: 32ch;
  font-size: 1.25rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.93);
}

/* ---------- vystřihovací arch */

.sheet {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 360px;
  padding: 56px 32px;
  text-align: center;
  color: var(--ink);
  border-radius: 18px;
  background-color: var(--paper);
  background-image: repeating-conic-gradient(var(--check-a) 0 25%, var(--check-b) 0 50%);
  background-size: 28px 28px;
  box-shadow: 0 20px 44px rgba(5, 32, 24, 0.38);
}

.cutline {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.cutline rect {
  x: 13px;
  y: 13px;
  width: calc(100% - 26px);
  height: calc(100% - 26px);
  rx: 10px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-dasharray: 11 8;
}

.scissors {
  position: absolute;
  top: 0;
  left: 44px;
  width: 28px;
  height: 28px;
  overflow: visible;
  pointer-events: none;
}
.scissors-halo { stroke: var(--paper); stroke-width: 6; }
.scissors-line { stroke: var(--ink); stroke-width: 2; }

.sheet :focus-visible { outline-color: var(--focus); }
.sheet.is-dragging { outline: 5px solid var(--cut); outline-offset: 6px; }
.sheet.is-dragging .cutline rect { stroke: var(--mat); stroke-width: 3; }

.sheet-body {
  max-width: 420px;
  padding: 26px 28px 20px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.95);
}

.hint { margin: 16px 0 4px; }
.formats { margin: 0 0 12px; font-size: 0.9375rem; color: var(--muted); }

/* ---------- tlačítka */

.btn {
  font: inherit;
  font-weight: 600;
  font-size: 1.0625rem;
  line-height: 1.2;
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.08s ease;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  color: var(--ink);
  background: var(--cut);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.16);
}
.btn-primary:hover { background: var(--cut-hover); }

.btn-big { font-size: 1.25rem; padding: 17px 36px; }

.btn-secondary {
  color: var(--ink);
  background: transparent;
  border: 2px solid var(--ink);
  padding: 12px 24px;
}
.btn-secondary:hover { background: rgba(16, 35, 58, 0.06); }

.btn-danger {
  color: #ffffff;
  background: var(--error);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22);
}
.btn-danger:hover { background: #912018; }

.btn-link {
  font: inherit;
  padding: 4px 2px;
  border: 0;
  background: none;
  color: var(--mat);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.btn-link:hover { color: var(--ink); }

.btn:disabled, .btn-link:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- výsledky */

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 24px 8px;
}

.alert {
  margin: 0 0 32px;
  padding: 14px 18px;
  border: 2px solid var(--error);
  border-radius: 12px;
  background: #fff4f2;
  color: #7a1a11;
}
.alert p { margin: 0; }
.alert p + p { margin-top: 6px; }

.results { margin-bottom: 56px; }

.results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 24px;
  margin-bottom: 22px;
}
.results-head h2 { margin: 0; font-size: 1.75rem; letter-spacing: -0.015em; }
.results-note { flex: 1 1 300px; margin: 0; color: var(--muted); }

.list { display: grid; gap: 28px; margin: 0; padding: 0; list-style: none; }

.item {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(250px, 2fr);
  gap: 28px;
  align-items: start;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--paper);
}

.stage-wrap { display: flex; justify-content: center; }

.stage {
  --pos: 100%;
  position: relative;
  width: min(100%, calc(62vh * var(--ar, 1.333)));
  aspect-ratio: var(--ar, 1.333);
  overflow: hidden;
  border-radius: 10px;
  background-color: var(--wash);
  user-select: none;
  -webkit-user-select: none;
}
.stage.is-transparent {
  background-color: var(--check-b);
  background-image: repeating-conic-gradient(var(--check-a) 0 25%, var(--check-b) 0 50%);
  background-size: 20px 20px;
}
.stage.is-white { background: #ffffff; }
.stage.is-color { background: var(--bg, #ffd43b); }

.stage img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  -webkit-user-drag: none;
}
.img-before { clip-path: inset(0 calc(100% - var(--pos)) 0 0); }

.stage.is-working img { filter: saturate(0.55) brightness(1.04); }

/* pochodující mravenci, jako výběr v grafickém editoru */
.ants {
  position: absolute;
  inset: 10px;
  display: none;
  pointer-events: none;
  background-image:
    linear-gradient(90deg, var(--ink) 50%, #fff 50%),
    linear-gradient(90deg, var(--ink) 50%, #fff 50%),
    linear-gradient(0deg, var(--ink) 50%, #fff 50%),
    linear-gradient(0deg, var(--ink) 50%, #fff 50%);
  background-repeat: repeat-x, repeat-x, repeat-y, repeat-y;
  background-size: 16px 2px, 16px 2px, 2px 16px, 2px 16px;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  animation: ants 0.9s linear infinite;
}
.stage.is-working .ants { display: block; }

@keyframes ants {
  to { background-position: 16px 0, -16px 100%, 0 -16px, 100% 16px; }
}

.split, .handle, .tag { display: none; }
.stage.is-done .split, .stage.is-done .tag { display: block; }
.stage.is-done .handle { display: grid; }

.stage.is-done::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--pos);
  width: 3px;
  margin-left: -1.5px;
  background: var(--cut);
  box-shadow: 0 0 0 1px rgba(16, 35, 58, 0.4);
  pointer-events: none;
}

.split {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  touch-action: pan-y;
}

.handle {
  position: absolute;
  top: 50%;
  left: var(--pos);
  z-index: 1;
  width: 42px;
  height: 42px;
  margin: -21px 0 0 -21px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--cut);
  color: var(--ink);
  pointer-events: none;
}
.handle svg { width: 22px; height: 22px; }
.split:focus-visible + .handle { outline: 3px solid var(--focus); outline-offset: 3px; }

/* Popisek jde přetáhnout myší nebo kliknutím přesunout dolů a zpět nahoru, když zakrývá obsah. */
.tag {
  position: absolute;
  z-index: 3;
  top: 10px;
  margin: 0;
  padding: 3px 10px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fff;
  background: rgba(16, 35, 58, 0.78);
  cursor: grab;
  touch-action: none;
}
.tag.is-dragging { cursor: grabbing; }
.tag:hover { background: rgba(16, 35, 58, 0.92); }
.tag:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.tag.is-down { top: auto; bottom: 10px; }
.tag-before { left: 10px; }
.tag-after { right: 10px; }

.item-name { margin: 0; font-size: 1.125rem; font-weight: 600; overflow-wrap: anywhere; }
.item-meta { margin: 2px 0 0; font-size: 0.9375rem; color: var(--muted); }
.item-meta:empty { display: none; }
.item-status { margin: 14px 0 0; }
.item.is-error .item-status { color: var(--error); font-weight: 500; }

.choice { margin: 22px 0 0; padding: 0; border: 0; }
.choice legend { margin-bottom: 8px; padding: 0; font-weight: 600; }
.choice label { display: inline-flex; align-items: center; gap: 7px; margin: 0 18px 8px 0; cursor: pointer; }
.choice input[type="radio"],
.choice input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--mat); }
.choice label:has(input:disabled) { color: var(--muted); cursor: default; }
.kind label { display: flex; margin-right: 0; }
.kind + .bg,
.bg + .crop { margin-top: 14px; }
.btn-region,
.bg .btn-edit { display: block; margin-top: 2px; }
.bg-color {
  width: 36px;
  height: 28px;
  padding: 0 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  cursor: pointer;
}

/* Barva čar: vlastní paleta na plátně, kód HEX a složky R, G, B. */
.ink-palette {
  display: block;
  width: 100%;
  max-width: 360px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: crosshair;
  touch-action: none;
}
.ink-hint { margin: 6px 0 8px; font-size: 0.875rem; color: var(--muted); }
.ink-codes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.ink-codes + .ink-codes { margin-top: 8px; }
.ink .ink-codes label { margin: 0; gap: 6px; cursor: default; }
.ink-swatch { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 6px; background: #000000; }
.ink-codes input {
  font: inherit;
  font-size: 0.9375rem;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.ink-codes .ink-hex { width: 6.5em; font-family: ui-monospace, Consolas, monospace; }
.ink-codes input[type="number"] { width: 4.4em; }
.ink-codes .ink-hex[aria-invalid="true"] { border-color: var(--error); }
.ink-orig, .ink-pick { display: inline-flex; align-items: center; gap: 6px; }
.ink-orig svg, .ink-pick svg { width: 18px; height: 18px; flex: none; }
.ink-orig[aria-pressed="true"] { color: var(--ink); background: var(--cut); box-shadow: 0 0 0 4px var(--cut); border-radius: 4px; text-decoration: none; }

/* Kapátko z originálu: celý originál bez popisků, malý kroužek místo kurzoru, posuvník nereaguje. */
.stage.is-picking { touch-action: none; }
.stage.is-picking,
.stage.is-picking * { cursor: url('kapatko.svg') 7 7, crosshair; }
.stage.is-picking .split { pointer-events: none; }
.stage.is-picking .handle,
.stage.is-picking .tag,
.stage.is-picking::after { display: none; }
/* originál pro kapátko: vlastní plátno, každý jeho bod je přesně jeden bod obrazovky */
.pick-view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
/* barva bodu pod kroužkem, u prstu nad místem dotyku */
.pick-chip {
  position: absolute;
  z-index: 4;
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  border: 3px solid #ffffff;
  border-radius: 6px;
  box-shadow: 0 0 0 1px rgba(16, 35, 58, 0.6), 0 2px 6px rgba(16, 35, 58, 0.35);
  pointer-events: none;
}
.ink-orig-hint { margin: 8px 0 0; }

.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; margin-top: 22px; }

/* ---------- jak to funguje */

.info {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 36px;
  padding: 8px 0 32px;
}
.info h2 { margin: 0 0 8px; font-size: 1.125rem; letter-spacing: -0.005em; }
.info p { margin: 0 0 8px; max-width: 40ch; color: var(--muted); }

.foot {
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 24px 44px;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--muted);
}
.foot p { max-width: 80ch; margin: 0 0 6px; }
.foot a { color: inherit; text-underline-offset: 3px; }

/* ---------- úpravy štětcem */

.editor {
  width: min(100vw - 24px, 1240px);
  max-width: none;
  height: calc(100vh - 24px);
  height: calc(100dvh - 24px);
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 16px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 24px 60px rgba(5, 32, 24, 0.45);
}
.editor[open] { display: flex; flex-direction: column; }
.editor::backdrop { background: rgba(16, 35, 58, 0.66); }

.editor-head { padding: 16px 20px 0; }
.editor-head h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.editor-help { margin: 4px 0 0; max-width: 90ch; font-size: 0.9375rem; color: var(--muted); }

.editor-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 22px;
  padding: 12px 20px;
}

.modes { display: inline-flex; gap: 6px; }
.mode {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 12px;
  border: 2px solid var(--line);
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.mode input { position: absolute; opacity: 0; pointer-events: none; }
.mode::before {
  content: '';
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--dot);
}
.mode-keep { --dot: #19964f; }
.mode-remove { --dot: #dc2d3c; }
.mode.is-on, .mode:has(input:checked) { border-color: var(--ink); background: var(--wash); }
.mode:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }

.size { display: inline-flex; align-items: center; gap: 10px; }
.size input { width: 150px; accent-color: var(--mat); }

.editor-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 4px 20px;
  overflow: hidden;
}
.editor-canvas { position: relative; line-height: 0; }
#ed-view {
  display: block;
  border-radius: 6px;
  background-color: var(--check-b);
  background-image: repeating-conic-gradient(var(--check-a) 0 25%, var(--check-b) 0 50%);
  background-size: 20px 20px;
}
#ed-paint {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: crosshair;
}
/* Výřez se vybírá na tmavém podkladu, aby byl vidět okraj obrázku. Odstraněné části
   jsou slabě na šachovnici jako při úpravě štětcem. */
.cropper .editor-stage { background: #4a5662; }
#cr-view {
  display: block;
  background-color: var(--check-b);
  background-image: repeating-conic-gradient(var(--check-a) 0 25%, var(--check-b) 0 50%);
  background-size: 20px 20px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7), 0 6px 18px rgba(0, 0, 0, 0.4);
}
#cr-sel {
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: crosshair;
}

.editor-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 12px 20px 18px;
}
.editor-status { flex: 1 1 260px; margin: 0; min-height: 1.55em; color: var(--muted); }

@media (max-width: 880px) {
  .mat-inner { padding-bottom: 44px; }
  .hero { grid-template-columns: 1fr; gap: 28px; margin-top: 26px; }
  h1 { max-width: none; }
  .sheet { min-height: 300px; padding: 46px 18px; }
  .item { grid-template-columns: 1fr; gap: 18px; padding: 14px; }
  .info { grid-template-columns: 1fr; gap: 22px; }
  .editor { width: 100vw; height: 100vh; height: 100dvh; border-radius: 0; }
  .editor-head, .editor-tools, .editor-foot { padding-left: 14px; padding-right: 14px; }
  .editor-stage { padding: 4px 8px; }
  .editor-help { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ants { animation: none; }
  .btn { transition: none; }
}
