:root {
  --bg: #f4f1ea; --surface: #ffffff; --text: #22201c; --muted: #6f6a60; --line: #e2ddd2;
  --accent: #3d6b4f; --accent-text: #ffffff; --ok: #2f7d43; --bad: #b23a2e; --warn: #9a6a12;
  --sq-light: #ecdab9; --sq-dark: #ae8a68; --sq-sel: #e6c35c; --sq-last: rgba(214, 190, 60, .45);
  --sq-hint: rgba(61, 107, 79, .55); --shadow: 0 1px 3px rgba(0,0,0,.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a18; --surface: #262421; --text: #ece8e0; --muted: #a39d92; --line: #3a3733;
    --accent: #6aa57f; --accent-text: #10160f; --ok: #6cc183; --bad: #ec7b6e; --warn: #e0b35a;
    --sq-light: #c9b48f; --sq-dark: #8b6c50; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1a18; --surface: #262421; --text: #ece8e0; --muted: #a39d92; --line: #3a3733;
  --accent: #6aa57f; --accent-text: #10160f; --ok: #6cc183; --bad: #ec7b6e; --warn: #e0b35a;
  --sq-light: #c9b48f; --sq-dark: #8b6c50; --shadow: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.35rem; margin: 0 0 .2rem; }
h2 { font-size: 1.02rem; margin: 0 0 .6rem; }
h3 { font-size: .98rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.top { display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; padding: .8rem 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; padding: 16px; max-width: 1400px; margin: 0 auto; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .view { order: -1; } }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; box-shadow: var(--shadow); }
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.view { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: .5rem; }
label { font-size: .88rem; color: var(--muted); }
input[type=url] { width: 100%; padding: .55rem .6rem; border: 1px solid var(--line); border-radius: 7px; background: var(--bg); color: var(--text); font: inherit; }
input:disabled { opacity: .6; }
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: .5rem .8rem; border-radius: 7px; font: inherit; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.tag { font-size: .72rem; font-weight: 600; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 1px 8px; color: var(--muted); vertical-align: middle; }
.seg { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.seg label { color: var(--text); }
.side-pick button { border: 1px solid var(--line); background: var(--bg); color: var(--text); padding: .4rem .7rem; border-radius: 7px; font: inherit; cursor: pointer; }
.side-pick button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.status { margin-top: .6rem; padding: .55rem .7rem; border-radius: 7px; background: var(--bg); font-size: .9rem; }
.status.err { color: var(--bad); }
.jobs, .trainers, .lines, .ideas { list-style: none; padding: 0; margin: 0; }
.jobs li { font-size: .85rem; padding: .35rem 0; border-top: 1px dashed var(--line); }
.trainers li { padding: .6rem .6rem; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.trainers li:hover { background: var(--bg); }
.trainers li.on { border-color: var(--accent); background: var(--bg); }
.trainers .tt { font-weight: 600; }
.th-row { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.t-summary { margin: .6rem 0 .4rem; }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-top: .4rem; }
.tabs button { border: 0; background: none; color: var(--muted); padding: .5rem .8rem; font: inherit; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.trainzone { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .trainzone { grid-template-columns: 1fr; } }
.board-wrap { min-width: 0; }
.board { display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); container-type: inline-size; width: 100%; max-width: 560px; aspect-ratio: 1; border-radius: 6px; overflow: hidden; user-select: none; touch-action: manipulation; box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.sq { position: relative; min-width: 0; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sq.l { background: var(--sq-light); } .sq.d { background: var(--sq-dark); }
.sq.last::before { content: ""; position: absolute; inset: 0; background: var(--sq-last); }
.sq.sel::before { content: ""; position: absolute; inset: 0; background: var(--sq-sel); opacity: .75; }
.sq.hint::before { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 4px var(--sq-hint); }
.sq.bad::before { content: ""; position: absolute; inset: 0; background: rgba(200, 50, 40, .45); }
.sq.check::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(230,40,30,.8), transparent 70%); }
.sq.dot::after { content: ""; position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(30, 30, 30, .28); }
.sq.cap::after { content: ""; position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(30, 30, 30, .28); }
.pc { position: relative; z-index: 1; font-size: 10.5cqw; line-height: 1; font-family: "Segoe UI Symbol", "DejaVu Sans", "Noto Sans Symbols2", serif; }
.pc.w { color: #fffdf6; text-shadow: 0 0 1px #000, 0 0 1px #000, 0 1px 2px rgba(0,0,0,.6); -webkit-text-stroke: 1px #2b2622; }
.pc.b { color: #1d1a17; text-shadow: 0 1px 1px rgba(255,255,255,.25); }
.coord { position: absolute; font-size: 10px; font-weight: 700; opacity: .7; z-index: 2; color: #3a2d20; }
.coord.f { right: 3px; bottom: 1px; } .coord.r { left: 3px; top: 1px; }
.controls { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }
.panel { display: flex; flex-direction: column; gap: .5rem; min-height: 200px; }
.l-title { font-weight: 700; font-size: 1.05rem; }
.msg { font-weight: 600; min-height: 1.4em; }
.msg.ok { color: var(--ok); } .msg.bad { color: var(--bad); } .msg.warn { color: var(--warn); }
.note { background: var(--bg); border-left: 3px solid var(--accent); padding: .6rem .7rem; border-radius: 4px; min-height: 3em; white-space: pre-wrap; }
.note:empty { display: none; }
.movelist { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: .15rem .5rem; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9rem; }
.movelist .cur { background: var(--sq-sel); color: #222; border-radius: 3px; padding: 0 3px; }
.movelist .hid { color: var(--muted); }
.lines-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 1100px) { .lines-wrap { grid-template-columns: 1fr; } }
.lines li { display: flex; justify-content: space-between; gap: .6rem; padding: .45rem .5rem; border-radius: 7px; cursor: pointer; }
.lines li:hover { background: var(--bg); }
.lines li.on { background: var(--bg); outline: 1px solid var(--accent); }
.badge { font-size: .75rem; white-space: nowrap; color: var(--muted); }
.badge.done { color: var(--ok); font-weight: 600; }
.ideas-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .ideas-grid { grid-template-columns: 1fr; } }
.video { position: relative; aspect-ratio: 16/9; background: #000; border-radius: 6px; overflow: hidden; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ideas li { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.ideas .it { font-weight: 700; }
.ideas .ts { font-size: .82rem; margin-left: .4rem; }
.ideas .il { margin-top: .4rem; display: flex; flex-wrap: wrap; gap: .3rem; }
.ideas .il button { font-size: .8rem; padding: .2rem .5rem; }
.empty p { margin: 0; }
