:root {
  --blue: #165dff;
  --blue-dark: #0e42d2;
  --blue-soft: #e8efff;
  --bg: #f1f3f8;
  --card: #ffffff;
  --text: #1a1f2e;
  --muted: #6b7280;
  --line: #e6e9f0;
  --ok: #30a46c;
  --bad: #e5484d;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body.booting { background: var(--bg); }
body.booting .app, body.booting .gate { visibility: hidden; }

/* ---------- 登录门 ---------- */
.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 50% -10%, #e2ebff 0%, rgba(232,239,255,0) 62%),
    var(--bg);
}
.gate-card {
  width: 100%;
  max-width: 356px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(20, 30, 60, .09);
  padding: 26px 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.gate-brand {
  font-size: 20px; font-weight: 600; letter-spacing: .5px;
  display: flex; align-items: center; gap: 9px;
}
.gate-brand i { width: 10px; height: 10px; border-radius: 3px; background: var(--blue); display: inline-block; }
.gate-sub { margin: -6px 0 4px; color: var(--muted); font-size: 12.5px; }
.gate-fld { display: flex; flex-direction: column; gap: 5px; }
.gate-fld span { font-size: 11.5px; color: var(--muted); }
.gate-fld input {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; font-size: 13.5px; color: var(--text); background: #fbfcfe;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.gate-fld input:focus { border-color: var(--blue); background: #fff; box-shadow: 0 0 0 3px rgba(22, 93, 255, .12); }
.gate-msg { margin: 0; min-height: 18px; font-size: 12px; color: var(--ok); }
.gate-msg.bad { color: var(--bad); }
.gate-btn {
  border: 0; border-radius: 9px; padding: 10px 12px; font-size: 14px; font-weight: 600;
  color: #fff; background: var(--blue); cursor: pointer; transition: background .15s;
}
.gate-btn:hover { background: var(--blue-dark); }
.gate-btn:disabled { opacity: .65; cursor: default; }
.gate-foot { margin: 2px 0 0; font-size: 11px; color: #9aa2b1; line-height: 1.5; }

.who { margin-left: auto; display: flex; align-items: center; gap: 9px; font-size: 12.5px; }
.who-name { color: var(--text); font-weight: 500; }
.who-out {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 7px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.who-out:hover { color: var(--text); border-color: #ccd2de; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1480px; margin: 0 auto; padding: 16px 20px 18px; height: 100vh; display: flex; flex-direction: column; box-sizing: border-box; }

.top { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.brand { font-size: 17px; font-weight: 600; letter-spacing: .5px; display: flex; align-items: center; gap: 8px; }
.brand i { width: 9px; height: 9px; border-radius: 3px; background: var(--blue); display: inline-block; }
.sub { color: var(--muted); font-size: 12px; }

.layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 14px; align-items: stretch; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(20, 30, 60, .04);
  overflow: hidden;
}

h2 { font-size: 14px; font-weight: 600; margin: 0; }

/* ---- 主舞台 ---- */
.stage { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.stage-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; }
.presets { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 999px; padding: 4px 11px; font-size: 12px; cursor: pointer;
  font-family: inherit; transition: .15s;
}
.chip:hover { border-color: #c9d4ea; color: var(--text); }
.chip.on { background: var(--blue-soft); border-color: #b8ccff; color: var(--blue-dark); font-weight: 500; }

.canvas-wrap { position: relative; flex: 1; min-height: 0; margin: 0 16px; border-radius: 10px; overflow: hidden; }
#field { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
#field.dragging { cursor: grabbing; }

.readout {
  display: flex; flex-wrap: wrap; gap: 6px 22px;
  padding: 12px 16px; border-top: 1px solid var(--line);
}
.ro { display: flex; align-items: baseline; gap: 5px; font-size: 12px; color: var(--muted); }
.ro span { color: var(--muted); }
.ro b { font-size: 15px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.ro i { font-style: normal; font-size: 11px; color: var(--muted); }
.ro.wide { margin-left: auto; }
.ro.wide b { font-size: 13px; font-weight: 500; color: var(--blue-dark); }

.bar {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; background: #fafbfe; border-top: 1px solid var(--line);
}
button { font-family: inherit; font-size: 13px; cursor: pointer; border-radius: 8px; padding: 7px 16px; border: 1px solid transparent; transition: .15s; }
button.primary { background: var(--blue); color: #fff; font-weight: 500; }
button.primary:hover { background: var(--blue-dark); }
button.ghost { background: #fff; border-color: var(--line); color: var(--text); }
button.ghost:hover { border-color: #c9d4ea; }
button.link { background: none; border: none; color: var(--muted); font-size: 12px; padding: 2px 4px; }
button.link:hover { color: var(--bad); }
button:disabled { opacity: .45; cursor: default; }

#timeline { flex: 1; accent-color: var(--blue); min-width: 80px; }
.tlabel { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }
select.mini { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-family: inherit; font-size: 12px; background: #fff; color: var(--text); }

/* ---- 右栏 ---- */
.side { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; padding-right: 2px; }
.side > .card { flex: none; }
.side > .card:last-child { flex: 1 1 auto; min-height: 190px; display: flex; flex-direction: column; }
.side > .card:last-child .program { flex: 1 1 auto; min-height: 0; max-height: none; overflow-y: auto; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px 8px; }
.hint { font-size: 12px; color: var(--muted); }
.tip { margin: 0 14px 8px; font-size: 11px; color: #9aa2b1; line-height: 1.4; }

#carPanel { width: 100%; height: 158px; display: block; touch-action: none; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px 7px; padding: 2px 14px 14px; }
.fld { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.fld label { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; }
.fld .row { display: flex; align-items: center; gap: 4px; }
.fld input, .fld select {
  width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 7px; padding: 5px 6px;
  font-family: inherit; font-size: 12px; color: var(--text); background: #fff;
  font-variant-numeric: tabular-nums;
}
.fld input:focus, .fld select:focus { outline: 2px solid #cddcff; border-color: #a9c2ff; }
.fld .u { font-size: 10px; color: #9aa2b1; white-space: nowrap; }

/* ---- 程序 ---- */
.program { padding: 2px 12px 14px; max-height: 310px; overflow-y: auto; }
.blk {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  background: #f7f9fd; border: 1px solid var(--line); border-radius: 9px;
  padding: 5px 7px; margin-bottom: 5px; font-size: 12px; gap: 5px;
}
.blk .grp {
  font-size: 10px; color: var(--blue-dark); background: var(--blue-soft);
  border-radius: 5px; padding: 1px 5px; flex: none;
}
.blk .words { color: var(--text); }
.blk input, .blk select {
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 5px;
  font-family: inherit; font-size: 12px; background: #fff; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.blk input.num { width: 50px; text-align: center; }
.blk .ops { margin-left: auto; display: flex; gap: 2px; flex: none; }
.blk .ops button {
  border: none; background: none; color: #b3bac7; padding: 0 3px; font-size: 12px; line-height: 1;
}
.blk .ops button:hover { color: var(--blue); }
.blk .ops button[data-act="del"]:hover { color: var(--bad); }
.body { margin: 0 0 6px 14px; padding-left: 10px; border-left: 2px solid #e2e8f5; }
.addrow { display: flex; gap: 6px; align-items: center; margin: 4px 0 10px; }
.addrow select {
  flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 7px; padding: 5px 7px;
  font-family: inherit; font-size: 12px; color: var(--muted); background: #fff;
}
.addrow button { padding: 5px 10px; font-size: 12px; background: #fff; border-color: var(--line); color: var(--muted); }
.addrow button:hover { color: var(--blue); border-color: #b8ccff; }

@media (max-width: 1080px) {
  .app { height: auto; }
  .layout { grid-template-columns: 1fr; }
  .stage { height: auto; }
  .canvas-wrap { height: 52vh; }
  .side { overflow: visible; }
}
