@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2");
}

:root {
  --paper: #e6edef; --panel: #f4f7f8; --ink: #1d3039; --ink-soft: #566c74; --line: #c4d1d5;
  --deep: #165a78; --shallow: #47b3c2; --foam: #c9ece6; --error: #a8392f;
  --pool: #10151d; --crest: #c4501a; --crest-top: #ffb347;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #142028; --panel: #1b2a33; --ink: #e2ecee; --ink-soft: #9db2b7;
    --line: #304650; --deep: #1f7396; --shallow: #5cc8d6; --foam: #d4f3ee; --error: #f08a7e;
    --pool: #0b0f15; --crest: #d65c1f; --crest-top: #ffbd5c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #142028; --panel: #1b2a33; --ink: #e2ecee; --ink-soft: #9db2b7;
  --line: #304650; --deep: #1f7396; --shallow: #5cc8d6; --foam: #d4f3ee; --error: #f08a7e;
  --pool: #0b0f15; --crest: #d65c1f; --crest-top: #ffbd5c;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: inherit; }
html { height: 100%; scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0; height: 100%; background: var(--paper); color: var(--ink);
  font-family: "Bricolage Grotesque", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px; line-height: 1.45;
}
.app { display: grid; grid-template-columns: minmax(300px, 360px) 1fr; height: 100%; }
aside {
  background: var(--panel); border-right: 1px solid var(--line);
  padding: 28px 26px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px;
}
h1 { font-weight: 800; font-size: 2.1rem; line-height: 1.02; margin: 0; letter-spacing: -0.02em; }
.lead { margin: 6px 0 0; color: var(--ink-soft); font-size: 0.95rem; max-width: 34ch; }

form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.88rem; font-weight: 600; }
input[type=number], select {
  font: inherit; font-weight: 400; font-size: 1rem; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-variant-numeric: tabular-nums;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--shallow); outline-offset: 2px; }
.checks { grid-column: 1 / -1; display: flex; gap: 18px; flex-wrap: wrap; }
.checks label { display: flex; align-items: center; gap: 7px; font-size: 0.88rem; }
.checks input { accent-color: var(--deep); width: 17px; height: 17px; }
button {
  grid-column: 1 / -1; font: inherit; font-weight: 600; font-size: 1rem;
  background: var(--ink); color: var(--panel); border: 0; border-radius: 6px; padding: 11px 14px; cursor: pointer;
}
button:hover { background: var(--deep); color: #fff; }
.error { grid-column: 1 / -1; color: var(--error); font-size: 0.9rem; margin: 0; }
.error:empty { display: none; }

.seq { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.seq li {
  font-variant-numeric: tabular-nums; font-size: 0.92rem; padding: 3px 9px; border-radius: 999px; cursor: default;
  background: color-mix(in srgb, var(--c, var(--shallow)) 22%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c, var(--shallow)) 55%, transparent);
}
.seq li.active { background: color-mix(in srgb, var(--c, var(--shallow)) 55%, transparent); }
.section-title { font-size: 0.88rem; font-weight: 600; margin: 0 0 8px; }
.ratio { border-top: 1px solid var(--line); padding-top: 16px; }
.ratio .big { font-size: 2.4rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.ratio p { margin: 6px 0 0; color: var(--ink-soft); font-size: 0.9rem; }

.stage { position: relative; min-height: 0; overflow: hidden; }
canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
canvas.dragging { cursor: grabbing; }
.hint { position: absolute; right: 16px; bottom: 14px; margin: 0; font-size: 0.82rem; color: var(--ink-soft); pointer-events: none; }
.tip {
  position: absolute; pointer-events: none; padding: 5px 9px; border-radius: 5px;
  background: var(--ink); color: var(--panel); font-size: 0.88rem; font-weight: 600;
  font-variant-numeric: tabular-nums; transform: translate(12px, -120%); white-space: nowrap; display: none;
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 58vh auto; height: auto; }
  .stage { grid-row: 1; }
  aside { grid-row: 2; border-right: 0; border-top: 1px solid var(--line); overflow: visible; }
  body { height: auto; }
  .hint { display: none; }
}
