:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --cyan: #0891b2;
  --cyan-soft: #ecfeff;
  --bg: #f8fafc;
  --danger: #dc2626;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button,
input {
  font: inherit;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: linear-gradient(145deg, #06b6d4, #2563eb);
  color: #fff;
  font-weight: 900;
}
.pairing-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(circle at 50% 0, #cffafe 0, transparent 34%), var(--bg);
  padding: 30px;
}
.pairing-brand,
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
}
.pairing-card {
  width: min(540px, 100%);
  margin: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 28px;
  padding: 42px 48px;
  text-align: center;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.1);
}
.eyebrow {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--cyan);
}
h1 {
  font-size: 40px;
  line-height: 1.08;
  letter-spacing: -0.035em;
  margin: 14px 0;
}
.lead {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
  margin: 0 auto 25px;
  max-width: 420px;
}
.qr-shell {
  width: 228px;
  height: 228px;
  margin: 0 auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  position: relative;
}
.qr-shell img,
.qr-shell canvas {
  width: 198px !important;
  height: 198px !important;
}
.qr-loader {
  position: absolute;
  inset: 14px;
  border-radius: 10px;
  background: linear-gradient(100deg, #f1f5f9 30%, #fff 50%, #f1f5f9 70%);
  background-size: 220% 100%;
  animation: shine 1.2s infinite;
}
@keyframes shine {
  to {
    background-position: -220% 0;
  }
}
.pair-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: #475569;
  font-size: 14px;
  margin: 18px;
}
.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 5px #dcfce7;
}
.pair-steps {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  text-align: left;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.pair-steps span {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--cyan-soft);
  color: var(--cyan);
  font-weight: 900;
  font-size: 12px;
}
.pair-steps p {
  margin: 2px 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.45;
}
.link-button {
  border: 0;
  background: none;
  color: var(--cyan);
  font-weight: 800;
  cursor: pointer;
  margin-top: 16px;
}
.pairing-screen footer {
  font-size: 12px;
  color: #94a3b8;
  padding: 22px;
}
.workspace {
  height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: 66px 1fr;
  overflow: hidden;
}
.topbar {
  grid-column: 1/3;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 300px 1fr auto;
  align-items: center;
  padding: 0 24px;
}
.save-state {
  text-align: center;
  color: #16a34a;
  font-size: 12px;
  font-weight: 700;
}
.account {
  display: flex;
  align-items: center;
  gap: 15px;
  color: var(--muted);
  font-size: 13px;
}
.account button,
.editor-actions button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 8px 12px;
  cursor: pointer;
}
.sidebar {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.sidebar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 7px 15px;
}
.sidebar h2 {
  margin: 5px 0 0;
  font-size: 23px;
}
.icon-button {
  border: 0;
  background: var(--cyan);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  font-size: 24px;
  cursor: pointer;
}
.project-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.project-item {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  text-align: left;
}
.project-item:hover {
  background: #f8fafc;
}
.project-item.active {
  border-color: #a5f3fc;
  background: var(--cyan-soft);
}
.project-item b {
  display: block;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-item span {
  color: #94a3b8;
  font-size: 11px;
  display: block;
  margin-top: 5px;
}
.sidebar-note {
  margin-top: auto;
  border: 1px solid #bae6fd;
  background: #f0f9ff;
  border-radius: 13px;
  padding: 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.sidebar-note b {
  font-size: 12px;
  color: #0369a1;
}
.sidebar-note span {
  font-size: 11px;
  line-height: 1.45;
  color: #64748b;
}
.editor {
  min-width: 0;
  min-height: 0;
}
.empty-editor {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}
.empty-editor h2 {
  margin: 14px 0 3px;
  color: #334155;
}
.empty-editor p {
  margin: 0;
}
.empty-icon {
  font-size: 58px;
  color: #67e8f9;
}
.editor-content {
  height: 100%;
  display: grid;
  grid-template-rows: 66px 56px 1fr;
}
.editor-head {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}
.editor-head input {
  border: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  outline: none;
  width: min(440px, 50vw);
  padding: 8px;
}
.editor-actions {
  display: flex;
  gap: 8px;
}
.editor-actions .danger {
  color: var(--danger);
}
.toolbar {
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 18px;
  overflow-x: auto;
}
.tool-group {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  flex: none;
}
.tool-group button,
.tool-delete {
  height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 0 12px;
  cursor: pointer;
  color: #475569;
  font-weight: 700;
  font-size: 13px;
}
.tool-group button:last-child {
  border-right: 0;
}
.tool-group button.active {
  background: var(--cyan-soft);
  color: var(--cyan);
}
.elements button {
  min-width: 38px;
  padding: 0 9px;
}
.tool-delete {
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--danger);
}
.canvas-wrap {
  position: relative;
  min-height: 0;
  background-color: #fbfdff;
  background-image: radial-gradient(#dbeafe 1px, transparent 1px);
  background-size: 24px 24px;
  overflow: hidden;
}
#canvas {
  width: 100%;
  height: 100%;
  touch-action: none;
}
.canvas-help {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.86);
  color: #fff;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 11px;
  white-space: nowrap;
}
.atom circle {
  fill: #fff;
  stroke: #cbd5e1;
  stroke-width: 1;
}
.atom text {
  font-weight: 800;
  font-size: 17px;
  text-anchor: middle;
  dominant-baseline: central;
  user-select: none;
}
.atom.selected circle {
  stroke: #06b6d4;
  stroke-width: 3;
  fill: #ecfeff;
}
.bond line {
  stroke: #1e293b;
  stroke-width: 3;
  stroke-linecap: round;
}
.bond.selected line {
  stroke: #06b6d4;
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #0f172a;
  color: #fff;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px;
  z-index: 20;
}
@media (max-width: 800px) {
  .pairing-card {
    padding: 30px 22px;
  }
  h1 {
    font-size: 31px;
  }
  .workspace {
    grid-template-columns: 230px 1fr;
  }
  .topbar {
    grid-template-columns: 230px 1fr auto;
  }
  .account span {
    display: none;
  }
  .canvas-help {
    display: none;
  }
}
