/* ============================================================
   Graph Lab — UI styles
   ============================================================ */
:root {
  --bg0: #070b10;
  --bg1: #0a1017;
  --panel: #0c131c;
  --card: rgba(255, 255, 255, 0.028);
  --line: rgba(148, 163, 184, 0.12);
  --txt: #e8eef7;
  --muted: #8b9bb0;
  --dim: #64748b;
  --accent: #5eead4;
  --accent2: #22d3ee;
  --violet: #a78bfa;
  --rose: #fb7185;
  --amber: #fbbf24;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", "Pretendard", system-ui, -apple-system, "Segoe UI", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg0);
  color: var(--txt);
  font-family: var(--sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input { font-family: inherit; }
button { cursor: pointer; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
code { font-family: var(--mono); }
[hidden] { display: none !important; }
::selection { background: rgba(94, 234, 212, 0.28); }

.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* ---------------- sidebar ---------------- */

.sidebar {
  position: relative;
  z-index: 40;
  width: 346px;
  flex: 0 0 346px;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(420px 220px at 0% 0%, rgba(94, 234, 212, 0.055), transparent 70%),
    linear-gradient(180deg, #0d141d 0%, #0a0f16 100%);
  border-right: 1px solid rgba(148, 163, 184, 0.09);
  padding: 18px 16px 12px;
  gap: 14px;
}
.sidebar::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(rgba(148, 163, 184, 0.09) 0.6px, transparent 0.6px);
  background-size: 18px 18px;
  opacity: 0.35;
  mask-image: linear-gradient(180deg, #000 0%, transparent 55%);
}
.sidebar > * { position: relative; z-index: 1; }

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 2px 2px 0;
}
.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: linear-gradient(135deg, rgba(94, 234, 212, 0.16), rgba(167, 139, 250, 0.14));
  border: 1px solid rgba(94, 234, 212, 0.3);
  box-shadow: 0 0 26px rgba(34, 211, 238, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.brand-mark svg { width: 25px; height: 25px; stroke-width: 1.6; }
.brand-text h1 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.015em;
}
.brand-text p {
  margin: 2px 0 0;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--dim);
  text-transform: uppercase;
  font-weight: 500;
}
.sidebar .sidebar-close { display: none; margin-left: auto; }

.scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 2px 10px;
  margin: 0 -2px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.22) transparent;
}
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.18); border-radius: 10px; }

.card {
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.065);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.036), rgba(255, 255, 255, 0.014));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
  padding: 13px 13px 12px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 9px;
}
.card-head h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.005em;
  color: #d8e3f0;
}
.card-head .icon-btn { margin-left: auto; }
.card-desc {
  margin: 0 0 11px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.65;
}
.hintline {
  margin: 8px 1px 0;
  color: var(--dim);
  font-size: 10.5px;
  line-height: 1.6;
}
.hintline code {
  color: #a7b6c9;
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 10px;
}

.pill {
  font-size: 9.5px;
  color: var(--accent);
  background: rgba(94, 234, 212, 0.1);
  border: 1px solid rgba(94, 234, 212, 0.16);
  padding: 1px 7px;
  border-radius: 999px;
}
.tag {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 0.07em;
  color: var(--dim);
  border: 1px solid rgba(148, 163, 184, 0.18);
  padding: 2px 6px;
  border-radius: 5px;
  text-transform: uppercase;
}
.tag.violet { color: var(--violet); border-color: rgba(167, 139, 250, 0.25); background: rgba(167, 139, 250, 0.07); }

.icon-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--txt); }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn.tiny { width: 22px; height: 22px; }
.icon-btn.tiny svg { width: 13px; height: 13px; }

/* ---------------- function rows ---------------- */

.func-list { display: flex; flex-direction: column; gap: 2px; }
.frow {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) 24px 24px;
  gap: 5px;
  align-items: start;
  padding: 5px 4px;
  border-radius: 9px;
  transition: background 0.14s;
}
.frow:hover { background: rgba(255, 255, 255, 0.026); }
.swatch {
  width: 14px;
  height: 14px;
  margin: 9px auto 0;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.35);
  background: var(--c, #5eead4);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.045), 0 0 12px var(--c, #5eead4);
  transition: transform 0.15s;
}
.swatch:hover { transform: scale(1.2); }
.fmain { min-width: 0; }
.fexpr {
  width: 100%;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.065);
  border-radius: 8px;
  padding: 7px 9px;
  color: var(--txt);
  font: 12px/1.45 var(--mono);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.fexpr::placeholder { color: #4b5b6e; }
.fexpr:focus {
  border-color: rgba(94, 234, 212, 0.55);
  background: rgba(0, 0, 0, 0.34);
  box-shadow: 0 0 0 3px rgba(94, 234, 212, 0.1);
}
.frow.has-err .fexpr { border-color: rgba(251, 113, 133, 0.5); }
.ferr {
  display: none;
  margin: 4px 1px 1px;
  color: var(--rose);
  font-size: 10px;
  line-height: 1.45;
}
.frow.has-err .ferr { display: block; }
.frow .icon-btn { margin-top: 4px; opacity: 0.55; }
.frow:hover .icon-btn { opacity: 0.9; }
.frow .del:hover { color: var(--rose); background: rgba(251, 113, 133, 0.1); }
.fbadge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 8.5px;
  color: var(--violet);
  border: 1px solid rgba(167, 139, 250, 0.3);
  background: rgba(167, 139, 250, 0.08);
  border-radius: 4px;
  padding: 0 4px;
  margin-left: 5px;
  vertical-align: 1px;
}
.frow.hidden-fn .fexpr { opacity: 0.45; }
.frow.muted-3d .fexpr { opacity: 0.4; }
.frow.muted-3d .swatch { opacity: 0.35; }

/* ---------------- buttons ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.045);
  color: var(--txt);
  font-size: 12px;
  font-weight: 550;
  padding: 8px 12px;
  transition: transform 0.14s, filter 0.14s, background 0.14s, border-color 0.14s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.075); }
.btn:active { transform: translateY(1px); }
.btn.wide { width: 100%; }
.btn.sm { padding: 5px 9px; font-size: 10.5px; border-radius: 7px; }
.btn.primary {
  background: linear-gradient(135deg, #5eead4 0%, #22d3ee 55%, #38bdf8 100%);
  color: #04222a;
  border: none;
  font-weight: 700;
  box-shadow: 0 6px 22px rgba(34, 211, 238, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn.primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn.primary .btn-ico { width: 15px; height: 15px; }
.btn kbd {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(4, 34, 42, 0.16);
  border: 1px solid rgba(4, 34, 42, 0.2);
  color: rgba(4, 34, 42, 0.7);
}
.btn.primary.active {
  background: linear-gradient(135deg, #fda4af, #fb7185);
  color: #2b0710;
  box-shadow: 0 6px 24px rgba(251, 113, 133, 0.22);
  animation: pulse-draw 2.2s ease-in-out infinite;
}
@keyframes pulse-draw {
  0%, 100% { box-shadow: 0 6px 24px rgba(251, 113, 133, 0.18); }
  50% { box-shadow: 0 6px 30px rgba(251, 113, 133, 0.36); }
}
.btn.ghost { background: rgba(255, 255, 255, 0.02); border-color: rgba(255, 255, 255, 0.08); color: var(--muted); }
.btn.ghost:hover { color: var(--txt); border-color: rgba(255, 255, 255, 0.16); }

kbd {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 2px 5px;
}

/* ---------------- sketch / fit ---------------- */

.fit-empty {
  margin: 10px 1px 4px;
  padding: 10px;
  border: 1px dashed rgba(148, 163, 184, 0.16);
  border-radius: 9px;
  text-align: center;
  color: var(--dim);
  font-size: 10.5px;
}
.fit-result { margin-top: 10px; }
.fit-formula-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 8px 9px;
  border-radius: 9px;
  background: rgba(94, 234, 212, 0.055);
  border: 1px solid rgba(94, 234, 212, 0.16);
}
.fx-label { color: var(--accent); font-family: var(--mono); font-size: 10px; flex: 0 0 auto; }
.fit-formula {
  flex: 1;
  min-width: 0;
  color: #ccfbf1;
  font-size: 11.5px;
  line-height: 1.55;
  word-break: break-word;
  max-height: 76px;
  overflow-y: auto;
}
.fit-meter { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.meter {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}
.meter i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #2dd4bf, #22d3ee);
  transition: width 0.45s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.fit-meter span { font-size: 9.5px; color: var(--accent); }
.fit-sub { margin-top: 3px; color: var(--dim); font-size: 9.5px; }
.fit-actions { display: flex; gap: 5px; margin-top: 9px; flex-wrap: wrap; }
.fit-actions .btn { flex: 1; padding: 5px 4px; font-size: 10px; }

.row { display: flex; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.tight { margin-top: 10px; }
.mini-label { font-size: 10px; color: var(--muted); letter-spacing: 0.02em; }
.mini-val { font-size: 10px; color: var(--accent); width: 10px; text-align: right; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 18px;
  background: transparent;
  accent-color: var(--accent);
  margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.2);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #062a2c;
  box-shadow: 0 0 8px rgba(94, 234, 212, 0.5);
}
input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 99px;
  background: rgba(148, 163, 184, 0.2);
}
input[type="range"]::-moz-range-thumb {
  width: 10px; height: 10px; border: 2px solid #062a2c; border-radius: 50%; background: var(--accent);
}


.tip-list {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tip-list div {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 10.5px;
  color: var(--dim);
  line-height: 1.4;
}
.tip-list span {
  flex: 0 0 15px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 8.5px;
  color: var(--accent);
  background: rgba(94, 234, 212, 0.09);
  border: 1px solid rgba(94, 234, 212, 0.16);
}


/* ---------------- sketch modes / shape results / params ---------------- */

.sketch-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  padding: 3px;
  margin: 2px 0 10px;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 9px;
}
.sketch-modes button {
  border: none;
  background: transparent;
  color: var(--dim);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
  padding: 6px 2px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.sketch-modes button:hover { color: var(--txt); }
.sketch-modes button.on { background: rgba(94, 234, 212, 0.14); color: var(--accent); }

.shape-result, .canon-result { margin-top: 10px; }
.shape-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}
.shape-badge {
  font-size: 10px;
  font-weight: 650;
  color: var(--accent);
  background: rgba(94, 234, 212, 0.1);
  border: 1px solid rgba(94, 234, 212, 0.2);
  padding: 2px 7px;
  border-radius: 6px;
}
.shape-badge.canon {
  color: var(--violet);
  background: rgba(167, 139, 250, 0.1);
  border-color: rgba(167, 139, 250, 0.22);
}
.shape-pct { font-size: 9.5px; color: var(--dim); }
.shape-formula {
  font: 10.5px/1.65 var(--mono);
  color: #cfe0ef;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px 9px;
  max-height: 118px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.22) transparent;
}
.shape-sub { margin-top: 5px; color: var(--dim); font-size: 9.5px; line-height: 1.55; }
.meter.slim { width: 100%; height: 3px; margin-top: 8px; }

.fexpr.readonly {
  opacity: 0.82;
  cursor: default;
  border-style: dashed;
  color: #cfe0ef;
}
.fexpr.readonly:focus { border-color: rgba(255, 255, 255, 0.12); box-shadow: none; background: rgba(0, 0, 0, 0.24); }

.param-select {
  margin-left: auto;
  max-width: 186px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: var(--txt);
  font-size: 10px;
  padding: 3px 5px;
  outline: none;
}
.param-select:focus { border-color: rgba(94, 234, 212, 0.45); }
.param-controls { display: flex; flex-direction: column; gap: 1px; }
.prow {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) 52px;
  gap: 5px;
  align-items: center;
  margin: 3px 0;
}
.prow label {
  font-size: 9.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.prow input[type="range"] { height: 16px; min-width: 0; }
.prow input[type="number"] {
  width: 100%;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  color: #dbe7f3;
  font: 10px var(--mono);
  padding: 3px 4px;
  text-align: right;
  outline: none;
  -moz-appearance: textfield;
}
.prow input[type="number"]:focus { border-color: rgba(94, 234, 212, 0.5); }
.prow input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------------- 3d settings ---------------- */

.setting { display: flex; align-items: center; gap: 8px; margin: 9px 0; }
.setting .mini-label { flex: 0 0 auto; }
.seg {
  margin-left: auto;
  display: flex;
  background: rgba(0, 0, 0, 0.26);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 7px;
  padding: 2px;
  gap: 2px;
}
.seg button {
  border: none;
  background: transparent;
  color: var(--dim);
  font-family: var(--mono);
  font-size: 9.5px;
  padding: 3px 8px;
  border-radius: 5px;
  transition: background 0.15s, color 0.15s;
}
.seg button:hover { color: var(--txt); }
.seg button.on { background: rgba(94, 234, 212, 0.14); color: var(--accent); }
.toggle {
  position: relative;
  width: 34px;
  height: 19px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
  padding: 0;
  transition: background 0.18s, border-color 0.18s;
  flex: 0 0 34px;
}
.toggle i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #93a4b8;
  transition: transform 0.18s, background 0.18s;
}
.toggle.on { background: rgba(94, 234, 212, 0.22); border-color: rgba(94, 234, 212, 0.4); }
.toggle.on i { transform: translateX(15px); background: var(--accent); }

/* ---------------- sidebar footer ---------------- */

.side-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 4px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--dim);
  font-size: 10px;
}
.side-foot button {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 10px;
  padding: 2px;
}
.side-foot button:hover { color: var(--accent); }
.foot-note { margin-left: auto; color: #435163; font-size: 9px; letter-spacing: 0.04em; }

/* ---------------- stage ---------------- */

.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background:
    radial-gradient(1100px 620px at 72% 6%, rgba(34, 211, 238, 0.075), transparent 62%),
    radial-gradient(900px 600px at 15% 100%, rgba(167, 139, 250, 0.06), transparent 60%),
    #080d13;
  touch-action: none;
}
.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#c2d { z-index: 1; }
#c3d { z-index: 2; }
#c3dLabels { z-index: 3; pointer-events: none; }
.app.mode-3d #c2d { display: none; }
.app:not(.mode-3d) #c3d,
.app:not(.mode-3d) #c3dLabels { display: none; }

.mode-switch {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(10, 16, 23, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 36px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.mode-switch button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: 0.04em;
  padding: 6px 22px;
  border-radius: 999px;
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
}
.mode-switch button:hover { color: var(--txt); }
.mode-switch button.active {
  color: #04222a;
  background: linear-gradient(135deg, #5eead4, #22d3ee);
  box-shadow: 0 4px 18px rgba(34, 211, 238, 0.26);
}

.stage-actions {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 20;
  display: flex;
  gap: 7px;
}
.glass-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(10, 16, 23, 0.62);
  color: var(--muted);
  backdrop-filter: blur(12px);
  transition: color 0.15s, background 0.15s, transform 0.15s;
}
.glass-btn:hover { color: var(--txt); background: rgba(20, 30, 42, 0.8); transform: translateY(-1px); }
.glass-btn svg { width: 16px; height: 16px; }
#panelToggle { display: none; }

.draw-banner {
  position: absolute;
  top: 78px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(20, 14, 20, 0.8);
  border: 1px solid rgba(251, 113, 133, 0.35);
  color: #fecdd3;
  font-size: 11px;
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 30px rgba(251, 113, 133, 0.12);
  white-space: nowrap;
}
.draw-banner .db-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--rose);
  box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.5);
  animation: ping 1.6s ease-out infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(251, 113, 133, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(251, 113, 133, 0); }
  100% { box-shadow: 0 0 0 0 rgba(251, 113, 133, 0); }
}
.draw-banner kbd { border-color: rgba(251, 113, 133, 0.25); color: #fda4af; background: rgba(251, 113, 133, 0.08); }

.hud {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 11px;
  background: rgba(10, 16, 23, 0.66);
  border: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  font-size: 10.5px;
  color: var(--muted);
  pointer-events: none;
  max-width: calc(100% - 36px);
  overflow: hidden;
  white-space: nowrap;
}
.hud-coords { color: #cfe0ef; }
.hud-sep { width: 1px; height: 11px; background: rgba(148, 163, 184, 0.2); }
.hud-perf { color: var(--accent); }
.hud-perf.idle { color: var(--dim); }

.hints {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: flex;
  gap: 5px;
  pointer-events: none;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.hint {
  font-size: 10px;
  color: var(--dim);
  background: rgba(10, 16, 23, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.065);
  border-radius: 999px;
  padding: 4px 9px;
  backdrop-filter: blur(10px);
}
.hint b { color: #c3d2e2; font-weight: 600; }

.toast-host {
  position: absolute;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
}
.toast {
  padding: 8px 13px;
  border-radius: 9px;
  background: rgba(14, 21, 30, 0.92);
  border: 1px solid rgba(94, 234, 212, 0.22);
  border-left: 2px solid var(--accent);
  color: #d9e7f2;
  font-size: 11px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.24s cubic-bezier(0.2, 0.9, 0.3, 1);
  backdrop-filter: blur(12px);
}
.toast.out { animation: toast-out 0.25s forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

.gl-fallback {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(8, 13, 19, 0.88);
  backdrop-filter: blur(6px);
  text-align: center;
  padding: 30px;
}
.gl-fallback h3 { margin: 0; font-size: 16px; }
.gl-fallback p { margin: 0 0 10px; color: var(--muted); font-size: 12px; max-width: 380px; line-height: 1.6; }

.empty3d {
  position: absolute;
  inset: 0;
  z-index: 21;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.empty3d-card {
  pointer-events: auto;
  width: min(330px, 82vw);
  padding: 22px 22px 20px;
  border-radius: 16px;
  background: rgba(11, 17, 25, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  text-align: center;
}
.empty3d-icon {
  width: 40px; height: 40px; margin: 0 auto 10px;
  display: grid; place-items: center;
  border-radius: 12px;
  font: italic 700 19px Georgia, serif;
  color: var(--violet);
  background: rgba(167, 139, 250, 0.1);
  border: 1px solid rgba(167, 139, 250, 0.25);
}
.empty3d-card h3 { margin: 0 0 5px; font-size: 14px; }
.empty3d-card p { margin: 0 0 13px; color: var(--muted); font-size: 11px; line-height: 1.6; }

/* ---------------- modal ---------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-back {
  position: absolute;
  inset: 0;
  background: rgba(3, 7, 11, 0.68);
  backdrop-filter: blur(8px);
}
.modal-card {
  position: relative;
  width: min(620px, 100%);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(180deg, #101924, #0b1119);
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: modal-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
  overflow: hidden;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: none; } }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 20px 22px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.modal-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.02em; }
.modal-head p { margin: 4px 0 0; font-size: 11px; color: var(--dim); }
.modal-body { padding: 18px 22px 8px; overflow-y: auto; }
.modal-body section { margin-bottom: 20px; }
.modal-body h3 {
  margin: 0 0 9px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 650;
}
.modal-body h4 { margin: 0 0 6px; font-size: 11px; color: var(--txt); }
.modal-p { margin: 0; color: var(--muted); font-size: 11.5px; line-height: 1.75; }
.modal-p code, .help-col code {
  color: #a7f3d0;
  background: rgba(94, 234, 212, 0.08);
  border: 1px solid rgba(94, 234, 212, 0.12);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 10.5px;
}
.modal-p b { color: #cfe0ef; font-weight: 600; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.help-col {
  padding: 11px 13px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.055);
}
.help-col p { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.9; }
.help-col b { color: #d6e4f1; font-weight: 600; }
.perf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perf-grid > div {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 11px;
  border-radius: 9px;
  background: rgba(94, 234, 212, 0.04);
  border: 1px solid rgba(94, 234, 212, 0.1);
}
.perf-grid b { font-family: var(--mono); font-size: 11px; color: var(--accent); }
.perf-grid span { font-size: 10px; color: var(--dim); }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 22px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.modal-foot .mono { font-size: 9.5px; color: var(--dim); letter-spacing: 0.04em; }

.scrim {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

/* ---------------- responsive ---------------- */

@media (max-width: 980px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(86vw, 350px);
    flex-basis: auto;
    transform: translateX(-103%);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 20px 0 60px rgba(0, 0, 0, 0.5);
    z-index: 61;
  }
  .app.sidebar-open .sidebar { transform: none; }
  .app.sidebar-open .scrim { display: block; }
  .sidebar .sidebar-close { display: inline-flex; }
  #panelToggle { display: inline-flex; }
  .stage-actions { top: 14px; right: 14px; }
  .mode-switch { top: 14px; }
  .hud { left: 14px; bottom: 14px; padding: 6px 10px; gap: 7px; font-size: 10px; }
  .hints { display: none; }
  .draw-banner { top: 66px; font-size: 10.5px; }
  .toast-host { bottom: 64px; }
}

@media (max-width: 620px) {
  #resetView { display: none; }
  .mode-switch button { padding: 6px 17px; font-size: 11px; }
  .hud-zoom, .hud-sep { display: none; }
  .stage-actions { gap: 5px; }
  .glass-btn { width: 33px; height: 33px; }
  .brand { gap: 9px; }
  .fit-actions .btn { font-size: 9.5px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
