@font-face {
  font-family: "Mind";
  src: url("font2.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: "font1";
  src: url("font1.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "font2";
  src: url("font2.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --grid: #ededed;
  --grid-major: #dedede;
  --bg: #fafafa;
  --ink: #111;
  --line: #111;
  --accent: #111;
  --fs: 16px;
  --ui-stroke: 1.5px;
  --hud-top: 18px;
  --hud-side: 20px;
  --hud-burger: 32px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: var(--app-h, 100dvh);
  min-height: var(--app-h, 100dvh);
  font-family: "Mind", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  font-size: var(--fs);
  line-height: 1.3;
  color: var(--ink);
  background: var(--bg);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

button, input { font-family: inherit; font-size: var(--fs); }

.hidden { display: none !important; }

.auth-screen {
  position: fixed;
  top: var(--app-offset, 0);
  left: 0;
  right: 0;
  height: var(--app-h, 100dvh);
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--bg);
}

.auth-card {
  width: 280px;
  max-width: calc(100vw - 32px);
  background: #fff;
  border: var(--ui-stroke) solid #e6e6e6;
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.auth-logo {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: var(--ui-stroke) solid var(--ink);
  box-sizing: border-box;
}

.auth-brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.auth-title { color: var(--ink); letter-spacing: -0.3px; }
.auth-sub { color: #aaa; font-size: 0.78em; }

.auth-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  background: #f1f1f1;
  border-radius: 10px;
}

.auth-tab {
  border: none;
  background: none;
  padding: 7px 0;
  border-radius: 8px;
  cursor: pointer;
  color: #9a9a9a;
  text-align: center;
  transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
  color: var(--ink);
  background: #fff;
}

.auth-card input {
  width: 100%;
  padding: 10px 13px;
  border: var(--ui-stroke) solid #e3e3e3;
  border-radius: 10px;
  outline: none;
  background: #fafafa;
  transition: border-color 0.15s, background 0.15s;
}

.auth-card input:focus { border-color: var(--ink); background: #fff; }

.auth-card input.auth-mask {
  -webkit-text-security: disc;
  text-security: disc;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.2;
  -webkit-appearance: none;
  appearance: none;
}

.touch-ui .auth-card input.auth-mask {
  font-size: 15px;
  letter-spacing: 0.06em;
}

.auth-error { color: #c0392b; min-height: 0; font-size: 0.88em; }
.auth-error:empty { display: none; }

.btn-primary {
  padding: 11px;
  border: none;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  letter-spacing: -0.2px;
  transition: opacity 0.15s;
  margin-top: 2px;
}

.btn-primary:hover:not(:disabled) { opacity: 0.88; }

.board-message {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.board-message-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 340px;
  padding: 28px 30px;
  background: #fff;
  border: var(--ui-stroke) solid #e6e6e6;
  border-radius: 18px;
  text-align: center;
}

.board-message-text { color: var(--ink); line-height: 1.4; }

.board-message-link {
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.2px;
}

.board-message-link:hover { opacity: 0.88; }

.btn-primary:disabled { opacity: 0.5; cursor: default; }

.app { position: fixed; top: var(--app-offset, 0); left: 0; right: 0; height: var(--app-h, 100dvh); bottom: auto; }

.canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: default;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  background-color: var(--bg);
}

.canvas.space { cursor: grab; }
.canvas.panning { cursor: grabbing; }
body.readonly .canvas { cursor: grab; }
body.readonly .canvas.panning { cursor: grabbing; }

.grid-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  pointer-events: none;
}

.world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  width: 0;
  height: 0;
  z-index: 2;
}

.edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 1;
}

.edge-line { stroke: var(--line); stroke-width: 1.5; fill: none; }
.edge-hit { stroke: transparent; stroke-width: 16; fill: none; pointer-events: stroke; cursor: pointer; }
.edge-line.selected { stroke: #4a90d9; }

.node {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 18px;
  background: var(--node-bg, #fff);
  color: var(--node-fg, var(--ink));
  border: var(--ui-stroke) solid var(--ink);
  border-radius: 24px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  z-index: 1;
}

.node.selected {
  z-index: 2;
  outline: var(--ui-stroke) dashed #999;
  outline-offset: 2px;
}

.node.selected.dragging {
  z-index: 3;
}

.node-text {
  white-space: pre;
  text-align: center;
  outline: none;
  min-width: 1ch;
}

.node.editing .node-text { user-select: text; -webkit-user-select: text; touch-action: auto; }

.node-text:empty::before { content: "..."; color: var(--node-ph, #bbb); }

.node-image {
  display: block;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 16px;
  overflow: hidden;
  box-sizing: border-box;
}

.node-image .node-img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: cover;
  object-position: center;
  border-radius: 16px;
  border: var(--ui-stroke) solid var(--ink);
  box-sizing: border-box;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.node-image.selected .node-img {
  outline: var(--ui-stroke) dashed #999;
  outline-offset: 2px;
}

.node-image.selected {
  outline: none;
}

.node.editing { cursor: text; z-index: 50; }
.node.editing .node-text {
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-user-modify: read-write-plaintext-only;
}
.touch-ui.editing-node .node.editing .node-text {
  visibility: hidden;
  pointer-events: none;
  -webkit-user-modify: read-only;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none;
}
.touch-ui.editing-node .node.editing {
  opacity: 0 !important;
  pointer-events: none !important;
  background: transparent !important;
  border-color: transparent !important;
  outline: none !important;
}
.touch-ui.editing-node .node.editing .port {
  opacity: 0 !important;
  pointer-events: none !important;
}
.node.editing .node-text:empty::before { content: none; }
.node.dragging { cursor: grabbing; }

.port {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--ink);
  cursor: crosshair;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.08s linear;
}

.node.ports-hot .port,
.node.link-target .port,
.touch .node.selected .port {
  opacity: 1;
  pointer-events: auto;
}

.port-l { left: -6px; top: 50%; transform: translateY(-50%); }
.port-r { right: -6px; top: 50%; transform: translateY(-50%); }
.port-t { top: -6px; left: 50%; transform: translateX(-50%); }
.port-b { bottom: -6px; left: 50%; transform: translateX(-50%); }

body.readonly .port { display: none; }
body.readonly .node { pointer-events: none; cursor: default; }

.hud {
  position: absolute;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.hud-left { top: var(--hud-top); left: var(--hud-side); flex-direction: column; align-items: flex-start; gap: 6px; }
.hud-right {
  top: calc(var(--hud-top) + 0.5lh - var(--hud-burger) / 2);
  right: var(--hud-side);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.hud-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--hud-burger);
  height: var(--hud-burger);
  flex-shrink: 0;
  padding: 0;
  border-radius: 50%;
  border: var(--ui-stroke) solid rgba(17, 17, 17, 0.35);
  background: rgba(255, 255, 255, 0.55);
  color: rgba(17, 17, 17, 0.55);
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
}

.hud-burger svg { width: 17px; height: 17px; display: block; }

.hud-right:hover .hud-burger,
.hud-burger:focus { opacity: 1; }

.hud-burger:hover,
.hud-burger:focus {
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  border-color: var(--ink);
}

.hud-burger.active {
  opacity: 1;
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.board-menu {
  display: flex;
  flex-direction: column;
  min-width: 240px;
  background: #fff;
  border: var(--ui-stroke) solid var(--ink);
  border-radius: 14px;
  padding: 6px;
  gap: 2px;
}

.hud-actions {
  display: none;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  width: fit-content;
}

.hud-actions.open { display: flex; }

.board-menu > button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
  letter-spacing: -0.2px;
  white-space: nowrap;
  transition: background 0.12s;
}

@media (hover: hover) {
  .board-menu > button:hover {
    background: #f0f0f0;
    color: var(--ink);
  }
}

.board-menu > button:active {
  background: #f0f0f0;
  color: var(--ink);
}

.hud-actions .text-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding: 6px 14px;
  border: var(--ui-stroke) solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  letter-spacing: -0.2px;
  white-space: nowrap;
  line-height: 1.2;
  transition: background 0.12s;
}

@media (hover: hover) {
  .hud-actions .text-btn:hover {
    background: #f0f0f0;
    color: var(--ink);
  }
}

.hud-actions .text-btn:active {
  background: #f0f0f0;
  color: var(--ink);
}

.bm-sep {
  height: 1px;
  background: #eee;
  margin: 4px 2px;
  flex-shrink: 0;
}

.board-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 1lh;
}

.board-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  letter-spacing: -0.3px;
  color: var(--ink);
}

.board-btn .caret { color: #b3b3b3; }
body.readonly .board-btn { cursor: default; }
body.readonly .board-btn .caret { display: none; }

#board-name { outline: none; }
.board-bar.editing .caret { display: none; }
.board-bar.editing #board-name {
  cursor: text;
  border-bottom: var(--ui-stroke) solid var(--ink);
  min-width: 60px;
}
#board-name[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: #b3b3b3;
}

.hud-status { color: #b3b3b3; }
.hud-status.saving { color: #d99000; }

.bm-row {
  display: flex;
  align-items: center;
  gap: 0;
  border-radius: 8px;
  background: #fff;
  transition: background 0.12s;
}

@media (hover: hover) {
  .bm-row:hover {
    background: #f0f0f0;
  }
}

.bm-row:active {
  background: #f0f0f0;
}

.bm-row .bm-item {
  flex: 1;
  min-width: 0;
  width: auto;
  display: block;
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 6px 8px 10px;
  border-radius: 8px 0 0 8px;
  cursor: pointer;
  color: var(--ink);
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bm-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  gap: 2px;
  padding-right: 4px;
}

.bm-act {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: #bbb;
  line-height: 1;
  font-size: 1em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s, background 0.12s;
}

@media (hover: hover) {
  .bm-act:hover {
    color: var(--ink);
    background: rgba(0, 0, 0, 0.06);
  }
}

.bm-act:active {
  color: var(--ink);
  background: rgba(0, 0, 0, 0.06);
}

.bm-rename {
  font-size: 0.9em;
}

.bm-del.confirm {
  color: #c0392b;
  background: #fff0f0;
}

.bm-del.confirm:hover,
.bm-del.confirm:active {
  background: #ffe8e8;
}

.bm-rename-input {
  flex: 1;
  min-width: 0;
  margin: 4px 0 4px 8px;
  padding: 7px 10px;
  border: var(--ui-stroke) solid var(--ink);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: var(--ink);
  outline: none;
}

.board-menu .bm-item.active { font-weight: 500; }

.marquee {
  position: absolute;
  border: var(--ui-stroke) solid #4a90d9;
  background: rgba(74, 144, 217, 0.08);
  pointer-events: none;
  z-index: 5;
}

.board-gizmo {
  position: absolute;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.board-gizmo.hidden { display: none; }

.board-gizmo .mob-bubble {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 76px;
  height: 40px;
  margin: 0;
  padding: 0 16px;
  font: inherit;
  line-height: 1;
  text-align: center;
  box-sizing: border-box;
  pointer-events: auto;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
  overflow: hidden;
}

.board-gizmo .board-gizmo-image {
  cursor: pointer;
}

.board-gizmo .mob-bubble-label {
  display: block;
  line-height: 1;
  pointer-events: none;
}

.board-gizmo .board-gizmo-file {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  opacity: 0;
  font-size: 0;
  cursor: pointer;
  pointer-events: none;
}

.board-gizmo .board-gizmo-image.active .board-gizmo-file {
  pointer-events: auto;
}

.gizmo-pick-input {
  position: fixed;
  width: 48px;
  height: 48px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  opacity: 0.001;
  font-size: 16px;
  pointer-events: auto;
  z-index: 100001;
}

.gizmo-pick-input.hidden {
  display: none;
  pointer-events: none;
}

.board-gizmo .mob-bubble.active {
  background: var(--ink);
  color: #fff;
}

.image-file-input {
  position: fixed;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0.001;
  pointer-events: none;
  z-index: -1;
}

.find-bar {
  position: absolute;
  top: var(--hud-top);
  left: 50%;
  transform: translateX(-50%);
  z-index: 14;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 6px 5px 10px;
  background: #fff;
  border: var(--ui-stroke) solid var(--ink);
  border-radius: 12px;
}

.find-bar input {
  border: none;
  outline: none;
  background: none;
  min-width: 180px;
  padding: 4px 2px;
  color: var(--ink);
}

.find-count {
  color: #9a9a9a;
  font-size: 0.85em;
  min-width: 38px;
  text-align: center;
}

.find-nav {
  border: none;
  background: none;
  cursor: pointer;
  color: #8a8a8a;
  padding: 3px 7px;
  border-radius: 7px;
  line-height: 1;
}

.find-nav:hover { color: var(--ink); background: #f3f3f3; }

.node.found { outline: var(--ui-stroke) solid #e0a528; outline-offset: 3px; }
.node.found.current { outline: var(--ui-stroke) solid #e06a1f; outline-offset: 3px; }

@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  .find-bar {
    top: max(10px, env(safe-area-inset-top));
    left: 50%;
    width: min(320px, calc(100vw - 20px));
  }
  .find-bar input { min-width: 0; flex: 1; min-height: 36px; }
  .find-nav { min-width: 36px; min-height: 36px; }
}

.text-btn {
  display: inline-flex;
  align-items: center;
  border: none;
  background: none;
  padding: 2px 4px;
  color: #8a8a8a;
  cursor: pointer;
  letter-spacing: -0.2px;
}

.text-btn:hover { color: var(--ink); }
.text-btn.copied { color: var(--ink); }

.help-wrap { display: none; }

.help-widget {
  position: absolute;
  left: var(--hud-side);
  bottom: var(--hud-side);
  z-index: 10;
}

.help-trigger {
  width: var(--hud-burger);
  height: var(--hud-burger);
  border-radius: 50%;
  border: var(--ui-stroke) solid rgba(17, 17, 17, 0.35);
  background: rgba(255, 255, 255, 0.55);
  color: rgba(17, 17, 17, 0.55);
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
}

.help-widget:hover .help-trigger,
.help-trigger:focus {
  opacity: 1;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  border-color: var(--ink);
}

.help-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 10px);
  width: max-content;
  min-width: 240px;
  max-width: calc(100vw - 48px);
  padding: 6px 8px;
  background: #fff;
  color: var(--ink);
  border: var(--ui-stroke) solid var(--ink);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.help-panel.hidden { display: none; }

.help-note {
  padding: 8px 10px 6px;
  color: #b3b3b3;
  font-size: 0.92em;
  letter-spacing: -0.2px;
  border-bottom: 1px solid #eee;
  margin-bottom: 2px;
}

.help-item {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 14px;
  padding: 7px 10px;
  border-radius: 8px;
}

.help-desc {
  color: #b3b3b3;
  font-size: 0.92em;
  letter-spacing: -0.2px;
  min-width: max-content;
}

.help-keys {
  color: var(--ink);
  letter-spacing: -0.2px;
  text-align: right;
  white-space: nowrap;
}

.live-badge {
  padding: 2px 8px;
  border-radius: 999px;
  border: var(--ui-stroke) solid #dcc98a;
  color: #7a6520;
  background: #faf5e6;
  font-size: 0.88em;
}

.live-badge.mode-collab {
  border-color: #b8d4be;
  color: #2d6a3a;
  background: #f4fbf5;
}

.share-mode {
  border: var(--ui-stroke) solid #dcc98a;
  border-radius: 999px;
  background: #faf5e6;
  color: #7a6520;
  font-size: 0.88em;
  padding: 2px 10px;
  cursor: pointer;
  letter-spacing: -0.2px;
}

.share-mode.mode-collab {
  border-color: #b8d4be;
  color: #2d6a3a;
  background: #f4fbf5;
}

.console-drawer {
  position: fixed;
  top: 14px;
  right: 14px;
  bottom: 14px;
  left: auto;
  width: min(540px, 46vw);
  min-width: 400px;
  z-index: 25;
  background: #fff;
  border: var(--ui-stroke) solid var(--ink);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 24px));
  transition: transform 0.22s ease;
  box-sizing: border-box;
  font-family: "Mind", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: var(--fs);
  line-height: 1.35;
  text-transform: lowercase;
  color: var(--ink);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.console-drawer.open { transform: translateX(0); }

.console-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  padding: 12px 14px;
  border-bottom: var(--ui-stroke) solid #ececec;
  background: #fafafa;
}

.console-title {
  letter-spacing: -0.3px;
  color: var(--ink);
}

.console-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.console-tool {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: var(--ui-stroke) solid rgba(17, 17, 17, 0.2);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95em;
  line-height: 1;
  color: var(--ink);
  background: #fff;
  transition: background 0.12s, border-color 0.12s;
}

.console-tool svg { display: none; }

.console-tool-close { background: #fff; }
.console-tool-refresh { background: #fff; }

.console-tool-close::after { content: "✕"; }
.console-tool-refresh::after { content: "↻"; }

.console-tool:active { background: #f0f0f0; }

.console-body {
  flex: 1;
  min-height: 0;
  padding: 14px;
  overflow-y: auto;
  overflow-x: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fff;
}

.console-notice {
  padding: 10px 12px;
  border-radius: 10px;
  border: var(--ui-stroke) solid #e8e8e8;
  background: #f6f6f6;
  color: var(--ink);
  line-height: 1.35;
  margin: 0;
  font-size: inherit;
}

.console-notice.error {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.admin-summary {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0;
  padding: 7px 11px;
  margin: 0;
  border-radius: 10px;
  background: #f6f6f6;
  border: var(--ui-stroke) solid #ececec;
  color: #888;
  font-size: 0.88em;
  line-height: 1.3;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.admin-summary::-webkit-scrollbar { display: none; }

.admin-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  flex-shrink: 0;
}

.admin-stat:not(:last-child)::after {
  content: "·";
  margin: 0 8px;
  color: #ccc;
}

.admin-stat-num { color: var(--ink); font-weight: 500; }
.admin-stat-label { color: #888; }
.admin-stat.warn .admin-stat-num,
.admin-stat.warn .admin-stat-label { color: var(--ink); }

.admin-alert {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
}

.admin-alert-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
}

.admin-alert-info {
  color: #fff;
  line-height: 1.4;
}

.admin-alert-info::before { content: "! "; }

.admin-users {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.admin-user {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  border: var(--ui-stroke) solid #e6e6e6;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.admin-user-top {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  min-height: 44px;
  background: #f7f7f7;
  border-bottom: 1px solid #ececec;
}

.admin-user-name {
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  letter-spacing: -0.3px;
  font-weight: 600;
  font-size: 1.02em;
  flex: 1 1 auto;
  min-width: 0;
}

.admin-sessions {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  box-sizing: border-box;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.78em;
  line-height: 1;
}

.admin-user-flag {
  margin-left: auto;
  color: gray;
}

.admin-user-flag::before { content: "["; }
.admin-user-flag::after { content: "]"; }

.admin-actions {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  padding: 2px 0 2px 24px;
  background: linear-gradient(90deg, rgba(247, 247, 247, 0) 0%, rgba(247, 247, 247, 0.92) 28%, #f7f7f7 48%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
}

@media (hover: hover) {
  .admin-user:hover .admin-actions,
  .admin-user:focus-within .admin-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

@media (hover: none) {
  .admin-actions {
    opacity: 1;
    pointer-events: auto;
    position: static;
    transform: none;
    padding: 0;
    background: none;
    margin-left: auto;
    flex-shrink: 0;
  }
}

.admin-act {
  flex: 0 0 auto;
  white-space: nowrap;
  border: none;
  background: #ececec;
  color: #555;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.82em;
  text-transform: lowercase;
  transition: color 0.15s, background 0.15s;
}

.admin-act:hover { color: #fff; background: var(--ink); }
.admin-act:disabled { color: #bbb; cursor: default; background: #f0f0f0; }
.admin-act:disabled:hover { color: #bbb; background: #f0f0f0; }
.admin-act.danger:hover { background: #c0392b; }
.admin-act.confirm { color: #fff; background: #c0392b; }

.admin-dot {
  flex-shrink: 0;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #cfcfcf;
}

.admin-user.is-online .admin-dot { background: #2ec45f; }

.admin-user-meta {
  display: none;
  color: #999;
  font-size: 0.84em;
  line-height: 1.35;
  padding: 6px 12px 8px;
  border-bottom: 1px solid #f0f0f0;
  background: #fcfcfc;
}

.admin-user.show-meta .admin-user-meta { display: block; }

.admin-board-list {
  margin: 0;
  padding: 4px 0;
  list-style: none;
  display: flex;
  flex-direction: column;
}

.admin-board-link {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  cursor: pointer;
  padding: 6px 12px 6px 22px;
  border: none;
  background: none;
  box-sizing: border-box;
  text-align: left;
  white-space: nowrap;
  transition: background 0.12s;
  font-family: inherit;
  font-size: 0.88em;
}

.admin-board-link:last-child { border-bottom: none; }
.admin-board-link:hover { background: #f6f6f6; }
.admin-board-link:active { background: #f0f0f0; }

.admin-board-name {
  color: #444;
  font-weight: 500;
  flex-shrink: 0;
}

.admin-board-name::before {
  content: "— ";
  color: #ccc;
  font-weight: 400;
}

.admin-board-meta {
  color: #aaa;
  font-size: 0.92em;
  text-align: right;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-reset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 9px 11px;
  border-top: 1px solid #e6e6e6;
  background: #fafafa;
}

.admin-reset-input {
  width: 100%;
  padding: 6px 9px;
  border: none;
  border-radius: 5px;
  outline: none;
  background: #fff;
  color: #000;
  box-sizing: border-box;
  font: inherit;
  text-transform: lowercase;
}

.admin-reset-input:focus { background: #fff; box-shadow: inset 0 0 0 var(--ui-stroke) #000; }

.admin-reset-row {
  display: flex;
  gap: 8px;
}

.palette {
  position: absolute;
  z-index: 10;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 7px;
  box-sizing: border-box;
  background: #fff;
  border: var(--ui-stroke) solid var(--ink);
  border-radius: 22px;
  overflow-x: auto;
  scrollbar-width: none;
}

#app > .palette {
  padding: 7px;
  gap: 5px;
  border: var(--ui-stroke) solid var(--ink);
  border-radius: 22px;
}

#app > .palette .swatch {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-width: var(--ui-stroke);
  box-sizing: border-box;
}

.palette::-webkit-scrollbar { display: none; }

.swatch {
  width: 26px;
  height: 26px;
  box-sizing: border-box;
  border-radius: 50%;
  border: var(--ui-stroke) solid #d6d6d6;
  background: var(--c);
  cursor: pointer;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  display: block;
  line-height: 0;
  appearance: none;
  -webkit-appearance: none;
}

.swatch:hover { border-color: #999; }
.swatch.active { border-color: var(--ink); }
.swatch-dark.active { border-color: #fff; outline: var(--ui-stroke) solid var(--ink); outline-offset: calc(var(--ui-stroke) * -1); }

.text-btn.active { color: var(--ink); }

.mobile-dock {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 12;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  max-width: calc(100vw - 16px);
}

.mobile-dock.edge-only #mobile-edit,
.mobile-dock.edge-only #mobile-image,
.mobile-dock.edge-only #palette {
  display: none !important;
}

.mob-bubble {
  flex-shrink: 0;
  min-width: 0;
  min-height: 40px;
  height: 40px;
  padding: 0 12px;
  border: var(--ui-stroke) solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  cursor: pointer;
  letter-spacing: -0.2px;
  font-size: 0.84em;
}

.mob-bubble-danger { color: #c0392b; }

.mobile-dock .palette {
  position: static;
  left: auto;
  bottom: auto;
  transform: none;
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  max-width: min(240px, calc(100vw - 150px));
  height: auto;
  padding: 7px;
  box-sizing: border-box;
  margin: 0;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  border: var(--ui-stroke) solid var(--ink);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
}

.mobile-dock .swatch {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-width: var(--ui-stroke);
  box-sizing: border-box;
}

.mobile-dock .palette::-webkit-scrollbar { display: none; }

.mobile-dock .palette.hidden { display: none; }

.touch-ui.editing-node .mobile-dock { display: none !important; }

.touch-input {
  position: fixed;
  z-index: 60;
  margin: 0;
  padding: 0;
  border: var(--ui-stroke) solid var(--ink);
  outline: none;
  background: #fff;
  color: var(--ink);
  caret-color: var(--ink);
  resize: none;
  overflow: hidden;
  font-family: "Mind", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  -webkit-text-size-adjust: 100%;
  text-align: center;
  box-sizing: border-box;
  white-space: pre;
  overflow-wrap: normal;
  word-break: normal;
  -webkit-text-fill-color: currentColor;
  border-radius: 24px;
  -webkit-appearance: none;
  appearance: none;
}

.touch-input.hidden { display: none !important; }

.touch-input::placeholder {
  color: var(--ph, #bbb);
  opacity: 1;
}

.touch-ui:not(.editing-node) html,
.touch-ui:not(.editing-node) body {
  min-height: calc(var(--app-h, 100dvh) + 1px);
}

.touch-ui.editing-node html,
.touch-ui.editing-node body {
  min-height: var(--app-h, 100dvh);
  height: var(--app-h, 100dvh);
}

.touch-ui html,
.touch-ui body {
  overflow-x: hidden;
  overscroll-behavior: none;
}

.touch-ui .app {
  position: fixed;
  top: var(--app-offset, 0);
  left: 0;
  right: 0;
  height: var(--app-h, 100dvh);
}

.touch-ui.standalone .app {
  top: 0;
  height: var(--app-h, 100dvh);
}

@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  :root { --fs: 16px; }

  button,
  input,
  .text-btn,
  .board-btn,
  .hud-burger,
  .mob-bubble,
  .swatch,
  .admin-act {
    touch-action: manipulation;
  }

  .hud-left {
    top: max(var(--hud-top), env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
    max-width: calc(100vw - 120px);
  }

  .hud-right {
    top: calc(max(var(--hud-top), env(safe-area-inset-top)) + 0.5lh - var(--hud-burger) / 2);
    right: max(10px, env(safe-area-inset-right));
  }

  :root {
    --hud-burger: 40px;
  }

  .hud-burger {
    width: var(--hud-burger);
    height: var(--hud-burger);
    opacity: 1;
    background: rgba(255, 255, 255, 0.94);
    color: var(--ink);
    border-color: var(--ink);
  }

  .hud-burger svg { width: 20px; height: 20px; }

  .hud-actions .text-btn {
    min-height: 40px;
    padding: 8px 14px;
  }

  .text-btn {
    min-height: 36px;
    padding: 6px 8px;
  }

  .palette { max-width: min(320px, calc(100vw - 88px)); }

  .app, .node, .text-btn, .hud-burger, .mob-bubble, .swatch {
    -webkit-tap-highlight-color: transparent;
  }

  .node-text { -webkit-touch-callout: none; }
  .node.editing .node-text {
    -webkit-touch-callout: default;
    pointer-events: none;
    -webkit-user-select: none;
    user-select: none;
  }

  .board-menu {
    min-width: min(300px, calc(100vw - 32px));
    max-height: min(50vh, 360px);
    overflow: auto;
  }

  .board-menu > button {
    min-height: 40px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .bm-row .bm-item {
    min-height: 40px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .bm-act {
    width: 36px;
    height: 36px;
    min-height: 36px;
  }

  .help-widget {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 20;
  }

  .help-trigger {
    display: none;
  }

  .help-panel {
    position: fixed;
    right: max(10px, env(safe-area-inset-right));
    top: max(54px, calc(10px + env(safe-area-inset-top)));
    left: auto;
    bottom: auto;
    width: max-content;
    min-width: 220px;
    max-width: calc(100vw - 24px);
    max-height: 46vh;
    overflow: auto;
    pointer-events: auto;
    padding: 6px 8px;
  }

  .help-item {
    column-gap: 12px;
    padding: 9px 10px;
  }

  .mobile-dock {
    bottom: max(10px, env(safe-area-inset-bottom));
  }

  @media (orientation: landscape) {
    .mobile-dock .palette {
      overflow-x: visible;
      max-width: none;
      flex: 0 1 auto;
    }
  }

  @media (orientation: portrait) {
    .mobile-dock .palette {
      overflow-x: auto;
      max-width: min(240px, calc(100vw - 150px));
      flex: 1 1 auto;
    }
  }

  .port {
    width: 16px;
    height: 16px;
    touch-action: none;
  }

  .port::before {
    content: "";
    position: absolute;
    inset: -12px;
  }

  .port-l { left: -8px; }
  .port-r { right: -8px; }
  .port-t { top: -8px; }
  .port-b { bottom: -8px; }

  .node {
    padding: 7px 16px;
    touch-action: none;
  }

  .node.node-image {
    display: block;
    padding: 0;
    border: none;
    background: transparent;
    overflow: hidden;
  }

  .touch .node.selected .port,
  .touch .node.ports-hot .port,
  .touch .node.link-target .port {
    opacity: 1;
    pointer-events: auto;
  }

  .touch .edge-hit { stroke-width: 28; }

  .console-drawer {
    top: var(--app-offset, 0);
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    height: var(--app-h, 100dvh);
    min-width: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    transform: translateX(100%);
  }

  .console-drawer.open {
    transform: translateX(0);
  }

  .console-toolbar {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }

  .console-body {
    padding: 10px max(10px, env(safe-area-inset-left)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-right));
    gap: 10px;
  }

  .admin-summary {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    padding: 7px 8px;
    font-size: 0.74em;
    line-height: 1;
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-stat {
    flex: 0 0 auto;
    gap: 2px;
    flex-direction: row;
    align-items: baseline;
    text-align: left;
  }

  .admin-stat:not(:last-child)::after {
    content: "·";
    margin: 0 4px;
    color: #ccc;
  }

  .admin-stat-label {
    font-size: 1em;
  }

  .console-tool {
    width: 36px;
    height: 36px;
  }

  .console-tool { color: var(--ink); }

  .auth-card {
    width: min(340px, calc(100vw - 24px));
    padding: 22px 20px;
  }

  .auth-card input,
  .btn-primary {
    min-height: 44px;
  }
}
