:root {
  --ink: #1f2937;
  --ink-strong: #111827;
  --muted: #6b7280;
  --paper: #f7f4ec;
  --surface: rgba(255, 255, 255, .92);
  --surface-strong: #ffffff;
  --line: rgba(31, 41, 55, .12);
  --line-strong: rgba(31, 41, 55, .2);
  --accent: #4263eb;
  --accent-soft: rgba(66, 99, 235, .12);
  --note: #ffe27a;
  --danger: #d92d20;
  --shadow-soft: 0 12px 28px rgba(31, 41, 55, .12);
  --shadow-strong: 0 22px 70px rgba(31, 41, 55, .18);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: "Aptos", "Segoe UI Variable", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at 16% 12%, rgba(66, 99, 235, .15), transparent 34%),
    radial-gradient(circle at 82% 18%, rgba(255, 226, 122, .36), transparent 30%),
    linear-gradient(135deg, #f5f1e8 0%, #eef2f7 58%, #e8edf5 100%);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  display: grid;
  grid-template-columns: 292px 1fr;
  height: 100vh;
  padding: 14px;
  gap: 14px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, .62);
  border-radius: 26px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.78));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 15px;
  color: #fff;
  background:
    linear-gradient(145deg, #202938, #0f172a),
    radial-gradient(circle at 25% 20%, rgba(255,255,255,.3), transparent 32%);
  font-weight: 900;
  letter-spacing: -.08em;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .24);
}

.brand-title {
  font-size: 19px;
  font-weight: 850;
  letter-spacing: -.04em;
}

.brand-subtitle,
.network-line,
.status,
.property-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.primary-btn,
.ghost-btn,
.icon-btn,
.tool,
.zoom-label {
  border: 0;
  border-radius: 14px;
  transition:
    transform .12s ease,
    background .12s ease,
    border-color .12s ease,
    color .12s ease,
    box-shadow .12s ease;
}

.primary-btn {
  padding: 12px 14px;
  color: #fff;
  background: linear-gradient(135deg, #1f2937, #4263eb);
  box-shadow: 0 14px 28px rgba(66, 99, 235, .2);
  font-weight: 800;
}

.ghost-btn {
  padding: 10px 13px;
  background: rgba(31, 41, 55, .08);
  color: var(--ink);
}

.primary-btn:hover,
.ghost-btn:hover,
.icon-btn:hover,
.tool:hover,
.zoom-label:hover {
  transform: translateY(-1px);
}

.panel-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.board-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  min-height: 90px;
  padding-right: 4px;
}

.board-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  background: rgba(255, 255, 255, .76);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.board-item:hover {
  border-color: rgba(66, 99, 235, .28);
  background: #fff;
}

.board-item.active {
  border-color: rgba(66, 99, 235, .5);
  background: var(--accent-soft);
}

.board-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-strong);
  font-weight: 850;
}

.board-item-meta {
  color: var(--muted);
  font-size: 12px;
}

.network-card {
  margin-top: auto;
  border: 1px solid rgba(66, 99, 235, .14);
  border-radius: 22px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(66, 99, 235, .1), rgba(255, 226, 122, .28)),
    rgba(255, 255, 255, .62);
}

.network-title {
  font-weight: 850;
}

.network-url {
  margin-top: 8px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 12px;
  font-family: Consolas, "Courier New", monospace;
}

.workspace {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 28px;
  background: rgba(255,255,255,.42);
  box-shadow: var(--shadow-soft);
}

.topbar {
  position: relative;
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  padding: 14px 16px 10px;
}

.board-title-input {
  flex: 1;
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 16px;
  outline: none;
  padding: 8px 12px;
  background: rgba(255,255,255,.62);
  color: var(--ink-strong);
  font-size: clamp(22px, 2.4vw, 34px);
  font-weight: 900;
  letter-spacing: -.06em;
}

.board-title-input:focus {
  border-color: rgba(66, 99, 235, .32);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(66, 99, 235, .08);
}

.status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 126px;
  white-space: nowrap;
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background:
    radial-gradient(circle at 22% 28%, rgba(255,255,255,.6), transparent 22%),
    linear-gradient(135deg, #faf7ef, #eef2f8);
}

.board-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
  touch-action: none;
}

.toolbar,
.quickbar,
.selection-panel,
.zoom-controls,
.hint {
  position: absolute;
  z-index: 6;
}

.toolbar {
  top: 18px;
  left: 18px;
  display: grid;
  gap: 7px;
  width: 112px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.tool {
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 12px;
  font-weight: 780;
}

.tool-mark {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 9px;
  background: rgba(31, 41, 55, .07);
  color: var(--ink-strong);
  font-size: 11px;
  font-weight: 900;
}

.tool.active {
  border-color: rgba(66, 99, 235, .18);
  background: var(--accent-soft);
  color: #243a90;
}

.tool.active .tool-mark {
  color: #fff;
  background: var(--accent);
}

.quickbar {
  top: 18px;
  left: 144px;
  display: flex;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.icon-btn,
.zoom-label {
  min-width: 40px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 820;
}

.icon-btn:disabled {
  cursor: default;
  opacity: .42;
  transform: none;
}

.icon-btn.danger {
  color: var(--danger);
}

.icon-btn.danger:hover {
  border-color: rgba(217, 45, 32, .18);
  background: rgba(217, 45, 32, .08);
}

.selection-panel {
  top: 18px;
  right: 18px;
  width: 230px;
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.selection-panel[hidden] {
  display: none;
}

.selection-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.selection-type {
  margin-top: 4px;
  color: var(--ink-strong);
  font-weight: 860;
}

.property-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.swatch {
  width: 27px;
  height: 27px;
  border: 2px solid rgba(255,255,255,.9);
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px rgba(31, 41, 55, .16), 0 8px 14px rgba(31, 41, 55, .1);
}

.swatch.active {
  box-shadow: 0 0 0 3px rgba(66, 99, 235, .24), 0 0 0 1px rgba(31, 41, 55, .14);
}

.zoom-controls {
  right: 18px;
  bottom: 18px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(18px);
}

.zoom-label {
  min-width: 68px;
}

.hint {
  left: 18px;
  bottom: 18px;
  max-width: min(760px, calc(100% - 320px));
  border: 1px solid rgba(31, 41, 55, .08);
  border-radius: 16px;
  padding: 9px 12px;
  color: rgba(31, 41, 55, .7);
  background: rgba(255, 255, 255, .76);
  font-size: 12px;
  pointer-events: none;
}

.wb-item {
  cursor: pointer;
}

.wb-item.selected .outline {
  stroke: var(--accent);
  stroke-width: 2.4;
  stroke-dasharray: 8 5;
}

.wb-item.erasing {
  opacity: 0.3;
  transition: opacity 80ms ease-out;
  pointer-events: none;
}

.selection-box {
  fill: rgba(66, 99, 235, .1);
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-dasharray: 8 5;
  pointer-events: none;
}

.note-body {
  stroke: rgba(31, 41, 55, .2);
  stroke-width: 1.4;
  filter: drop-shadow(0 8px 14px rgba(31, 41, 55, .16));
}

.shape-body {
  stroke-width: 2.2;
  filter: drop-shadow(0 7px 13px rgba(31, 41, 55, .08));
}

.resize-handle {
  fill: #fff;
  stroke: var(--accent);
  stroke-width: 2.3;
  cursor: nwse-resize;
  filter: drop-shadow(0 4px 8px rgba(31, 41, 55, .18));
}

.text-dialog {
  width: min(460px, calc(100vw - 32px));
  border: 0;
  border-radius: 24px;
  padding: 18px;
  background: #fff;
  color: var(--ink);
  box-shadow: var(--shadow-strong);
}

.text-dialog::backdrop {
  background: rgba(17, 24, 39, .26);
  backdrop-filter: blur(6px);
}

.text-dialog form {
  display: grid;
  gap: 12px;
}

.text-dialog label {
  font-weight: 850;
}

.text-dialog textarea {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 12px;
  outline: none;
  color: var(--ink);
}

.text-dialog textarea:focus {
  border-color: rgba(66, 99, 235, .42);
  box-shadow: 0 0 0 4px rgba(66, 99, 235, .08);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .sidebar {
    max-height: 260px;
  }

  .workspace {
    min-height: 72vh;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status {
    align-items: flex-start;
  }

  .toolbar {
    width: auto;
    max-width: calc(100% - 36px);
    grid-template-columns: repeat(3, minmax(72px, 1fr));
  }

  .quickbar {
    top: auto;
    left: 18px;
    bottom: 74px;
  }

  .selection-panel {
    top: auto;
    right: 18px;
    bottom: 74px;
    width: min(230px, calc(100% - 36px));
  }

  .hint {
    display: none;
  }
}
