:root {
  color-scheme: light;
  --ink: #1f252b;
  --muted: #5d6875;
  --line: #d8dee6;
  --panel: #f5f7f2;
  --paper: #fffdf7;
  --accent: #0f766e;
  --accent-strong: #0a5d57;
  --warm: #c76a11;
  --danger: #be123c;
  --tile-a: #f7e7bd;
  --tile-b: #dbece7;
  --tile-c: #e8e0f4;
  --paint: #2f4f7f;
  --shadow: 0 18px 48px rgba(32, 39, 47, .13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #e8ece4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  min-height: 100vh;
}

.toolbar {
  display: flex;
  flex-direction: column;
  gap: 17px;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 4px;
}

.mark {
  width: 40px;
  height: 40px;
  background:
    linear-gradient(135deg, transparent 47%, #ffffff 48% 52%, transparent 53%),
    conic-gradient(from 45deg, #0f766e, #c76a11, #334155, #0f766e);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
  line-height: 1.1;
}

.brand p,
.canvas-head p,
.readout,
.tool-group label,
.tool-group span,
.hint,
.canvas-foot,
.status {
  color: var(--muted);
  font-size: 13px;
}

.tool-group {
  display: grid;
  gap: 8px;
}

.hint {
  line-height: 1.35;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 9px 10px;
  color: var(--ink);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.segmented.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.segmented.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

button:hover {
  border-color: #96a4b4;
}

button:active {
  transform: translateY(1px);
}

button.active {
  border-color: var(--accent);
  background: #ddf3ee;
  color: var(--accent-strong);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

button.primary:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: .46;
  background: #f2f4f6;
  color: #8a94a3;
}

button.locked {
  background: #f1f4f6;
  color: #7a8593;
}

button.locked::after {
  content: " zamceno";
  display: block;
  font-size: 11px;
  color: #8b95a4;
  line-height: 1.1;
}

.sliders strong {
  color: var(--ink);
  font-weight: 650;
}

input[type="range"] {
  accent-color: var(--accent);
}

.checks {
  gap: 10px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.checks input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

.actions .primary {
  grid-column: 1 / -1;
}

.workspace {
  min-width: 0;
  padding: 22px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.canvas-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
}

.canvas-head h2 {
  font-size: 24px;
  line-height: 1.15;
}

.status-stack {
  display: grid;
  justify-items: end;
  gap: 5px;
  min-width: 260px;
}

.status {
  border: 1px solid #b7d9ca;
  background: #edf8f2;
  color: #14614a;
  border-radius: 999px;
  padding: 5px 10px;
  max-width: 420px;
}

.status.warn {
  border-color: #f4b4c4;
  background: #fff1f4;
  color: var(--danger);
}

.readout {
  text-align: right;
}

#stage {
  width: 100%;
  height: 100%;
  min-height: 620px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  touch-action: none;
}

.canvas-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
}

.canvas-foot strong {
  color: var(--ink);
}

.tile-fill-a {
  fill: var(--tile-a);
}

.tile-fill-b {
  fill: var(--tile-b);
}

.tile-fill-c {
  fill: var(--tile-c);
}

.tile-line {
  fill: none;
  stroke: #202936;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.tile-line.invalid {
  stroke: var(--danger);
}

.paint-line {
  fill: none;
  stroke: var(--paint);
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .92;
}

.grid-line {
  stroke: rgba(79, 89, 102, .3);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.base-shape {
  fill: none;
  stroke: rgba(15, 118, 110, .48);
  stroke-width: 1.4;
  stroke-dasharray: 6 5;
}

.edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 18;
  cursor: pointer;
}

.edge-guide {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.edge-guide.source {
  stroke: rgba(15, 118, 110, .9);
  stroke-width: 3;
}

.edge-guide.derived {
  stroke: rgba(95, 108, 122, .8);
  stroke-width: 2;
  stroke-dasharray: 7 6;
}

.edge-active {
  fill: none;
  stroke: var(--warm);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.rule-arrow {
  fill: none;
  stroke: rgba(199, 106, 17, .8);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  marker-end: url(#ruleArrowHead);
  pointer-events: none;
}

.rule-label {
  fill: rgba(91, 63, 23, .88);
  font-size: 12px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #fffdf7;
  stroke-width: 4px;
  stroke-linejoin: round;
  pointer-events: none;
}

.rule-lock {
  fill: rgba(91, 100, 112, .9);
  font-size: 13px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #fffdf7;
  stroke-width: 4px;
  pointer-events: none;
}

.intersection-marker {
  fill: #be123c;
  stroke: #fff;
  stroke-width: 3;
  pointer-events: none;
}

.intersection-label {
  fill: #be123c;
  font-size: 12px;
  font-weight: 800;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 4px;
  pointer-events: none;
}

.handle {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 2.4;
  cursor: grab;
}

.handle.endpoint {
  fill: #eef2f7;
  stroke: #8995a3;
  cursor: default;
}

.handle.selected {
  fill: var(--warm);
  stroke: #7c2d12;
}

.origin-marker {
  fill: #fff;
  stroke: rgba(15, 118, 110, .6);
  stroke-width: 2;
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .toolbar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .actions,
  .segmented {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .actions .primary {
    grid-column: auto;
  }

  .canvas-head {
    align-items: start;
    flex-direction: column;
  }

  .status-stack {
    min-width: 0;
    justify-items: start;
  }

  .readout {
    text-align: left;
  }

  #stage {
    min-height: 560px;
  }
}
