:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #22363a;
  background: #edf2f1;
  --muted: #536a6c;
  --border: #d6e1df;
  --accent: #145a52;
  --active: #e4f1eb;
  --panel: #fff;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 280px; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .42; }
button, input, textarea, select { color: inherit; }
:focus-visible { outline: 2px solid #16766b; outline-offset: 2px; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.site-header {
  min-height: 5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem 1.5rem;
  padding: .85rem 1.6rem;
  background: #153b3a;
  color: #f4fbf7;
}
.identity, .workspace-actions { display: flex; align-items: center; gap: .7rem; }
.identity { gap: .8rem; }
.brand-mark { display: grid; place-items: center; width: 2.55rem; height: 2.55rem; border-radius: .65rem; background: #d6e9c9; color: #214841; flex: none; }
.brand-mark .icon { width: 1.6rem; height: 1.6rem; }
.brand-mark circle { fill: #d6e9c9; }
h1 { margin: 0; font-size: 1.35rem; line-height: 1.15; letter-spacing: -.035em; font-weight: 680; }
.identity p { margin: .25rem 0 0; color: #c4dcd5; font-size: .8125rem; }
.header-button { padding: .58rem .82rem; border-radius: .45rem; font-size: .875rem; font-weight: 620; color: inherit; background: transparent; border: 1px solid #5a7b75; white-space: nowrap; }
.header-button:hover:not(:disabled) { background: #28504d; }
.header-button.primary { background: #e6efcd; border-color: #e6efcd; color: #193d33; }
.header-button.primary:hover { background: #f4f8e8; }
.site-header :focus-visible { outline-color: #e6efcd; }

.workspace { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1rem; padding: 1rem; height: calc(100vh - 5rem); min-height: 36rem; }
.toolbox, .board { background: var(--panel); border: 1px solid var(--border); border-radius: .75rem; }
.toolbox { padding: .95rem .75rem .8rem; display: flex; flex-direction: column; gap: .9rem; }
.tool-group { display: grid; gap: .16rem; }
.tool-group h2 { margin: 0 0 .25rem .52rem; color: var(--muted); font-size: .75rem; font-weight: 675; letter-spacing: .055em; text-transform: uppercase; }
.tool { display: flex; align-items: center; gap: .66rem; width: 100%; min-height: 2.28rem; border: 1px solid transparent; border-radius: .43rem; background: transparent; padding: .32rem .5rem; text-align: left; font-size: .875rem; white-space: nowrap; }
.tool:hover { background: #f0f5f3; }
.tool[aria-pressed="true"] { background: var(--active); color: #15574c; border-color: #d2e6dd; font-weight: 680; }
.tool-key { display: grid; place-items: center; min-width: 1.2rem; height: 1.2rem; margin-inline-start: auto; padding-inline: .15rem; border: 1px solid #c7d8d2; border-bottom-width: 2px; border-radius: .24rem; background: #fff; color: #3d5d58; font: 650 .75rem/1 system-ui, sans-serif; }
.privacy { padding: .7rem .45rem 0; border-top: 1px solid #e1e9e6; color: var(--muted); margin: auto 0 0; font-size: .78rem; }

.board { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.board-bar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: .45rem .7rem; min-height: 3.35rem; padding: .5rem .75rem; border-bottom: 1px solid var(--border); }
.board-tools { grid-column: 2; min-width: 0; }
.inspector { display: flex; align-items: center; flex-wrap: wrap; gap: .35rem .65rem; }
.history { display: flex; gap: .18rem; padding-right: .65rem; border-right: 1px solid var(--border); }
.icon-button { display: grid; place-items: center; width: 2rem; height: 2rem; border: 1px solid transparent; border-radius: .34rem; background: transparent; padding: 0; color: #334e50; flex: none; }
.icon-button:hover:not(:disabled) { background: #e8f0ed; }
.board-footer { display: flex; align-items: center; min-height: 2.65rem; padding: .55rem .8rem; border-top: 1px solid var(--border); }
#status { margin: 0; font-size: .875rem; color: var(--muted); }
.edge-mode { display: inline-flex; align-items: center; gap: .35rem; font-size: .875rem; white-space: nowrap; }
input[type="checkbox"] { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); }

.viewport {
  position: relative;
  flex: 1;
  min-height: 25rem;
  overflow: hidden;
  isolation: isolate;
  background-color: #f9fbf9;
  background-image: radial-gradient(circle, #bacdc7 1px, transparent 1.15px);
  background-size: 24px 24px;
  outline-offset: -3px;
}
#drawing, #cards { position: absolute; inset: 0; width: 100%; height: 100%; }
#drawing { display: block; touch-action: none; }
#cards { pointer-events: none; transform-origin: 0 0; }
.viewport.is-dragging { cursor: grabbing; }
.viewport[data-tool="note"], .viewport[data-tool="table"], .viewport[data-tool="vertex"], .viewport[data-tool="edge"], .viewport[data-tool="pen"], .viewport[data-tool="rectangle"], .viewport[data-tool="ellipse"] { cursor: crosshair; }
.empty-board { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 1rem; pointer-events: none; text-align: center; user-select: none; }
.empty-icon { width: 3rem; height: 3rem; display: grid; place-items: center; border: 1px dashed #9ebcb1; border-radius: .8rem; background: #eef5f0; color: #387166; }
.empty-board h2 { margin: .8rem 0 .24rem; font-size: 1.25rem; font-weight: 675; letter-spacing: -.03em; }
.empty-board p { margin: 0; color: var(--muted); font-size: .875rem; }
.zoom-controls { grid-row: 1; grid-column: 3; display: flex; align-items: center; gap: .12rem; }
.zoom-controls output { min-width: 3rem; text-align: center; font-variant-numeric: tabular-nums; font-size: .8125rem; }
.zoom-controls .fit-button { border-left-color: var(--border); border-radius: 0 .34rem .34rem 0; }

.graphic { outline: none; }
.graphic[data-kind="node"] { cursor: grab; }
.viewport[data-tool="edge"] .graphic[data-kind="node"] { cursor: crosshair; }
.edge-hit { fill: none; stroke: transparent; stroke-width: 16; }
.edge-line { fill: none; stroke-width: 2.35; stroke-linecap: round; }
.edge-halo { fill: none; stroke: #b6d9d0; stroke-width: 8; stroke-linecap: round; }
.vertex-halo { fill: none; stroke: #79b5a8; stroke-width: 2; stroke-dasharray: 4 3; }
.vertex { stroke-width: 2.25; }
.vertex-label, .edge-label { pointer-events: none; text-anchor: middle; dominant-baseline: central; user-select: none; }
.vertex-label { font-size: 14px; font-weight: 680; }
.edge-label, .vertex-caption { paint-order: stroke; stroke: #f9fbf9; stroke-width: 5; stroke-linejoin: round; pointer-events: visiblePainted; }
.edge-label { font-size: 14px; font-weight: 675; }
.mark-halo { fill: none; stroke: #a8d2c7; stroke-width: 9; }
.mark-line { stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.mark-hit { fill: none; stroke: transparent; stroke-width: 15; pointer-events: stroke; }
.graphic[data-kind="rectangle"] .mark-hit, .graphic[data-kind="ellipse"] .mark-hit { pointer-events: all; }
.viewport[data-tool="select"] .graphic[data-kind="rectangle"], .viewport[data-tool="select"] .graphic[data-kind="ellipse"] { cursor: grab; }
.edge-halo, .vertex-halo, .mark-halo { pointer-events: none; visibility: hidden; }
.graphic.is-selected .edge-halo, .graphic.is-selected .vertex-halo, .graphic.is-selected .mark-halo,
.graphic:focus-visible .edge-halo, .graphic:focus-visible .vertex-halo, .graphic:focus-visible .mark-halo { visibility: visible; }
.viewport.is-dragging .graphic[data-kind] { cursor: inherit; }
.shape-bounds { fill: none; stroke: #56998b; stroke-width: 1; stroke-dasharray: 4 3; pointer-events: none; }
.shape-handle { outline: none; }
.shape-handle[data-resize-corner="nw"], .shape-handle[data-resize-corner="se"], .viewport.is-resizing[data-resize-cursor="nwse"] { cursor: nwse-resize; }
.shape-handle[data-resize-corner="ne"], .shape-handle[data-resize-corner="sw"], .viewport.is-resizing[data-resize-cursor="nesw"] { cursor: nesw-resize; }
.handle-hit { fill: transparent; }
.handle-mark { fill: #fff; stroke: #277b6e; stroke-width: 1.6; pointer-events: none; }
.shape-handle:hover .handle-mark, .shape-handle:focus-visible .handle-mark { fill: #277b6e; }

.canvas-card { position: absolute; width: max-content; min-width: 13rem; border: 1px solid #b9cfca; border-radius: .55rem; background: white; color: #233a3b; box-shadow: 0 3px 11px #1d42351a; }
.canvas-card[data-kind="note"] { width: 17rem; min-width: 0; }
.viewport[data-tool="select"] .canvas-card { pointer-events: auto; }
.canvas-card.is-selected { z-index: 1; outline: 2px solid #56998b; outline-offset: 2px; }
.card-header { padding: .37rem .48rem; border-bottom: 1px solid #d7e4df; border-radius: .49rem .49rem 0 0; background: var(--card-tone, #e9f2ec); }
.card-title-row { display: flex; align-items: center; gap: .32rem; }
.drag-card { width: 1.6rem; height: 1.6rem; cursor: grab; touch-action: none; }
.drag-card .icon { width: 1.05rem; height: 1.05rem; }
.canvas-card input, .canvas-card textarea { border: 0; background: transparent; border-radius: 0; }
.card-title { flex: 1; min-width: 0; padding: .17rem .15rem; font-size: .875rem; font-weight: 675; }
.card-note { display: block; width: 100%; min-height: 7.25rem; max-height: 30rem; padding: .62rem .75rem; line-height: 1.45; resize: none; font-size: 1rem; }
.note-resize { position: absolute; z-index: 1; top: 2.4rem; bottom: .25rem; width: 14px; padding: 0; border: 0; border-radius: 3px; background: transparent; cursor: ew-resize; touch-action: none; }
.note-resize[data-note-edge="left"] { left: -7px; }
.note-resize[data-note-edge="right"] { right: -7px; }
.note-resize::after { content: ""; position: absolute; top: 50%; left: 5px; width: 4px; height: 32px; border-radius: 3px; transform: translateY(-50%); background: #56998b; opacity: 0; }
.canvas-card.is-selected .note-resize::after, .canvas-card:hover .note-resize::after, .note-resize:focus-visible::after { opacity: 1; }
.note-resize:hover::after, .note-resize:focus-visible::after { background: #246c61; }
.viewport.is-resizing[data-resize-cursor="ew"] { cursor: ew-resize; }
.card-table { border-spacing: 0; table-layout: fixed; }
.card-table td, .card-table th { padding: 0; border-right: 1px solid #dce7e3; border-bottom: 1px solid #dce7e3; }
.card-table tr > :last-child { border-right: 0; }
.card-table tbody tr:last-child > * { border-bottom: 0; }
.card-table th { background: #f0f5f2; }
.card-table .highlighted { background: var(--cell-highlight); }
.cell-input { display: block; width: 4.1rem; height: 2.15rem; padding: .2rem .35rem; text-align: center; font-variant-numeric: tabular-nums; font-size: .875rem; }
.cell-input.is-active-cell { box-shadow: inset 0 0 0 2px #56998b; }
.card-table tr > :first-child .cell-input { width: 4.8rem; }
.card-table th .cell-input { font-weight: 650; }
.canvas-card :focus-visible { outline-offset: -2px; }

.selection-kind { color: var(--muted); font-size: .8rem; font-weight: 675; }
.label-control { display: flex; align-items: center; gap: .35rem; font-size: .875rem; }
.label-control input { width: 8rem; min-height: 1.9rem; border: 1px solid #bbcfc8; border-radius: .33rem; padding: .2rem .35rem; }
.palette { display: flex; align-items: center; gap: .11rem; }
.swatch { display: grid; place-items: center; width: 1.55rem; height: 1.55rem; padding: 0; border: 1px solid transparent; border-radius: 50%; background: transparent; }
.swatch::after { content: ""; width: .9rem; height: .9rem; border-radius: 50%; background: var(--swatch); }
.swatch:hover, .swatch[aria-pressed="true"] { border-color: var(--swatch); }
.table-controls { contain: inline-size; display: flex; align-items: center; flex-wrap: wrap; gap: .3rem .6rem; padding: .2rem .15rem .1rem; }
.table-dimension { display: inline-flex; align-items: center; gap: .22rem; font-size: .8rem; }
.table-dimension span { margin-inline-end: .1rem; }
.table-actions { display: flex; flex-wrap: wrap; gap: .25rem; }
.table-controls button, .table-actions button { background: #f6faf8; border: 1px solid var(--border); border-radius: .33rem; min-height: 1.85rem; }
.table-controls button { min-width: 1.65rem; padding: .12rem .25rem; font-size: .95rem; line-height: 1; }
.table-actions button { padding: .15rem .48rem; font-size: .8rem; }
.table-controls button:hover:not(:disabled), .table-actions button:hover:not(:disabled) { background: var(--active); }
.highlight-control { position: relative; display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; white-space: nowrap; }
.highlight-control::after { content: ""; position: absolute; right: .5rem; width: .35rem; height: .35rem; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: translateY(-2px) rotate(45deg); pointer-events: none; }
.highlight-control select { appearance: none; min-width: 4.4rem; min-height: 1.85rem; padding: .15rem 1.2rem .15rem .4rem; border: 1px solid var(--border); border-radius: .33rem; background: var(--cell-highlight, #f6faf8); }
.highlight-control select:disabled { opacity: .5; }
.delete-button { color: #9f3b46; }

@media (max-width: 780px) {
  .workspace { height: auto; min-height: calc(100vh - 5rem); grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(30rem, 1fr); gap: .55rem; padding: .55rem; }
  .site-header { padding-inline: .85rem; }
  .toolbox { flex-flow: row wrap; align-items: center; padding: .45rem; gap: .45rem .25rem; }
  .tool-group { grid-template-columns: repeat(2, max-content); padding-right: .25rem; border-right: 1px solid var(--border); }
  .tool-group:last-of-type { grid-template-columns: repeat(3, max-content); }
  .tool-group h2 { grid-column: 1 / -1; margin: 0 0 0 .5rem; }
  .tool { width: auto; gap: .3rem; }
  .privacy { flex-basis: 100%; border: 0; padding: 0 .5rem; margin: 0; }
  .board-tools { grid-row: 2; grid-column: 1 / -1; }
}

@media (max-width: 470px) {
  .site-header { flex-wrap: wrap; }
  .board-bar, .board-footer { padding-inline: .45rem; }
  .workspace-actions { gap: .4rem; }
  .header-button { padding-inline: .6rem; }
}

@media (max-width: 350px) {
  .tool-group:last-of-type { grid-template-columns: repeat(2, max-content); }
}

