:root {
  color-scheme: light;
  --ink: #172033;
  --muted: #697386;
  --line: #dce1e8;
  --panel: rgba(255, 255, 255, .94);
  --accent: #1769e0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; background: #fff; }
button, select, input { font: inherit; }
button, summary, select, input[type="color"] { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.app { position: fixed; inset: 0; width: 100%; height: 100dvh; min-width: 320px; overflow: hidden; background: #fff; }
#board { display: block; width: 100%; height: 100%; background: #fff; cursor: crosshair; touch-action: none; }
#board[data-cursor="grab"] { cursor: grab; }
#board[data-cursor="grabbing"] { cursor: grabbing; }

.topbar, .toolbar, .zoom-badge, .toast { position: fixed; z-index: 2; }
.topbar {
  top: max(10px, env(safe-area-inset-top)); left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right));
  display: flex; align-items: center; justify-content: space-between; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 8px; margin-right: auto; padding-left: 9px; color: var(--ink); font-size: .76rem; font-weight: 760; letter-spacing: .02em; }
.brand span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 11px 0 #f0a52b; margin-right: 11px; }
.top-actions { display: flex; align-items: center; gap: 5px; }
.icon-button, .action-button, .tool-button, .width-control, .color-control {
  min-width: 44px; min-height: 44px; border: 1px solid var(--line); background: var(--panel); box-shadow: 0 3px 14px rgba(23, 32, 51, .08); backdrop-filter: blur(10px);
}
.icon-button, .action-button, .tool-button { display: inline-flex; align-items: center; justify-content: center; padding: 0; cursor: pointer; }
.icon-button { border-radius: 13px; }
.icon-button svg, .action-button svg, .tool-button svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hub-link { margin-right: 4px; color: var(--ink); text-decoration: none; }
.action-button { gap: 7px; padding: 0 14px; border-radius: 13px; color: #fff; border-color: var(--ink); background: var(--ink); font-size: .78rem; font-weight: 700; }
button:disabled { opacity: .36; cursor: default; }
button:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid rgba(23, 105, 224, .3); outline-offset: 2px; }

.more-menu { position: relative; }
.more-menu summary { list-style: none; }
.more-menu summary::-webkit-details-marker { display: none; }
.more-menu summary svg circle { fill: currentColor; stroke: none; }
.menu-panel { position: absolute; top: 51px; right: 0; width: 218px; padding: 7px; border: 1px solid var(--line); border-radius: 15px; background: #fff; box-shadow: 0 14px 35px rgba(23, 32, 51, .16); }
.menu-panel button { width: 100%; min-height: 42px; display: flex; align-items: center; justify-content: space-between; padding: 0 11px; border: 0; border-radius: 9px; background: transparent; text-align: left; cursor: pointer; font-size: .82rem; }
.menu-panel button:hover { background: #f2f5f9; }
.menu-panel button span { color: var(--muted); font-size: .72rem; }
.menu-panel .danger { color: #b42318; }
.menu-panel p { margin: 6px 9px 5px; color: var(--muted); font-size: .66rem; line-height: 1.35; }

.toolbar {
  left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px; padding: 6px; border: 1px solid var(--line); border-radius: 19px; background: var(--panel); box-shadow: 0 10px 32px rgba(23, 32, 51, .15); backdrop-filter: blur(12px);
}
.tool-group { display: flex; gap: 2px; }
.tool-button { min-width: 49px; height: 50px; flex-direction: column; gap: 2px; border: 0; border-radius: 13px; background: transparent; box-shadow: none; }
.tool-button span { font-size: .59rem; color: var(--muted); }
.tool-button.active { color: #fff; background: var(--ink); }
.tool-button.active span { color: #fff; }
.tool-settings { display: flex; gap: 5px; padding-left: 7px; border-left: 1px solid var(--line); }
.color-control, .width-control { position: relative; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px; overflow: hidden; cursor: pointer; box-shadow: none; }
.color-control input { position: absolute; inset: -8px; width: 60px; height: 60px; opacity: 0; cursor: pointer; }
.color-control i { width: 22px; height: 22px; border: 4px solid #fff; border-radius: 50%; background: #172033; box-shadow: 0 0 0 1px #adb5c2; pointer-events: none; }
.width-control select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.width-control i { width: 24px; height: 5px; border-radius: 5px; background: var(--ink); pointer-events: none; }
.zoom-badge { left: 50%; bottom: calc(max(12px, env(safe-area-inset-bottom)) + 78px); transform: translate(-50%, 8px); padding: 5px 9px; border-radius: 20px; color: #fff; background: rgba(23, 32, 51, .76); font-size: .67rem; opacity: 0; transition: opacity .15s, transform .15s; pointer-events: none; }
.zoom-badge.show { opacity: 1; transform: translate(-50%, 0); }
.toast { left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 56px); transform: translate(-50%, -8px); max-width: calc(100vw - 30px); padding: 10px 14px; border-radius: 10px; color: #fff; background: var(--ink); font-size: .75rem; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 620px) {
  .brand { display: none; }
  .topbar { align-items: flex-start; }
  .action-button { width: 44px; padding: 0; }
  .action-button span { display: none; }
  .toolbar { width: calc(100% - 16px); bottom: max(8px, env(safe-area-inset-bottom)); justify-content: space-between; gap: 3px; padding: 5px; border-radius: 17px; }
  .tool-group { flex: 1; justify-content: space-around; }
  .tool-button { min-width: 43px; width: 25%; height: 48px; }
  .tool-settings { gap: 3px; padding-left: 4px; }
  .color-control, .width-control { width: 42px; height: 42px; }
  .zoom-badge { bottom: calc(max(8px, env(safe-area-inset-bottom)) + 70px); }
}

@media (max-width: 360px) {
  .tool-button { min-width: 39px; }
  .tool-button span { display: none; }
  .tool-settings { border-left: 0; padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
