:root {
  --bg: #eaeef6; --bg2: #f4f7fc; --ink: #1b2434; --ink-soft: #5a6478; --ink-faint: #98a1b5;
  --line: rgba(27,36,52,.08); --azure: #2b6cee; --gold: #c89600; --track: #e6ebf5; --zebra: #f5f7fb;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: linear-gradient(180deg, var(--bg2), var(--bg) 60%, #e3e9f4);
  color: var(--ink); font-family: 'Ubuntu Sans', 'Segoe UI', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; overflow: hidden;
}
button, input { font: inherit; color: inherit; }
#app { height: 100vh; height: 100dvh; display: grid; grid-template-columns: 320px minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
header.top {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 28px; padding: 14px 28px;
  border-bottom: 1px solid var(--line); background: rgba(255,255,255,.6);
}
.brand { font-weight: 800; font-size: 22px; letter-spacing: -.3px; white-space: nowrap; }
.brand small { display: block; font-size: 13px; font-weight: 600; color: var(--ink-faint); margin-top: 2px; }
.tabs { display: flex; gap: 4px; background: var(--track); border-radius: 999px; padding: 5px; }
.tabs button {
  border: 0; background: transparent; border-radius: 999px; padding: 10px 18px; cursor: pointer;
  font-weight: 700; font-size: 16px; color: var(--ink-soft);
}
.tabs button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(88,106,140,.16); }
.tabs kbd { font: 600 12px 'Ubuntu Sans', system-ui, sans-serif; opacity: .45; margin-left: 7px; }
.meta { margin-left: auto; font-size: 14px; color: var(--ink-faint); font-weight: 600; text-align: right; line-height: 1.45; }
aside.side { border-right: 1px solid var(--line); background: rgba(255,255,255,.45); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: baseline; justify-content: space-between; padding: 18px 20px 8px; }
.side-head b { font-size: 18px; font-weight: 800; }
.side-head span { font-size: 14px; color: var(--ink-faint); font-weight: 700; }
.side-tools { display: flex; gap: 8px; padding: 0 20px 12px; }
.side-tools input {
  flex: 1; min-width: 0; border: 1px solid var(--line); background: #fff; border-radius: 12px;
  padding: 8px 12px; font-size: 15px; outline: none;
}
.side-tools input:focus { border-color: var(--azure); }
.side-tools button { border: 0; background: var(--track); border-radius: 12px; padding: 0 12px; font-size: 14px; font-weight: 700; color: var(--ink-soft); cursor: pointer; }
.model-list { overflow-y: auto; padding: 4px 12px 16px; min-height: 0; flex: 1; }
.mrow {
  display: grid; grid-template-columns: 20px 34px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 14px; cursor: pointer; user-select: none;
}
.mrow:hover { background: #eef3ff; }
.mrow.off { opacity: .42; }
.mrow input { width: 18px; height: 18px; accent-color: var(--azure); }
.mico svg { width: 30px; height: 30px; display: block; }
.mtxt { min-width: 0; }
.mtxt b { display: block; font-size: 16px; font-weight: 800; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mtxt small { display: block; font-size: 13px; color: var(--ink-faint); font-weight: 600; }
.mavg { font-size: 16px; font-weight: 800; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.side-foot { padding: 12px 20px 16px; font-size: 13px; color: var(--ink-faint); line-height: 1.5; border-top: 1px solid var(--line); }
.main { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 24px 0; min-height: 70px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: #fff; border-radius: 999px;
  padding: 4px 13px 4px 4px; font-size: 14px; font-weight: 700; color: var(--ink-soft); cursor: pointer;
  box-shadow: 0 2px 8px rgba(88,106,140,.10); opacity: .5;
}
.chip.on { opacity: 1; color: var(--ink); }
.chip.plain { padding: 8px 16px; opacity: 1; }
.chip .mico svg { width: 22px; height: 22px; }
.seg { display: inline-flex; background: var(--track); border-radius: 999px; padding: 4px; gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 8px 16px; font-size: 14px; font-weight: 800; color: var(--ink-soft); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(88,106,140,.14); }
.hint { font-size: 15px; color: var(--ink-faint); font-weight: 600; margin-left: auto; }
.stage { flex: 1; min-height: 0; overflow: auto; padding: 16px 24px 28px; }
.fig { width: min(100%, 1400px); margin: 0 auto; }
.fig.wide { width: max(100%, 2000px); }
.fig svg { display: block; width: 100%; height: auto; }
.fig text { font-family: 'Ubuntu Sans', 'Segoe UI', system-ui, sans-serif; }
.tip {
  position: fixed; pointer-events: none; background: var(--ink); color: #fff; padding: 9px 14px;
  border-radius: 12px; font-size: 15px; font-weight: 600; opacity: 0; transition: opacity .08s; z-index: 50; max-width: 460px;
}
#exportStage { position: fixed; left: 0; top: 0; width: 3072px; display: none; background: var(--bg); }
#exportStage .fig { width: 3072px; }
body.exporting #app { display: none; }
body.exporting #exportStage { display: block; }
.notice { font-size: 20px; font-weight: 600; color: var(--ink-soft); padding: 60px 0; text-align: center; }
.meta a { color: var(--azure); text-decoration: none; }
.meta a:hover { text-decoration: underline; }
@media (max-width: 900px) {
  body { overflow: auto; }
  #app { height: auto; grid-template-columns: minmax(0, 1fr); }
  header.top { flex-wrap: wrap; gap: 12px 16px; padding: 14px 16px; }
  .meta { margin-left: 0; text-align: left; }
  .tabs { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .tabs button { flex-shrink: 0; padding: 9px 14px; }
  .tabs kbd { display: none; }
  .controls { padding: 12px 16px 0; }
  .stage { padding: 12px 16px 24px; }
  aside.side { max-height: 340px; }
  .fig { width: 100%; }
  .hint { display: none; }
}
