@font-face {
  font-family: "Archivo";
  src: url("/static/fonts/Archivo-Variable.woff2") format("woff2");
  font-weight: 100 900; font-display: swap;
}

:root {
  --ground: #ECECEF;         /* workspace around the sheet */
  --panel: #FAFAFB;
  --panel-2: #F2F2F4;
  --line: #E0E0E5;
  --ink: #1D1D20;
  --muted: #74747C;
  --press: #E6E6EA;
  --accent: #E8590C;         /* the one accent: everything you are drawing or have selected */
  --accent-soft: rgba(232, 89, 12, .12);
  --sticky: #F2C94C; --sticky-edge: #C99A00;
  --ok: #2F8F5B;
  --shadow: 0 1px 2px rgba(20, 20, 30, .06), 0 8px 24px rgba(20, 20, 30, .08);
  --r: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #151517; --panel: #1E1E21; --panel-2: #26262A; --line: #313136;
    --ink: #ECECF0; --muted: #9A9AA3; --press: #2E2E33;
    --accent: #FF7A33; --accent-soft: rgba(255, 122, 51, .16);
    --ok: #4CC487;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font: 13px/1.35 "Archivo", ui-sans-serif, sans-serif; color: var(--ink); background: var(--ground);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }
svg { display: block; }
body.ro .edit-only, body.client .edit-only { display: none !important; }

/* ---------- controls ---------- */
.btn {
  height: 32px; padding: 0 14px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--panel); display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  font-weight: 560; white-space: nowrap; transition: background .12s, border-color .12s, transform .12s;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 22%, var(--line)); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--ink); color: var(--panel); border-color: var(--ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--accent)); }
.btn.danger { color: #C6362D; }
.btn.wide { width: 100%; height: 40px; }
.linkish { border: 0; background: none; padding: 0; cursor: pointer; color: var(--accent); font-weight: 600; }
.quiet-danger { color: var(--muted); font-weight: 500; margin-top: 28px; }
.quiet-danger:hover { color: #C6362D; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r); border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; transition: background .12s, transform .12s; flex: none;
}
.icon-btn:hover { background: var(--press); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn svg, .tools svg, .ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.tools svg .fill { fill: currentColor; stroke: none; }

.seg { display: inline-flex; background: var(--panel-2); border-radius: var(--r); padding: 2px; gap: 2px; }
.seg button, .tog {
  height: 26px; padding: 0 9px; border: 0; border-radius: 6px; background: transparent; cursor: pointer;
  color: var(--muted); font-weight: 560; font-size: 12px; white-space: nowrap; transition: background .12s, color .12s;
}
.seg button:hover, .tog:hover { color: var(--ink); }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.tog { background: var(--panel-2); height: 30px; }
.tog.on { background: var(--accent-soft); color: var(--accent); }
select {
  height: 30px; border-radius: var(--r); border: 0; background: var(--panel-2); padding: 0 8px; cursor: pointer;
  font-weight: 560; font-size: 12px;
}
input[type=text], input[type=search], input[type=email], input[type=password], textarea {
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--r); padding: 7px 10px; outline: none;
  transition: border-color .12s, box-shadow .12s; min-width: 0;
}
input:focus, textarea:focus, select:focus-visible, button:focus-visible {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none;
}
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 12px; font-weight: 560; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.k { font-size: 11px; font-weight: 600; color: var(--muted); }

/* ---------- library ---------- */
.screen { position: fixed; inset: 0; }
#library { display: grid; grid-template-columns: 248px 1fr; background: var(--ground); }
.lib-side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 18px 12px 12px; gap: 12px; min-height: 0; }
.brand { font-size: 15px; font-weight: 720; letter-spacing: -.01em; padding: 0 8px; }
.lib-side input[type=search] { width: 100%; }
.proj-list { display: flex; flex-direction: column; gap: 1px; overflow: auto; min-height: 0; flex: 1; }
.proj {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 34px; padding: 0 9px; border: 0; border-radius: var(--r);
  background: transparent; cursor: pointer; text-align: left; color: var(--ink); transition: background .12s, color .12s;
}
.proj:hover { background: var(--press); }
.proj.on { background: var(--accent-soft); color: var(--accent); }
.proj .ico { width: 18px; height: 18px; flex: none; }
.proj .pname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 560; }
.proj .pcount { color: var(--muted); font-size: 12px; }
.proj.on .pcount { color: inherit; }
.proj.add { color: var(--muted); }
.proj.add:hover { color: var(--ink); }
.plus { font-size: 18px; line-height: 1; width: 18px; text-align: center; font-weight: 400; }
.proj-input { margin: 2px 0; width: 100%; }
.side-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.me { display: flex; align-items: center; justify-content: space-between; padding: 4px 9px; font-weight: 560; }
.me .linkish { color: var(--muted); font-weight: 500; font-size: 12px; }
.me .linkish:hover { color: var(--ink); }

.lib-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.lib-head { display: flex; align-items: center; gap: 12px; padding: 22px 32px 14px; }
.lib-title h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; margin: 0; cursor: default; }
.title-input { font-size: 20px; font-weight: 700; width: min(480px, 60vw); }
.lib-actions { display: flex; gap: 8px; }
.lib-body { flex: 1; overflow: auto; padding: 4px 32px 40px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(236px, 1fr)); gap: 18px; }
.card {
  background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column;
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s;
}
.card:hover { transform: scale(1.012); box-shadow: 0 1px 2px rgba(20,20,30,.08), 0 14px 32px rgba(20,20,30,.12); }
.thumb { border: 0; padding: 0; margin: 0; background: #fff; cursor: pointer; aspect-ratio: 3 / 2; display: block; width: 100%; border-bottom: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-foot { display: flex; align-items: center; gap: 6px; padding: 10px 8px 11px 12px; min-height: 58px; }
.card-foot > input { width: 100%; }
.card-text { flex: 1; min-width: 0; }
.card-name { font-weight: 640; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 8px; margin-top: 2px; }
.open-notes { color: #9A6B00; font-weight: 600; }
@media (prefers-color-scheme: dark) { .open-notes { color: var(--sticky); } }
.shared { color: var(--ok); font-weight: 600; font-size: 12px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; width: 100%; }
.card-actions .btn { height: 28px; padding: 0 10px; font-size: 12px; }
.card-actions select { height: 28px; max-width: 110px; }
.card-actions .icon-btn { margin-left: auto; width: 28px; height: 28px; color: var(--muted); }
.more { color: var(--muted); font-size: 18px; }
.plus-tile {
  border: 1.5px dashed transparent; background: transparent; box-shadow: none; cursor: pointer; color: var(--muted);
  align-items: center; justify-content: center; gap: 8px; min-height: 216px; font-weight: 600;
  outline: 1.5px solid var(--line); outline-offset: -1.5px;
}
.plus-tile:hover { color: var(--ink); outline-color: color-mix(in srgb, var(--ink) 30%, var(--line)); transform: scale(1.012); box-shadow: none; }
.plus-tile .plus { font-size: 30px; width: auto; }
.new-form { padding: 14px; gap: 10px; min-height: 216px; justify-content: center; }
.new-form .seg { width: 100%; flex-wrap: wrap; }
.new-form .seg button { flex: 1; }
.composer-row { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.drop-hint { margin-top: 26px; text-align: center; font-weight: 500; }
.danger-row { margin-top: 28px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-weight: 560; }
.lib-drop {
  position: fixed; inset: 14px; border-radius: 14px; border: 2px solid var(--accent); background: var(--accent-soft);
  display: grid; place-items: center; font-size: 18px; font-weight: 600; color: var(--accent); pointer-events: none;
}

/* people */
.people-me { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.people-me input { width: 220px; }
.people { display: flex; flex-direction: column; gap: 10px; max-width: 900px; }
.person { background: var(--panel); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.person-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.person-line .btn { height: 28px; font-size: 12px; padding: 0 10px; }
.status { font-size: 12px; font-weight: 600; color: var(--muted); }
.status.s-active { color: var(--ok); }
.status.s-invited { color: #9A6B00; }
.access { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 26px; padding: 0 10px; border-radius: 6px; border: 1px solid var(--line); background: transparent; cursor: pointer;
  font-size: 12px; font-weight: 560; color: var(--muted); transition: background .12s, color .12s, border-color .12s;
}
.chip:hover { color: var(--ink); }
.chip.on { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.invite { display: flex; gap: 8px; }
.invite input { flex: 1; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.add-person { margin-top: 22px; display: flex; flex-direction: column; gap: 8px; max-width: 900px; }
.add-row { display: flex; gap: 8px; }
.add-row input { flex: 1; }

/* ---------- editor layout ---------- */
#editor {
  display: grid; grid-template-columns: 52px 1fr 300px; grid-template-rows: 52px 1fr 30px;
  grid-template-areas: "top top top" "tools stage side" "status status status";
}
.top {
  grid-area: top; display: flex; align-items: center; gap: 14px; padding: 0 12px; background: var(--panel);
  border-bottom: 1px solid var(--line); min-width: 0;
}
.top .group { display: flex; align-items: center; gap: 6px; }
.top .lbl { font-size: 11px; color: var(--muted); font-weight: 560; }
.doc-name { display: flex; flex-direction: column; min-width: 0; max-width: 300px; line-height: 1.2; }
.doc-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#doc-name { font-weight: 640; }
#doc-folder { font-size: 11px; }
@media (max-width: 1280px) { .top .lbl { display: none; } }

.tools {
  grid-area: tools; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  align-items: center; padding: 8px 0; gap: 2px; overflow: hidden;
}
.tools button {
  width: 40px; height: 38px; border-radius: var(--r); border: 0; background: transparent; cursor: pointer; position: relative; flex: none;
  display: grid; place-items: center; color: var(--ink); transition: background .12s, color .12s, transform .12s;
}
.tools button:hover { background: var(--press); }
.tools button:active { transform: scale(.94); }
.tools button.on { background: var(--accent-soft); color: var(--accent); }
.tools kbd { position: absolute; right: 3px; bottom: 2px; font: 600 8px/1 "Archivo"; color: var(--muted); }
.tools button.on kbd { color: var(--accent); }
.tools hr { width: 24px; border: 0; border-top: 1px solid var(--line); margin: 4px 0; flex: none; }

.stage { grid-area: stage; position: relative; overflow: hidden; background: var(--ground); }
#sheet, #canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#sheet { pointer-events: none; }
#canvas { touch-action: none; user-select: none; -webkit-user-select: none; }
.stage.t-pan #canvas, .stage.panning #canvas { cursor: grab; }
.stage.panning.dragging #canvas, .stage.t-pan.dragging #canvas { cursor: grabbing; }
.stage.t-draw #canvas { cursor: crosshair; }
.stage.t-select #canvas { cursor: default; }
.stage.t-text #canvas { cursor: text; }
.pin { cursor: pointer; }
.pin-body { fill: var(--sticky); stroke: var(--sticky-edge); stroke-width: 1.2; transition: transform .15s; }
.pin.on .pin-body { stroke: var(--accent); stroke-width: 2; }
.pin-label { font: 700 11px "Archivo"; fill: #3A2E00; pointer-events: none; }

/* ---------- right panel ---------- */
.side { grid-area: side; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-tabs { margin: 10px 12px 0; display: flex; }
.side-tabs button { flex: 1; }
.count { display: inline-block; min-width: 16px; padding: 0 4px; border-radius: 8px; background: var(--sticky); color: #3A2E00; font-size: 10px; line-height: 15px; text-align: center; margin-left: 3px; }
.count:empty { display: none; }
.side-body { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 14px; }
.side-body h2 { margin: 0; font-size: 14px; font-weight: 680; }
.side-body p { margin: 0; }
.inspector .row { display: flex; flex-direction: column; gap: 6px; }
.inspector .row > .k { font-size: 11px; font-weight: 600; color: var(--muted); }
.inspector .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.inspector input[type=text] { width: 100%; }
.inspector textarea { resize: none; min-height: 62px; font: 13px/1.35 Arial, sans-serif; }
.inspector textarea.one-line { min-height: 36px; }
.inspector .value { font: 600 22px/1.1 "Archivo"; letter-spacing: -.01em; }
.inspector .value small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 6px; }
.inspector .views { display: flex; flex-direction: column; gap: 6px; }
.inspector .views .v { display: grid; grid-template-columns: 1fr 150px; gap: 8px; align-items: center; font-size: 12px; }
.inspector .seg { width: 100%; flex-wrap: wrap; }
.inspector .seg button { flex: 1; }
.foot { margin-top: auto; display: flex; gap: 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.seg.small button { height: 22px; font-size: 11px; padding: 0 8px; }

.notes-list, .versions { display: flex; flex-direction: column; gap: 8px; }
.note { border-radius: 10px; padding: 10px 12px; background: var(--panel-2); cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: background .12s, box-shadow .12s; }
.note:hover { background: color-mix(in srgb, var(--panel-2) 70%, var(--press)); }
.note.on { background: var(--panel); box-shadow: 0 0 0 1.5px var(--accent) inset; cursor: default; }
.new-note { background: var(--panel); box-shadow: 0 0 0 1.5px var(--sticky-edge) inset; cursor: default; }
.note-meta { display: flex; align-items: center; gap: 7px; font-size: 12px; flex-wrap: wrap; }
.pin-num { min-width: 18px; height: 18px; border-radius: 4px; background: var(--sticky); color: #3A2E00; font: 700 10px/18px "Archivo"; text-align: center; padding: 0 4px; }
.pin-dot { width: 12px; height: 12px; border-radius: 3px; background: var(--sticky); }
.note-text { white-space: pre-wrap; word-break: break-word; line-height: 1.4; }
.reply { border-left: 2px solid var(--line); padding-left: 10px; display: flex; flex-direction: column; gap: 4px; }
.composer { display: flex; flex-direction: column; gap: 6px; }
.composer textarea { resize: vertical; min-height: 64px; width: 100%; }
.note-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.note-actions .btn { height: 28px; font-size: 12px; padding: 0 10px; }
.empty-tile {
  border: 0; outline: 1.5px solid var(--line); outline-offset: -1.5px; background: transparent; border-radius: 10px; padding: 22px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; transition: color .12s, outline-color .12s;
}
.empty-tile:hover { color: var(--ink); outline-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
.empty-tile .plus { font-size: 26px; width: auto; }
.save-version { display: flex; flex-direction: column; gap: 8px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.save-version input[type=text] { width: 100%; }
.version { border-radius: 10px; padding: 9px 11px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; transition: background .12s; }
.version:hover { background: var(--panel-2); }
.version.on { background: var(--panel-2); }
.version.quiet b { font-weight: 560; color: var(--muted); }
.v-line { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.v-line .muted { font-size: 12px; }
.version .note-actions { margin-top: 6px; }

.status {
  grid-area: status; display: flex; align-items: center; gap: 18px; padding: 0 14px; background: var(--panel);
  border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); white-space: nowrap;
}
.status .live { color: var(--ink); font-weight: 560; }

/* ---------- on-canvas helpers ---------- */
.hud {
  position: absolute; pointer-events: none; padding: 4px 7px; border-radius: 5px; background: var(--ink); color: var(--panel);
  font: 600 12px/1.2 "Archivo"; white-space: nowrap; box-shadow: var(--shadow); transform: translate(14px, 14px);
}
.hud .k { opacity: .65; font-weight: 500; margin-left: 6px; color: inherit; font-size: 12px; }
.inplace {
  position: absolute; border: 0; outline: 1px solid var(--accent); background: rgba(255,255,255,.92); color: #000;
  font-family: Arial, sans-serif; resize: none; overflow: hidden; padding: 0; line-height: 1.2; white-space: pre;
  border-radius: 0; box-shadow: none; transform-origin: 0 0;
}
.toast {
  position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%); background: var(--ink); color: var(--panel);
  padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center;
  font-weight: 560; z-index: 10; max-width: calc(100vw - 32px);
}
.toast a, .toast .linkish { color: var(--accent); text-decoration: none; font-weight: 640; }
.toast.err { background: #B3261E; color: #fff; }

/* ---------- sign in ---------- */
.login-page { display: grid; place-items: center; overflow: auto; }
.login { width: min(360px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 18px; padding: 24px 0; }
.login-mark { width: 40px; height: 40px; fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.login h1 { margin: 0; font-size: 24px; font-weight: 720; letter-spacing: -.01em; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.login input { height: 40px; font-size: 14px; color: var(--ink); }
.err { color: #C6362D; font-weight: 560; min-height: 18px; margin: 0; }

@media (max-width: 900px) {
  #library { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .lib-side { border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .lib-head { padding: 16px 16px 10px; flex-wrap: wrap; }
  .lib-body { padding: 4px 16px 32px; }
  .add-row { flex-direction: column; }
}

.signin-box { display: flex; flex-direction: column; gap: 10px; max-width: 900px; margin-bottom: 26px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.signin-box h2 { margin: 0; font-size: 14px; font-weight: 680; }
.ok-line { margin: 0; color: var(--ok); font-weight: 600; }
.twostep { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.secret { font: 600 15px/1.4 ui-monospace, Menlo, monospace; letter-spacing: .04em; background: var(--panel-2); padding: 8px 12px; border-radius: var(--r); user-select: all; }
.aud { font-size: 11px; font-weight: 600; color: var(--muted); }
.aud.shared { color: var(--ok); }
