:root {
  --bg: #070d16;
  --panel: #0c1626;
  --panel2: #111e33;
  --line: rgba(255, 255, 255, 0.08);
  --line2: rgba(255, 255, 255, 0.14);
  --text: #dbe6f6;
  --muted: #8395ad;
  --accent: #ffd166;
  --accent2: #5fd0ff;
  --home: #ff6b4a;
  --away: #4d9bff;
  --danger: #ff6b6b;
  --radius: 10px;
  font-synthesis: none;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  background: #16243a;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
button:hover { background: #1d2f4a; border-color: var(--line2); }
button:active { transform: translateY(1px); }
button.primary {
  background: linear-gradient(180deg, #ffd166, #f0b93f);
  color: #201803;
  border-color: #ffdf8d;
  font-weight: 700;
}
button.primary:hover { filter: brightness(1.06); }
button.ghost { background: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); }
button.danger { background: #33161c; color: #ff9a9a; border-color: #5c2230; }
button.danger:hover { background: #451c25; }
button.wide { width: 100%; }
button.icon-btn {
  display: grid; place-items: center;
  width: 32px; height: 32px; padding: 0;
}
button:disabled { opacity: .38; cursor: default; }

#app {
  display: grid;
  grid-template-rows: 54px minmax(0, 1fr) 152px;
  height: 100vh;
  height: 100dvh;
}

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  background: linear-gradient(180deg, #0d1828, #0a1320);
  border-bottom: 1px solid var(--line);
  z-index: 5;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; letter-spacing: .3px; font-size: 14px;
  white-space: nowrap;
}
.ball-dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #f3ff9b, #cbe63f 65%, #9bb51f);
  box-shadow: 0 0 12px rgba(211, 236, 80, .45);
}
.spacer { flex: 1; }
.cams { display: flex; gap: 6px; }
.chip {
  padding: 5px 11px; border-radius: 20px; font-size: 12px;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
}
.chip:hover { color: var(--text); }
.chip.active { background: rgba(95, 208, 255, .13); border-color: rgba(95, 208, 255, .5); color: #bfeaff; }
.actions { display: flex; gap: 8px; align-items: center; }
.actions button { font-size: 12px; }

/* ---------- layout ---------- */
main {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr) 316px;
  min-height: 0;
}

#rail {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 6px;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.mode, .mini {
  width: 56px; padding: 8px 2px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: transparent; border: 1px solid transparent;
  color: var(--muted); border-radius: 10px;
}
.mode svg, .mini svg { width: 22px; height: 22px; fill: currentColor; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
.mode span, .mini span { font-size: 10px; }
.mode:hover, .mini:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.mode.active {
  color: var(--accent); background: rgba(255, 209, 102, .1);
  border-color: rgba(255, 209, 102, .28);
}
.rail-sep { width: 34px; height: 1px; background: var(--line); margin: 6px 0; }

/* ---------- stage ---------- */
#stage { position: relative; min-height: 0; overflow: hidden; background: #060c14; }
#stage canvas { position: absolute; left: 0; top: 0; display: block; }
#hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 3;
  padding: 6px 14px; border-radius: 20px;
  background: rgba(8, 16, 28, .78); border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; white-space: nowrap;
  backdrop-filter: blur(8px);
  pointer-events: none;
  opacity: 0; transition: opacity .2s;
}
#hint.show { opacity: 1; }
#drop-tip {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  z-index: 3;
  padding: 6px 14px; border-radius: 20px;
  background: rgba(255, 209, 102, .12); border: 1px solid rgba(255, 209, 102, .4);
  color: #ffe3a3; font-size: 12px; white-space: nowrap;
  pointer-events: none; display: none;
}
body[data-mode="shot"] #drop-tip { display: block; }

#zone-legend {
  position: absolute; left: 14px; top: 14px; z-index: 3;
  display: flex; gap: 12px; align-items: center;
  padding: 7px 11px; border-radius: 9px;
  background: rgba(8, 16, 28, 0.72); border: 1px solid var(--line);
  backdrop-filter: blur(6px); font-size: 11px; color: #b9c9dd;
  pointer-events: none;
}
#zone-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
#zone-legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.topbar-sep { width: 1px; height: 22px; background: var(--line); margin: 0 2px; }
.phase-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 11px 5px 9px; border-radius: 9px;
  background: #0b1524; border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; white-space: nowrap;
}
.phase-toggle:hover { color: var(--text); border-color: var(--line2); }
.phase-toggle .track {
  width: 26px; height: 14px; border-radius: 7px; background: #223349;
  position: relative; transition: background .15s; flex: none;
}
.phase-toggle .track::after {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 10px; height: 10px; border-radius: 50%; background: #8da0b8;
  transition: left .15s, background .15s;
}
.phase-toggle.active { color: #ffe3a3; border-color: rgba(255, 209, 102, .5); background: rgba(255, 209, 102, .08); }
.phase-toggle.active .track { background: rgba(255, 209, 102, .3); }
.phase-toggle.active .track::after { left: 14px; background: #ffd166; }

#coach {
  position: absolute; left: 14px; bottom: 14px; z-index: 4;
  width: 336px; max-width: calc(100% - 28px);
  padding: 11px 13px 12px;
  background: rgba(8, 16, 28, 0.86); border: 1px solid var(--line2);
  border-radius: 11px; backdrop-filter: blur(8px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
.coach-head { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.coach-phase {
  font-size: 10.5px; padding: 2px 8px; border-radius: 9px;
  border: 1px solid currentColor; font-weight: 600;
}
.coach-step { flex: 1; font-size: 10.5px; color: var(--muted); }
.coach-edit {
  font-size: 10.5px; padding: 2px 8px; border-radius: 6px;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
}
.coach-edit:hover { color: var(--text); border-color: var(--line2); }
.coach-delete {
  font-size: 10.5px; padding: 2px 8px; border-radius: 6px;
  background: transparent; border: 1px solid rgba(255, 90, 92, .35); color: #ff8f8f;
}
.coach-delete:hover { background: rgba(255, 90, 92, .12); }
#coach .coach-head .x-btn { margin-left: 0; }
.coach-phase-sel {
  font-size: 10.5px; padding: 2px 5px; border-radius: 6px;
  background: #0a1422; border: 1px solid var(--line2); color: #dbe6f6; width: auto;
}
#coach [contenteditable="true"]:empty::before {
  content: attr(data-ph); color: #5f7590;
}
#coach [contenteditable="true"] {
  outline: 1px dashed rgba(255, 209, 102, .55); border-radius: 4px;
  padding: 1px 3px; margin: -1px -3px; min-width: 40px;
}
.coach-stats {
  margin-top: 7px; padding-top: 7px; border-top: 1px solid var(--line);
  font-size: 10px; color: #7f93ab; letter-spacing: .02em;
}
.coach-title { font-size: 13.5px; font-weight: 700; color: #eef5ff; margin-bottom: 5px; line-height: 1.35; }
.coach-why { margin: 0 0 7px; font-size: 11.5px; line-height: 1.6; color: #aebfd4; }
.coach-keys { font-size: 11px; line-height: 1.55; color: #93a7be; border-top: 1px solid var(--line); padding-top: 7px; }
.coach-keys b { color: #ffd166; font-weight: 600; margin-right: 6px; }
.ph-attack { color: #ffd166; background: rgba(255, 209, 102, .1); }
.ph-force { color: #ff9f43; background: rgba(255, 159, 67, .1); }
.ph-rally { color: #5fd0ff; background: rgba(95, 208, 255, .1); }
.ph-counter { color: #b48cff; background: rgba(180, 140, 255, .1); }
.ph-defense { color: #ff5a5c; background: rgba(255, 90, 92, .1); }

.tpl-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 10px; }
.tpl-card {
  background: #0a1422; border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; display: flex; flex-direction: column; gap: 6px;
}
.tpl-card .tpl-name { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 700; color: #eaf3ff; }
.tpl-card .tpl-tag { font-size: 11px; color: var(--muted); line-height: 1.5; min-height: 32px; }
.tpl-card .tpl-phases { display: flex; gap: 5px; flex-wrap: wrap; }
.tpl-card .tpl-phases .ph { font-size: 9.5px; padding: 1px 6px; border-radius: 8px; border: 1px solid currentColor; }
.tpl-card .tpl-load {
  margin-top: 4px; font-size: 11.5px; padding: 5px 8px;
  background: rgba(255, 209, 102, .14); border-color: rgba(255, 209, 102, .4); color: #ffe3a3;
}
.tpl-card .tpl-load:hover { background: rgba(255, 209, 102, .22); }
.match-stats {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding: 8px 10px; margin-bottom: 10px;
  background: #0a1422; border: 1px solid var(--line); border-radius: 9px;
  font-size: 11px; color: var(--muted);
}
.match-stats .ph { font-size: 10px; padding: 1px 7px; border-radius: 9px; border: 1px solid currentColor; }
.match-stats b { color: #dbe6f6; font-weight: 600; }
.lib-h { margin: 14px 0 9px; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.modal-body { padding: 0 14px 14px; overflow-y: auto; }
#credit {
  position: absolute; right: 16px; bottom: 12px; z-index: 3;
  text-align: right; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
  pointer-events: none; user-select: none; white-space: nowrap;
}
#credit .credit-logo {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 13px; letter-spacing: 0.14em;
  color: rgba(228, 240, 255, 0.62);
  margin-bottom: 4px; line-height: 1;
}
#credit .credit-logo b { font-weight: 800; color: rgba(246, 251, 255, 0.86); }
#credit .credit-logo span { font-weight: 300; letter-spacing: 0.05em; margin-left: 5px; }
#credit .credit-line { font-size: 10px; letter-spacing: 0.07em; color: rgba(203, 219, 238, 0.46); }
#credit .credit-line b { color: rgba(232, 243, 255, 0.72); font-weight: 600; }

/* ---------- panel ---------- */
#panel {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto; overflow-x: hidden;
  padding: 4px 0 30px;
  scrollbar-width: thin;
}
#panel::-webkit-scrollbar { width: 8px; }
#panel::-webkit-scrollbar-thumb { background: #1e2f47; border-radius: 4px; }
.ps { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ps h3 {
  margin: 0 0 10px; font-size: 11px; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.badge {
  padding: 1px 7px; border-radius: 10px; font-size: 10px;
  background: rgba(95, 208, 255, .12); color: #9fdcff; letter-spacing: 0;
}
.field { display: block; margin-bottom: 9px; }
.field > span {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11px; color: var(--muted); margin-bottom: 4px;
}
.field em { font-style: normal; color: var(--accent); font-variant-numeric: tabular-nums; }
input[type="text"], input[type="number"], input:not([type]), select, textarea {
  width: 100%; padding: 7px 9px;
  background: #0a1422; border: 1px solid var(--line);
  border-radius: 7px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: rgba(95, 208, 255, .55); }
textarea { resize: vertical; min-height: 44px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
input[type="range"] {
  width: 100%; -webkit-appearance: none; height: 4px; border-radius: 2px;
  background: #1c2c44; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 13px; height: 13px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0b1523; cursor: pointer;
}
.empty { color: var(--muted); font-size: 12px; padding: 4px 0 2px; }
.x-btn {
  margin-left: auto; width: 22px; height: 22px; padding: 0;
  display: grid; place-items: center; border-radius: 6px;
  background: transparent; border: 1px solid transparent;
  color: var(--muted); font-size: 16px; line-height: 1; text-transform: none;
}
.x-btn:hover { background: #33161c; color: #ff9a9a; border-color: #5c2230; }

.warn { color: #ffb0a8; background: rgba(255, 107, 107, .1); border: 1px solid rgba(255, 107, 107, .3);
  border-radius: 7px; padding: 6px 9px; font-size: 11px; margin-bottom: 9px; }
.tip { color: #6f8098; font-size: 11px; margin: 10px 0 0; line-height: 1.55; }
.tool-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tool-row button { padding: 6px 2px; font-size: 11px; white-space: nowrap; }
.tool-note { color: #6f8098; font-size: 10.5px; line-height: 1.55; margin: 8px 0 0; }
.tool-note code { background: #0a1422; padding: 0 4px; border-radius: 3px; color: #9fb4cb; }

.shot-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.shot-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 8px;
  background: #0a1422; border: 1px solid var(--line);
  cursor: pointer; font-size: 12px;
}
.shot-item:hover { border-color: var(--line2); }
.shot-item.active { border-color: rgba(255, 209, 102, .55); background: rgba(255, 209, 102, .07); }
.shot-item .n {
  width: 17px; height: 17px; border-radius: 50%; display: grid; place-items: center;
  font-size: 9.5px; background: #1b2b44; color: #a9c0da; flex: none;
}
.shot-item .who { font-weight: 600; }
.shot-item .meta { margin-left: auto; color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.shot-item .swatch { width: 4px; height: 16px; border-radius: 2px; flex: none; }
.shot-item-del {
  flex: none; width: 20px; height: 20px; padding: 0; margin-left: 4px;
  display: grid; place-items: center; border-radius: 6px;
  background: transparent; border: 1px solid transparent;
  color: #c96b6b; cursor: pointer;
}
.shot-item-del:hover { background: #33161c; color: #ff9a9a; border-color: #5c2230; }
.shot-item-del svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- timeline ---------- */
#timeline {
  background: #0a1320; border-top: 1px solid var(--line);
  padding: 6px 12px 10px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 0;
}
.tl-bar { display: flex; align-items: center; gap: 10px; height: 26px; }
.tl-bar .icon-btn { background: var(--accent); color: #221a04; border: none; width: 28px; height: 28px; border-radius: 8px; }
.tl-bar .icon-btn:hover { filter: brightness(1.07); background: var(--accent); }
.tl-bar .icon-btn svg { width: 14px; height: 14px; fill: currentColor; }
.time-read { font-variant-numeric: tabular-nums; font-size: 12px; color: #c9d8ea; min-width: 96px; }
#speed { width: auto; padding: 3px 6px; font-size: 11px; background: #101d2f; }
.chk { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); }
.chk input { accent-color: var(--accent); }
.tl-hint { margin-left: auto; font-size: 11px; color: #5f7389; }

.tl-track {
  position: relative; flex: 1; min-height: 0;
  background: #081220; border: 1px solid var(--line);
  border-radius: 10px; padding: 2px 10px 2px 0;
  overflow: hidden; touch-action: none; cursor: crosshair;
}
.tl-ruler { display: flex; height: 15px; border-bottom: 1px solid var(--line); }
.tl-ruler .lbl { width: 44px; flex: none; }
.tl-ruler .lane { position: relative; flex: 1; }
.tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, .07); }
.tick span { position: absolute; left: 3px; top: 2px; font-size: 9px; color: #63788f; font-variant-numeric: tabular-nums; }
.tl-rows { padding: 1px 0; }
.tl-row { display: flex; height: 18px; align-items: center; }
.tl-row .lbl { width: 44px; flex: none; font-size: 9.5px; color: #63788f; padding-left: 8px; }
.tl-row .lane { position: relative; flex: 1; height: 100%; }
.tl-row .lane::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px;
  background: rgba(255, 255, 255, .045);
}
.shot-bar {
  position: absolute; top: 1px; height: 18px; border-radius: 5px;
  display: flex; align-items: center; gap: 4px;
  background: rgba(255, 107, 74, .3); border: 1px solid rgba(255, 107, 74, .55);
  font-size: 9px; line-height: 12px; padding: 0 4px; color: #ffd0c4;
  white-space: nowrap; overflow: hidden; cursor: pointer;
}
.shot-bar[data-actor="B"] { background: rgba(77, 155, 255, .28); border-color: rgba(77, 155, 255, .55); color: #cfe4ff; }
.shot-bar.active { box-shadow: 0 0 0 1px var(--accent); }
.shot-bar .shot-label {
  flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  padding-left: 2px; line-height: 14px;
}
.shot-del {
  flex: none; width: 16px; height: 16px; padding: 0;
  display: grid; place-items: center; border-radius: 50%;
  background: #ff5a5a; border: none;
  color: #fff; font-size: 12px; font-weight: 700; line-height: 1;
  cursor: pointer; box-shadow: 0 1px 3px rgba(0, 0, 0, .35);
}
.shot-del:hover { background: #ff3232; transform: scale(1.08); }
.note-mark {
  position: absolute; top: 1px; transform: translateX(-50%);
  width: 18px; height: 17px; padding: 0; border-radius: 4px;
  display: grid; place-items: center; font-size: 9.5px; font-weight: 700;
  background: #16243a; border: 1px solid var(--line2); color: #9fb4cb;
  cursor: pointer; line-height: 1;
}
.note-mark:hover { border-color: #fff; color: #fff; }
.note-mark.empty { border-style: dashed; color: #7f93ab; background: transparent; }
.key {
  position: absolute; top: 50%; width: 8px; height: 8px; margin-top: -4px;
  transform: translateX(-50%) rotate(45deg);
  background: #2c3f58; border: 1px solid #5b7593; border-radius: 1px;
  cursor: pointer;
}
.key[data-actor="A"] { background: #4a261d; border-color: var(--home); }
.key[data-actor="B"] { background: #182a44; border-color: var(--away); }
.key:hover { border-color: #fff; }
.tl-playhead {
  position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent);
  pointer-events: none; box-shadow: 0 0 8px rgba(255, 209, 102, .5);
}
.tl-playhead i {
  position: absolute; top: 0; left: -4px; width: 10px; height: 7px;
  background: var(--accent); clip-path: polygon(0 0, 100% 0, 50% 100%);
}

/* ---------- modal ---------- */
#welcome {
  position: fixed; inset: 0; z-index: 50;
  display: flex; justify-content: center; align-items: flex-start;
  overflow-y: auto; padding: 22px;
  background: rgba(3, 7, 13, 0.7); backdrop-filter: blur(7px);
}
.welcome-box {
  position: relative; width: min(780px, 100%);
  background: #0c1626; border: 1px solid var(--line2); border-radius: 16px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .65);
  overflow: hidden; margin: auto 0;
  animation: pop .22s ease-out;
}
.welcome-x { position: absolute; right: 12px; top: 12px; width: 28px; height: 28px; z-index: 2; }
.welcome-top {
  padding: 26px 28px 20px;
  background: radial-gradient(120% 140% at 0% 0%, rgba(95, 208, 255, .16), transparent 60%),
              radial-gradient(120% 140% at 100% 0%, rgba(255, 209, 102, .13), transparent 55%);
  border-bottom: 1px solid var(--line);
}
.welcome-kicker { font-size: 10px; letter-spacing: .18em; color: #7f93ab; margin-bottom: 9px; }
.welcome-top h2 { margin: 0 0 7px; font-size: 21px; letter-spacing: .01em; color: #f2f7ff; }
.welcome-top p { margin: 0; font-size: 12.5px; color: #a6b8cd; }
.welcome-guide { display: flex; align-items: stretch; gap: 10px; padding: 16px 22px 2px; }
.guide-step {
  flex: 1; padding: 9px 10px 8px; border-radius: 10px;
  background: #0a1422; border: 1px solid var(--line);
}
.guide-step svg { width: 100%; height: auto; display: block; }
.guide-cap { display: flex; align-items: baseline; gap: 7px; margin-top: 7px; font-size: 11px; color: #8fa3ba; }
.guide-cap b { color: #e9f2ff; font-size: 11.5px; font-weight: 700; }
.guide-arrow { display: flex; align-items: center; color: #5b7593; font-size: 16px; }
.welcome-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 18px 22px 6px; }
.wstep { display: flex; gap: 11px; padding: 11px 12px; background: #0a1422; border: 1px solid var(--line); border-radius: 10px; }
.wnum {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(255, 209, 102, .16);
  color: #ffd166; font-size: 11px; font-weight: 700; border: 1px solid rgba(255, 209, 102, .4);
}
.wstep b { display: block; font-size: 12.5px; color: #e9f2ff; margin-bottom: 3px; }
.wstep p { margin: 0; font-size: 11.5px; line-height: 1.6; color: #93a7be; }
.welcome-keys {
  display: flex; flex-wrap: wrap; gap: 12px; padding: 12px 24px 4px;
  font-size: 10.5px; color: #7f93ab;
}
.welcome-keys kbd {
  display: inline-block; min-width: 18px; text-align: center;
  padding: 1px 5px; margin-right: 4px; border-radius: 4px;
  background: #0a1422; border: 1px solid var(--line2); color: #c9d8ea; font-size: 10px;
  font-family: inherit;
}
.welcome-actions { display: flex; gap: 9px; justify-content: flex-end; padding: 14px 22px 6px; }
.welcome-actions button { font-size: 12px; padding: 7px 13px; }
.welcome-ghost { background: transparent; color: #a6b8cd; border: 1px solid var(--line2); }
.welcome-ghost:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.welcome-tutorial { color: #ffd166; border-color: rgba(255, 209, 102, .55); }
.welcome-tutorial:hover { color: #0b1524; background: #ffd166; border-color: #ffd166; }
.welcome-foot { padding: 6px 24px 18px; text-align: right; font-size: 9.5px; letter-spacing: .06em; color: #5f7b93; }
.help-btn { width: 28px; height: 28px; border-radius: 50%; font-weight: 700; color: var(--muted); }

#modal {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(3, 7, 13, .72); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 24px;
}
.modal-box {
  width: min(780px, 100%); max-height: 82vh; display: flex; flex-direction: column;
  background: #0c1626; border: 1px solid var(--line2); border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 15px; }
.library-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.lib-card { background: #0a1422; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.lib-card .thumb { aspect-ratio: 16 / 10; background: #081120; object-fit: cover; width: 100%; display: block; }
.lib-card .body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; }
.lib-card .name { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px; min-width: 0; }
.lib-card .name-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.num {
  flex: none; font-size: 9.5px; font-weight: 700; letter-spacing: .05em;
  padding: 1px 5px; border-radius: 5px; border: 1px solid;
}
.num.tpl { color: #ffd166; border-color: rgba(255, 209, 102, .4); background: rgba(255, 209, 102, .09); }
.num.mine { color: #5fd0ff; border-color: rgba(95, 208, 255, .35); background: rgba(95, 208, 255, .08); }
.lib-card .meta { font-size: 10.5px; color: var(--muted); }
.lib-card .ops { display: flex; gap: 6px; margin-top: 6px; }
.lib-card .ops button { flex: 1; font-size: 11px; padding: 4px 6px; }
.modal-foot { padding: 10px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.modal-foot code { background: #081120; padding: 1px 5px; border-radius: 4px; }

#toast {
  position: fixed; left: 50%; bottom: 166px; transform: translateX(-50%) translateY(8px);
  padding: 9px 18px; border-radius: 20px;
  background: rgba(16, 30, 48, .95); border: 1px solid var(--line2);
  color: var(--text); font-size: 12px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 60;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .45);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: rgba(255, 107, 107, .5); color: #ffb3b3; }

@media (max-width: 1180px) {
  .brand-name { display: none; }
  .cams { gap: 4px; }
  .chip { padding: 5px 8px; }
  #coach { width: 300px; }
}

@media (max-width: 980px) {
  main { grid-template-columns: 60px minmax(0, 1fr); }
  #panel { display: none; }
  .cams { display: none; }
  #app { grid-template-rows: 50px minmax(0, 1fr) 150px; }
}

@media (max-width: 640px) {
  #topbar { gap: 8px; padding: 0 8px; }
  .brand { font-size: 12.5px; gap: 6px; }
  .ball-dot { width: 11px; height: 11px; }
  #btn-undo, #btn-redo, #btn-help, .topbar-sep { display: none; }
  .actions { gap: 6px; }
  .actions button { padding: 6px 9px; }
  #rail { padding: 8px 4px; }
  .mode, .mini { width: 50px; }
  #timeline { padding: 4px 8px 8px; }
  .tl-hint { display: none; }
  .time-read { min-width: 80px; font-size: 11px; }
  .welcome-steps { grid-template-columns: 1fr; padding: 14px 14px 4px; }
  .welcome-guide { flex-direction: column; padding: 12px 14px 0; }
  .guide-arrow { justify-content: center; transform: rotate(90deg); }
  .welcome-top { padding: 20px 18px 15px; }
  .welcome-top h2 { font-size: 17px; }
  .welcome-actions { padding: 12px 14px 4px; flex-wrap: wrap; }
  .welcome-keys { padding: 10px 16px 2px; }
  .welcome-foot { padding: 4px 16px 14px; }
  #toast { bottom: 148px; }
  #coach { left: 8px; bottom: 8px; width: calc(100% - 16px); }
  #credit { right: 10px; bottom: 9px; }
  #credit .credit-logo { font-size: 11.5px; }
  #credit .credit-line { font-size: 9px; }
}

.welcome-home { color: #9fb3c8; text-decoration: none; }
.welcome-home:hover { color: #e8eef6; text-decoration: underline; }

/* ---------- 手机 / 平板：触控布局 ---------- */
#view { position: relative; overflow: hidden; min-width: 0; min-height: 0; }
.cam-select, #btn-panel, .panel-mobile-bar, #panel-backdrop, .coach-toggle { display: none; }
.cam-select {
  background: #101d2f; border: 1px solid var(--line2); border-radius: 8px;
  color: var(--text); padding: 6px 8px; font-size: 12px; max-width: 112px;
}
#btn-panel {
  background: #16243a; border: 1px solid var(--line2); color: var(--text);
  padding: 6px 10px; border-radius: 8px;
}

@media (max-width: 980px) {
  #app { grid-template-rows: 50px minmax(0, 1fr) 126px; }
  main { grid-template-columns: 56px minmax(0, 1fr); }
  #topbar { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); gap: 8px; }
  #btn-zones, #btn-paths, .topbar-sep { display: none; }
  .cam-select { display: block; }
  #btn-panel { display: inline-flex; }
  #timeline { padding: 4px 8px calc(6px + env(safe-area-inset-bottom)); gap: 4px; }
  .tl-bar { height: 24px; }
  .tl-row { height: 16px; }
  .tl-ruler { height: 14px; }
  .tl-hint { display: none; }

  /* 右侧面板：抽屉 */
  #panel {
    display: block; position: fixed; top: 0; right: 0; bottom: 0;
    width: min(360px, 90vw); z-index: 40;
    transform: translateX(102%); transition: transform .24s ease;
    box-shadow: -18px 0 50px rgba(0, 0, 0, .55);
    border-left: 1px solid var(--line2);
    padding-bottom: calc(30px + env(safe-area-inset-bottom));
    overscroll-behavior: contain;
  }
  body.panel-open #panel { transform: none; }
  #panel-backdrop {
    display: block; position: fixed; inset: 0; z-index: 39;
    background: rgba(0, 0, 0, .5); opacity: 0; pointer-events: none;
    transition: opacity .2s;
  }
  body.panel-open #panel-backdrop { opacity: 1; pointer-events: auto; }
  .panel-mobile-bar {
    display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 2;
    padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line);
  }
  .panel-mobile-bar span { flex: 1; font-size: 12px; letter-spacing: .08em; color: var(--muted); }
  .panel-mobile-bar .primary { padding: 6px 14px; }
  .panel-mobile-bar .x-btn { width: 30px; height: 30px; font-size: 18px; }

  /* 讲解卡：手机默认收起，点箭头展开 */
  #coach { width: min(360px, calc(100% - 16px)); max-height: calc(100% - 16px); overflow: auto; }
  #coach .coach-title, #coach .coach-why, #coach .coach-keys, #coach .coach-stats { display: none; }
  body.coach-expanded #coach .coach-title,
  body.coach-expanded #coach .coach-why,
  body.coach-expanded #coach .coach-keys,
  body.coach-expanded #coach .coach-stats { display: block; }
  .coach-toggle {
    display: grid; place-items: center; width: 26px; height: 24px; padding: 0;
    border-radius: 6px; background: transparent; border: 1px solid var(--line);
    color: var(--muted); font-size: 12px; line-height: 1;
  }
  .coach-toggle:hover { color: var(--text); border-color: var(--line2); }
}

@media (max-width: 640px) {
  .cam-select { max-width: 96px; padding: 5px 6px; font-size: 11.5px; }
  #btn-panel { padding: 5px 8px; font-size: 12px; }
  #coach { left: 8px; bottom: 8px; width: calc(100% - 16px); }
  #credit { right: 8px; bottom: 6px; }
  #credit .credit-line { display: none; }
}

@media (orientation: landscape) and (max-height: 520px) {
  #app { grid-template-rows: 44px minmax(0, 1fr) 92px; }
  #topbar { gap: 6px; padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  #rail { padding: 6px 2px; }
  .mode, .mini { width: 44px; }
  #timeline { padding: 2px 8px calc(4px + env(safe-area-inset-bottom)); gap: 2px; }
  .tl-bar { height: 22px; }
  .tl-ruler { height: 12px; }
  .tl-row { height: 15px; }
  .tl-row .lbl, .tl-ruler .lbl { width: 0; padding: 0; font-size: 0; overflow: hidden; }
  #timeline .tl-rows .tl-row:first-child { display: none; }
  #credit, #drop-tip { display: none; }
  #coach { bottom: 6px; left: 6px; width: min(320px, calc(100% - 70px)); }
  #coach .coach-head { margin-bottom: 0; }
}

@media (max-width: 640px) {
  #topbar { gap: 6px; }
  .cam-select { max-width: 86px; padding: 5px 5px; font-size: 11px; flex: none; }
  #btn-coach, #btn-panel, #btn-library, #btn-save { font-size: 11.5px; padding: 5px 7px; white-space: nowrap; flex: none; }
  #btn-coach .track { display: none; }
  .actions { gap: 5px; }
  #credit { display: none; }
  #drop-tip { display: none; }
}

#loading .loading-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid rgba(255,255,255,.16); border-top-color: var(--accent); animation: spin .8s linear infinite; }
#loading { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); font-size: 13px; }
#loading[hidden] { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 640px) { #hint { display: none; } }

/* ---------- 反馈 ---------- */
.feedback-top { display: inline-flex; align-items: center; padding: 6px 10px; border: 1px solid var(--line2); background: #16243a; color: var(--text); border-radius: 8px; }
.feedback-top:hover { background: #1d2f4a; }
.fb-modal { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,.62); display: flex; align-items: center; justify-content: center; padding: 18px; }
.fb-modal[hidden] { display: none; }
.fb-card { position: relative; width: min(520px, 100%); max-height: calc(100dvh - 36px); overflow: auto; background: #0c1626; border: 1px solid var(--line2); border-radius: 16px; padding: 24px 24px 18px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.fb-kicker { margin: 0; font-size: 10.5px; letter-spacing: .18em; color: var(--muted); }
.fb-card h2 { margin: 6px 0 0; font-size: 22px; }
.fb-intro { margin: 6px 0 14px; font-size: 13px; line-height: 1.6; color: var(--muted); }
.fb-field { display: block; margin-top: 12px; }
.fb-field > span { display: block; margin-bottom: 6px; font-size: 11.5px; color: var(--muted); }
.fb-field > span em { font-style: normal; color: #5f7590; }
.fb-field input, .fb-field textarea { width: 100%; border: 1px solid var(--line2); border-radius: 9px; padding: 10px 11px; font: inherit; font-size: 14px; color: var(--text); background: #0a1422; outline: none; resize: vertical; }
.fb-field input:focus, .fb-field textarea:focus { border-color: var(--accent); }
.fb-honey { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.fb-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.fb-actions .primary { padding: 8px 16px; }
.fb-status { font-size: 12px; color: var(--muted); }
.fb-status.err { color: #ff8f8f; }
.fb-status a { color: var(--accent); text-decoration: underline; }
.fb-note { margin: 14px 0 0; font-size: 11px; line-height: 1.6; color: #5f7590; }
.fb-close { position: absolute; top: 12px; right: 14px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line2); background: #0a1422; color: var(--muted); font-size: 18px; line-height: 1; display: grid; place-items: center; padding: 0; }
.fb-close:hover { color: var(--text); }
#panel-feedback { font-size: 12px; padding: 6px 10px; border: 1px solid var(--line); background: transparent; color: var(--muted); }
@media (max-width: 980px) { .feedback-top { display: none; } }
@media (max-width: 640px) { .fb-card { padding: 20px 16px 16px; } .fb-field input, .fb-field textarea { font-size: 16px; } }

.fb-status.ok { color: #6ee7a8; }
