/* Shared tokens — see STYLE.md. Copy the :root block as-is into every app. */
:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bg: #fafafa;        /* form panel */
  --fg: #333;
  --dim: #888;
  --line: #ddd;
  --accent: #3d4fb0;    /* buttons, links */
  --accent-hi: #34449a;
  --side: #353b72;      /* right panel */
  --ok: #2e7d4f; --err: #c62828;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--fg); font: 14px/1.5 var(--font); background: var(--bg); }
[hidden] { display: none !important; }
ul { list-style: none; margin: 0; padding: 0; }

/* layout: list left, note right (same as chat) */
.app { display: flex; height: 100vh; height: 100dvh; }
.nav { width: 280px; flex: none; display: flex; flex-direction: column; padding: 24px 16px;
       background: var(--bg); border-right: 1px solid var(--line); overflow-y: auto; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }

.head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; padding: 0 8px; }
.mark { font-size: 22px; font-weight: 700; }
.status { color: var(--dim); font-size: 12px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; background: #bbb; }
.dot.on { background: var(--ok); }

input, textarea {
  width: 100%; padding: 7px 8px; font: inherit; color: var(--fg);
  background: #fff; border: 1px solid var(--line); border-radius: 3px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; margin: 12px 0 4px; font-size: 12px; }
.hint { margin: 4px 0 0; color: var(--dim); font-size: 12px; }

.link { font: inherit; color: var(--accent); background: none; border: 0; padding: 0; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.danger { color: var(--err); }
button.primary, button.ghost { padding: 7px 16px; font: inherit; border-radius: 3px; cursor: pointer; }
button.primary { background: var(--accent); color: #fff; border: 1px solid var(--accent); }
button.primary:hover { background: var(--accent-hi); }
button.primary.danger { background: var(--err); border-color: var(--err); }
button.primary.danger:hover { background: #a82020; }
button.ghost { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.new { display: flex; gap: 8px; margin-bottom: 12px; }
.new button { flex: 1; padding-left: 8px; padding-right: 8px; }

/* sidebar lists */
.sec { margin: 24px 0 4px; padding: 0 8px; color: var(--dim); font-size: 12px; }
.item { display: block; width: 100%; padding: 6px 8px; font: inherit; color: var(--fg); text-align: left;
        background: none; border: 0; border-radius: 3px; cursor: pointer; }
.item:hover { background: #eee; }
.item.active { background: var(--accent); color: #fff; }
.item .name, .item .sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { color: var(--dim); font-size: 12px; }
.item.active .sub { color: #dde; }
.empty { padding: 4px 8px; color: var(--dim); font-size: 12px; }

.foot { margin-top: auto; padding: 32px 8px 0; display: flex; justify-content: space-between; color: var(--dim); font-size: 12px; }

/* the open note */
.bar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--line); }
.bar .grow { flex: 1; min-width: 0; }
.bar .title { padding: 2px 0; font-size: 22px; font-weight: 400; border: 0; border-radius: 0; }
.info { padding: 4px 24px 0; color: var(--dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info:empty { display: none; }
.saved { color: var(--dim); font-size: 12px; white-space: nowrap; }
.saved.bad { color: var(--err); }
.back { display: none; }
.note { margin: 0; padding: 4px 24px 0; color: var(--err); font-size: 12px; }
.blank { margin: 48px 24px; color: var(--dim); }
.grow { flex: 1; }

/* text note */
.text-note { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 8px 24px 24px; }
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.tool, .seg button { padding: 2px 8px; font: inherit; font-size: 13px; color: var(--fg); background: #fff;
                     border: 1px solid var(--line); border-radius: 3px; cursor: pointer; }
.tool:hover, .seg button:hover { border-color: var(--accent); color: var(--accent); }
.tool.b { font-weight: 700; }
.tool.i { font-style: italic; }
.seg { display: flex; }
.seg button { border-radius: 0; }
.seg button:first-child { border-radius: 3px 0 0 3px; }
.seg button:last-child { border-radius: 0 3px 3px 0; margin-left: -1px; }
.seg button[aria-pressed="true"] { color: #fff; background: var(--accent); border-color: var(--accent); }
.text-note textarea { flex: 1; margin-top: 8px; padding: 4px 0; resize: none; border: 0; border-radius: 0; line-height: 1.6;
                      font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.md { flex: 1; overflow-y: auto; padding: 8px 0; line-height: 1.6; overflow-wrap: anywhere; }
.md h1, .md h2, .md h3 { margin: 16px 0 8px; font-weight: 400; }
.md h1 { font-size: 28px; } .md h2 { font-size: 22px; } .md h3 { font-size: 18px; }
.md p, .md ul, .md ol, .md table, .md pre, .md blockquote { margin: 0 0 12px; }
.md ul, .md ol { padding-left: 24px; }
.md li:has(> input[type="checkbox"]) { list-style: none; margin-left: -20px; }
.md img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 3px; }
.md table { border-collapse: collapse; display: block; max-width: 100%; overflow-x: auto; }
.md th, .md td { padding: 4px 12px; border: 1px solid var(--line); text-align: left; }
.md th { background: var(--bg); font-weight: 600; }
.md code { padding: 0 4px; font-size: 13px; background: var(--bg); border-radius: 3px; }
.md pre { padding: 8px 12px; overflow-x: auto; background: var(--bg); border-radius: 3px; }
.md pre code { padding: 0; }
.md blockquote { padding-left: 12px; color: var(--dim); border-left: 3px solid var(--line); }
.md a { color: var(--accent); }
.md hr { border: 0; border-top: 1px solid var(--line); }

/* diagram */
.canvas { position: relative; flex: 1; min-height: 0; border-top: 1px solid var(--line); margin-top: 8px; }
.canvas .loading { margin: 48px 24px; color: var(--dim); }
/* Excalidraw layout: shape toolbar at the bottom centre, properties panel on the right (below Library).
   Both are positioned inside Excalidraw's top container, which spans the whole canvas and ignores clicks. */
.canvas .excalidraw .shapes-section { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); }
.canvas .excalidraw .shapes-section .HintViewer { top: auto; bottom: calc(100% + 4px); }
.canvas .excalidraw .App-menu__left { left: auto; right: 0; }
.canvas .excalidraw .App-menu_top .layer-ui__wrapper__top-right { grid-column: 3; }  /* Library stays top right */
/* narrower canvas: lift the toolbar above the zoom / undo buttons so they never overlap */
@media (max-width: 1180px) {
  .canvas .excalidraw .shapes-section { bottom: 44px; }
  /* stay clear of the raised toolbar (Excalidraw sets an inline max-height, hence !important); the panel scrolls */
  .canvas .excalidraw .App-menu__left { max-height: calc(100% - 196px) !important; }
}

/* dialogs */
dialog { width: min(420px, calc(100% - 32px)); padding: 24px; color: var(--fg); background: #fff;
         border: 1px solid var(--line); border-radius: 3px; }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog h2 { margin: 0 0 4px; font-size: 22px; font-weight: 400; }
.picks { max-height: 240px; margin-top: 12px; overflow-y: auto; border: 1px solid var(--line); border-radius: 3px; }
.pick { display: flex; align-items: center; gap: 8px; padding: 6px 8px; }
.pick + .pick { border-top: 1px solid var(--line); }
.pick .name { flex: 1; }
.pick .dim { color: var(--dim); font-size: 12px; }
.av { width: 24px; height: 24px; flex: none; display: grid; place-items: center; font-size: 11px;
      color: #fff; background: var(--side); border-radius: 4px; text-transform: uppercase; }
.row { display: flex; gap: 8px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.err { margin: 8px 0 0; color: var(--err); font-size: 13px; }

/* under 720px: one pane at a time */
@media (max-width: 720px) {
  .nav { width: 100%; border-right: 0; }
  .app.in-note .nav { display: none; }
  .app:not(.in-note) .main { display: none; }
  .back { display: inline; }
  .bar, .note, .info, .text-note { padding-left: 16px; padding-right: 16px; }
  .bar { gap: 8px; flex-wrap: wrap; }
  .bar .grow { flex-basis: 100%; order: 2; }
  .bar .title { font-size: 18px; }
}
