:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1b2535;
  background: #edf1f6;
  --panel: #fff;
  --border: #dbe1ea;
  --muted: #718096;
  --text: #1b2535;
  --node-text: #eef4ff;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; overflow: hidden; }
body.dark { background: #131923; color: #e8edf5; --panel: #1c2533; --border: #303c4e; --muted: #9aa8ba; --text: #e8edf5; --node-text: #eef4ff; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.app { height: 100vh; display: flex; flex-direction: column; }
.topbar { min-height: 64px; background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 20px; padding: 8px 16px; z-index: 3; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 188px; }
.brandmark { color: #558dff; font-size: 30px; line-height: 1; }
.brand b { font-size: 16px; letter-spacing: -.3px; }
.brand small { color: var(--muted); font-size: 10px; margin-left: -4px; margin-top: 23px; }
.toolbar { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.toolbar button, .toolrow button, .page-tabs button, .inspector-actions button {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  border-radius: 6px; padding: 7px 10px; min-height: 34px; font-size: 12px;
}
.toolbar button:hover, .toolbar button.active, .toolrow button.selected, .page-tabs button.active { background: #4f8cff; color: #fff; border-color: #4f8cff; }
.toolbar button:disabled { opacity: .4; cursor: not-allowed; }
.divider { height: 24px; border-left: 1px solid var(--border); margin: 0 4px; }
.zoom { font-size: 12px; min-width: 42px; text-align: center; color: var(--muted); }
.docname { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.docname input { width: 170px; border: 0; background: transparent; color: var(--text); font-weight: 600; text-align: right; outline: none; }
.saved { font-size: 10px; color: #3bbd84; }
.workspace { display: grid; grid-template-columns: 245px 1fr 265px; min-height: 0; flex: 1; }
.panel { background: var(--panel); overflow: auto; }
.left { border-right: 1px solid var(--border); padding: 14px 12px; }
.right { border-left: 1px solid var(--border); padding: 14px; }
.panel-title { font-weight: 700; font-size: 13px; margin-bottom: 12px; }
.search { width: 100%; border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 6px; padding: 9px 10px; outline: none; }
.toolrow { display: flex; gap: 6px; margin: 10px 0; }
.toolrow button { flex: 1; }
.shape-list details { border-top: 1px solid var(--border); padding: 9px 0; }
.shape-list summary { cursor: pointer; font-size: 12px; font-weight: 650; list-style: none; }
.shape-list summary span { float: right; color: var(--muted); }
.shape-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 8px; }
.shape-grid button { min-height: 63px; background: transparent; border: 1px solid transparent; border-radius: 6px; color: var(--text); padding: 5px; }
.shape-grid button:hover { background: rgba(79,140,255,.12); border-color: #4f8cff; }
.shape-grid small { display: block; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 5px; }
.shape-icon { height: 27px; width: 42px; display: block; margin: auto; position: relative; }
.shape-icon i { display: block; position: absolute; left: 9px; top: 5px; width: 25px; height: 17px; border: 2px solid #6592e8; border-radius: 4px; }
.shape-icon.ellipse i { border-radius: 50%; }
.shape-icon.diamond i { transform: rotate(45deg); border-radius: 2px; width: 18px; height: 18px; left: 13px; top: 5px; }
.shape-icon.text i { border: 0; border-bottom: 2px solid #6592e8; }
.shape-icon.cloud i { border-radius: 12px; }
.shape-icon.database i { border-radius: 50%; }
.shape-icon.actor i { width: 14px; height: 14px; border-radius: 50%; left: 15px; }
.templates { margin-top: 18px; }
.templates select, .inspector select { width: 100%; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); color: var(--text); padding: 8px; }
.canvas-wrap { position: relative; overflow: hidden; background: #f4f6fa; }
.dark .canvas-wrap { background: #17202d; }
.canvas { width: 100%; height: 100%; display: block; color: #64748b; }
.canvas-status { position: absolute; top: 12px; left: 16px; z-index: 1; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; font-size: 11px; color: var(--text); box-shadow: 0 2px 8px #0001; }
.canvas-status #counts { color: var(--muted); margin-left: 9px; }
.canvas-help { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); background: var(--panel); padding: 6px 10px; border-radius: 5px; opacity: .88; white-space: nowrap; }
.node { cursor: move; }
.node text { pointer-events: none; user-select: none; }
.node.locked { opacity: .72; }
.selection { fill: none; stroke: #4f8cff; stroke-width: 2; stroke-dasharray: 5 3; pointer-events: none; }
.handle { fill: #fff; stroke: #4f8cff; stroke-width: 2; cursor: nwse-resize; }
.anchor { fill: #4f8cff; stroke: #fff; stroke-width: 2; }
.edge-label { font-size: 12px; fill: var(--text); }
.empty { font-size: 12px; line-height: 1.5; color: var(--muted); padding: 20px 2px; }
.inspector label { display: block; color: var(--muted); font-size: 11px; margin: 10px 0; }
.inspector input, .inspector select { margin-top: 5px; width: 100%; border: 1px solid var(--border); background: transparent; color: var(--text); border-radius: 5px; padding: 7px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inspector-actions { display: flex; gap: 7px; margin-top: 16px; }
.inspector-actions button { flex: 1; }
.inspector-actions .danger { color: #e45d6d; }
.layers { border-top: 1px solid var(--border); margin-top: 20px; padding-top: 15px; }
.page-tabs { display: flex; gap: 5px; margin-bottom: 12px; flex-wrap: wrap; }
.page-tabs button { padding: 6px 9px; }
.check { display: block; font-size: 11px; color: var(--muted); margin: 10px 0; }
.check input { accent-color: #4f8cff; margin-right: 7px; }
@media (max-width: 1050px) {
  .workspace { grid-template-columns: 210px 1fr 225px; }
  .toolbar button { padding: 6px 7px; }
  .brand { min-width: 165px; }
  .docname { display: none; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .app { min-height: 100vh; height: auto; }
  .topbar { align-items: flex-start; flex-wrap: wrap; }
  .toolbar { order: 3; width: 100%; overflow: auto; flex-wrap: nowrap; padding-bottom: 3px; }
  .workspace { grid-template-columns: 1fr; min-height: calc(100vh - 112px); }
  .left, .right { display: none; }
  .canvas-wrap { height: calc(100vh - 112px); min-height: 540px; }
  .canvas-help { font-size: 10px; }
  .brand small { display: none; }
}
