:root {
  --bg: #f4f2ee;
  --dot: #d9d5cd;
  --surface: #ffffff;
  --surface-2: #f7f6f3;
  --text: #1c1b19;
  --muted: #6f6b64;
  --line: #e4e0d8;
  --accent: #ff5a36;
  --accent-text: #ffffff;
  --arrow: #8d877d;
  --shadow: 0 1px 2px rgba(20, 16, 10, .06), 0 4px 14px rgba(20, 16, 10, .07);
  --shadow-lift: 0 10px 30px rgba(20, 16, 10, .18);
  --danger: #c8321e;
  --ok: #1f9d55;
  --radius: 12px;

  /* note / board colors: soft background + strong accent */
  --c-yellow: #fff3b0;  --a-yellow: #f2c200;
  --c-orange: #ffe0c4;  --a-orange: #ff8a3d;
  --c-red: #ffd6d1;     --a-red: #ef4444;
  --c-pink: #ffd8ec;    --a-pink: #e84393;
  --c-purple: #e7dcff;  --a-purple: #8b5cf6;
  --c-blue: #d7e7ff;    --a-blue: #3a86ff;
  --c-green: #d3f3dd;   --a-green: #22a861;
  --c-gray: #e8e5df;    --a-gray: #8a857c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --dot: #2a2926;
    --surface: #1f1e1b;
    --surface-2: #272622;
    --text: #efece6;
    --muted: #9a958c;
    --line: #34322d;
    --accent: #ff6a48;
    --arrow: #7d786f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3);
    --shadow-lift: 0 12px 34px rgba(0, 0, 0, .55);
    --danger: #ff6b57;
    --ok: #3ccf7a;
    --c-yellow: #48401c; --c-orange: #4a321d; --c-red: #4a2522; --c-pink: #47233a;
    --c-purple: #352a52; --c-blue: #1f3450; --c-green: #1c3d2c; --c-gray: #33312c;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
kbd {
  font: 12px ui-monospace, Consolas, monospace;
  padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--surface);
}

/* ---------- top bar ---------- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 46vw; }
.logo {
  flex: none; width: 18px; height: 18px; border-radius: 5px;
  background: conic-gradient(from 45deg, #ff5a36 0 25%, #ffb020 0 50%, #8338ec 0 75%, #3a86ff 0);
}
.crumbs { display: flex; align-items: center; gap: 2px; min-width: 0; overflow: hidden; white-space: nowrap; }
.crumbs a {
  font-weight: 700; letter-spacing: -.01em; color: var(--muted); text-decoration: none; padding: 3px 6px; border-radius: 6px;
  overflow: hidden; text-overflow: ellipsis; max-width: 200px;
}
.crumbs a:hover { background: var(--surface); color: var(--text); }
.crumbs a.here { color: var(--text); }
.crumbs a.drop-target { background: var(--accent); color: var(--accent-text); }
.crumbs .sep { color: var(--muted); opacity: .6; }
.live { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.on { background: var(--ok); }
.live.on.syncing { background: var(--a-blue); }
.live.on.offline { background: var(--a-yellow); }
.live.on.error { background: var(--danger); }

/* ---------- account ---------- */
.account-wrap { position: relative; }
.account {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer;
  background: var(--surface); color: var(--text); font-weight: 700; text-transform: uppercase;
}
.account:hover, .account[aria-expanded=true] { border-color: var(--accent); }
.account-menu {
  position: absolute; right: 0; top: 42px; z-index: 50; min-width: 240px; padding: 6px;
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lift);
}
.account-menu[hidden] { display: none; }
.am-who { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
#amEmail { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.am-sync { color: var(--muted); font-size: 12px; }
.account-menu button, .account-menu a {
  text-align: left; padding: 8px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text);
  cursor: pointer; text-decoration: none; font: inherit;
}
.account-menu button:hover, .account-menu a:hover { background: var(--surface-2); }

/* ---------- sign-in ---------- */
.signin {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle, var(--dot) 1px, transparent 1.2px) 0 0 / 22px 22px, var(--bg);
}
.signin[hidden] { display: none; }
.signin-card {
  width: min(400px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 28px 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lift);
}
.signin-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.signin-card h1 { margin: 8px 0 0; font-size: 22px; letter-spacing: -.02em; }
.signin-sub { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.signin-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.signin-card input {
  height: 40px; padding: 0 12px; font: inherit; font-weight: 400;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; outline: none; color: var(--text);
}
.signin-card input:focus { border-color: var(--accent); }
.signin-msg { margin: 0; padding: 8px 10px; border-radius: 9px; font-size: 13px; background: color-mix(in srgb, var(--danger) 12%, var(--surface)); color: var(--danger); }
.signin-msg.good { background: color-mix(in srgb, var(--ok) 12%, var(--surface)); color: var(--ok); }
.signin-msg[hidden] { display: none; }
.signin-go {
  height: 42px; border: 0; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 700;
  background: var(--accent); color: var(--accent-text);
}
.signin-go:disabled { opacity: .6; cursor: progress; }
.signin-alt { margin: 0; display: flex; justify-content: center; gap: 8px; color: var(--muted); font-size: 13px; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font: inherit; }
.add { flex: 1 1 220px; min-width: 180px; }
.add input, .tools input {
  width: 100%; height: 34px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; outline: none;
}
.add input:focus, .tools input:focus { border-color: var(--accent); }
.tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tools input[type=search] { width: 170px; }
.seg, .zoom { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button, .zoom button {
  height: 32px; padding: 0 10px; border: 0; background: transparent; cursor: pointer; color: var(--muted);
}
.seg button.on { background: var(--text); color: var(--bg); }
.zoom button:hover, .seg button:not(.on):hover { color: var(--text); background: var(--surface-2); }
#zoomLabel { min-width: 52px; font-variant-numeric: tabular-nums; }
.count { color: var(--muted); font-size: 12px; white-space: nowrap; }
.arrange {
  height: 34px; padding: 0 10px; border-radius: 9px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--text); outline: none;
}
.arrange:focus { border-color: var(--accent); }

/* ---------- left tool rail ---------- */
.rail {
  position: fixed; z-index: 15; left: 12px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.tool {
  width: 58px; padding: 7px 0 6px; border: 0; border-radius: 9px; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 10.5px; font-weight: 600;
}
.tool:hover { background: var(--surface-2); color: var(--text); }
.tool svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool[draggable=true] { cursor: grab; }
a.tool { text-decoration: none; }
.rail-sep { height: 1px; margin: 4px 8px; background: var(--line); }
@media (max-width: 720px) { .rail-sep { width: 1px; height: auto; margin: 8px 4px; } }

/* ---------- canvas ---------- */
#viewport {
  position: fixed; inset: 0; overflow: hidden; cursor: grab; touch-action: none;
  background-color: var(--bg);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.3px);
  background-size: 24px 24px;
}
#viewport.panning { cursor: grabbing; }
#world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#lines { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
#lines marker path { fill: var(--arrow); }
.ln .vis { fill: none; stroke: var(--arrow); stroke-width: 2; stroke-linecap: round; }
.ln .hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.ln.sel .vis, .ln:hover .vis { stroke: var(--accent); }
.ln.temp .vis { stroke: var(--accent); stroke-dasharray: 6 5; }

.card {
  --w: 240px;
  position: absolute; left: 0; top: 0; width: var(--w);
  background: var(--card-bg, var(--surface)); border-radius: var(--radius); box-shadow: var(--shadow);
  cursor: pointer; user-select: none;
  transition: box-shadow .15s, opacity .2s, outline-color .15s;
  outline: 2px solid transparent; outline-offset: 2px;
}
.card > .clip { border-radius: inherit; overflow: hidden; }
.card:hover { box-shadow: var(--shadow-lift); }
.card.dragging { box-shadow: var(--shadow-lift); cursor: grabbing; transition: none; pointer-events: none; opacity: .92; }
.card.selected { outline-color: var(--accent); }
.card.dim { opacity: .14; }
.card.drop-target { outline: 3px solid var(--accent); outline-offset: 4px; }
.card.c-yellow { --card-bg: var(--c-yellow); } .card.c-orange { --card-bg: var(--c-orange); }
.card.c-red { --card-bg: var(--c-red); }       .card.c-pink { --card-bg: var(--c-pink); }
.card.c-purple { --card-bg: var(--c-purple); } .card.c-blue { --card-bg: var(--c-blue); }
.card.c-green { --card-bg: var(--c-green); }   .card.c-gray { --card-bg: var(--c-gray); }

.card .media { position: relative; background: var(--surface-2); }
.card .media img, .card .media video { display: block; width: 100%; max-height: calc(var(--w) * 1.6); object-fit: cover; pointer-events: none; }
.card.t-image .media img { max-height: none; }
.card .noimg {
  height: 92px; display: grid; place-items: center;
  font-size: 32px; font-weight: 700; color: var(--muted); letter-spacing: -.02em;
}
.badge {
  position: absolute; left: 8px; top: 8px; padding: 2px 7px; border-radius: 6px;
  background: rgba(0, 0, 0, .62); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .03em;
}
.card .body { padding: 10px 12px 12px; }
.card .site { font-size: 11px; color: var(--muted); text-transform: lowercase; display: flex; gap: 6px; }
.card .title { font-weight: 600; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .caption { padding: 7px 10px 8px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .note {
  margin-top: 8px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2);
  font-size: 13px; color: var(--text); white-space: pre-wrap;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.card .tags { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); color: var(--muted); }
.card .ai-dot { color: var(--accent); }

/* notes */
.note-body { padding: 14px 16px; min-height: 52px; cursor: inherit; outline: none; overflow-wrap: anywhere; user-select: text; }
.note-body[contenteditable=true] { cursor: text; }
.note-body:empty::before { content: 'Type something…'; color: var(--muted); }
.note-body > :first-child { margin-top: 0; } .note-body > :last-child { margin-bottom: 0; }
.note-body h1, .note-body h2, .note-body h3 { font-size: 1.25em; line-height: 1.25; margin: .6em 0 .3em; letter-spacing: -.01em; }
.note-body ul, .note-body ol { margin: .3em 0; padding-left: 1.3em; }
.note-body blockquote { margin: .4em 0; padding-left: 10px; border-left: 3px solid var(--accent); color: var(--muted); }
.note-body a { color: var(--accent); }
.card.t-note .tags, .card.t-todo .tags { padding: 0 16px 12px; margin: 0; }

/* headings */
.card.t-heading { background: transparent; box-shadow: none; }
.card.t-heading:hover { box-shadow: none; background: color-mix(in srgb, var(--surface) 40%, transparent); }
.heading-text {
  padding: 4px 6px; font-weight: 800; letter-spacing: -.025em; line-height: 1.1; outline: none; overflow-wrap: anywhere;
  font-size: clamp(16px, calc(var(--w) * .075), 120px);
}
.heading-text[contenteditable=true] { cursor: text; user-select: text; }

/* to-dos */
.todo-title { padding: 12px 16px 4px; font-weight: 700; outline: none; }
.todos { padding: 2px 10px 10px; }
.todo-row { display: flex; align-items: flex-start; gap: 8px; padding: 3px 6px; border-radius: 6px; }
.todo-row input { margin: 3px 0 0; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex: none; }
.todo-text { flex: 1; outline: none; min-height: 1.45em; overflow-wrap: anywhere; }
.todo-row.done .todo-text { text-decoration: line-through; color: var(--muted); }
.todo-text:empty::before { content: 'To-do'; color: var(--muted); opacity: .6; }
.card.editing .todo-title, .card.editing .todo-text { cursor: text; user-select: text; }
.todo-progress { margin: 0 16px 12px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; }
.todo-progress i { display: block; height: 100%; background: var(--ok); }

/* boards */
.card.t-board { background: transparent; box-shadow: none; text-align: center; }
.card.t-board:hover { box-shadow: none; }
.b-icon {
  aspect-ratio: 1 / .82; border-radius: 16px; padding: 10%; box-shadow: var(--shadow);
  background: var(--accent-c, var(--a-blue));
  display: grid; grid-template-columns: 1fr 1fr; gap: 6%;
}
.card.t-board:hover .b-icon { box-shadow: var(--shadow-lift); }
.b-icon.has-icon { display: grid; grid-template-columns: 1fr; place-items: center; padding: 0; }
.b-emoji { font-size: calc(var(--w) * .42); line-height: 1; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .18)); }
.b-icon .ph { background: rgba(255, 255, 255, .55); border-radius: 6px; }
.b-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; background: rgba(255, 255, 255, .5); }
.b-title { margin-top: 8px; font-weight: 700; outline: none; overflow-wrap: anywhere; }
.b-title[contenteditable=true] { cursor: text; user-select: text; background: var(--surface); border-radius: 6px; }
.b-count { font-size: 12px; color: var(--muted); }
.card.c-default { --accent-c: var(--a-blue); }
.card.t-board.c-yellow, .card.t-board.c-orange, .card.t-board.c-red, .card.t-board.c-pink, .card.t-board.c-purple,
.card.t-board.c-blue, .card.t-board.c-green, .card.t-board.c-gray { --card-bg: transparent; }
.card.c-yellow { --accent-c: var(--a-yellow); } .card.c-orange { --accent-c: var(--a-orange); }
.card.c-red { --accent-c: var(--a-red); }       .card.c-pink { --accent-c: var(--a-pink); }
.card.c-purple { --accent-c: var(--a-purple); } .card.c-blue { --accent-c: var(--a-blue); }
.card.c-green { --accent-c: var(--a-green); }   .card.c-gray { --accent-c: var(--a-gray); }

/* swatches */
.sw { aspect-ratio: 1 / .75; border-radius: var(--radius) var(--radius) 0 0; }
.sw-label { padding: 8px 12px 10px; display: flex; flex-direction: column; }
.sw-label b { font-size: 13px; }
.sw-label span { font: 12px ui-monospace, Consolas, monospace; color: var(--muted); }

/* files */
.file { display: flex; gap: 12px; align-items: center; padding: 14px; }
.file-ext {
  flex: none; width: 44px; height: 52px; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); font-size: 11px; font-weight: 800; color: var(--accent); text-transform: uppercase;
}
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-size { font-size: 12px; color: var(--muted); }
.card audio { display: block; width: calc(100% - 20px); margin: 0 10px 12px; height: 34px; }

/* resize & connect handles */
.rz, .cn { position: absolute; opacity: 0; transition: opacity .12s; }
.card:hover > .rz, .card.selected > .rz, .card:hover > .cn { opacity: 1; }
.rz {
  right: -6px; bottom: -6px; width: 16px; height: 16px; cursor: nwse-resize; border-radius: 4px;
  background: var(--surface); border: 2px solid var(--accent);
}
.cn {
  right: -9px; top: 50%; width: 16px; height: 16px; margin-top: -8px; border-radius: 50%; cursor: crosshair;
  background: var(--accent); border: 3px solid var(--surface); box-shadow: var(--shadow);
}
.card.editing > .cn, .card.editing > .rz { display: none; }
.card.t-board > .cn { top: 40%; }

/* group headings from Arrange › By … */
#labels { position: absolute; left: 0; top: 0; pointer-events: none; }
.group-label {
  position: absolute; white-space: nowrap; font-size: 20px; font-weight: 750; letter-spacing: -.02em;
  max-width: var(--w); overflow: hidden; text-overflow: ellipsis;
}
.group-label span { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; }
#world.animate .card { transition: transform .45s cubic-bezier(.2, .8, .2, 1), box-shadow .15s, opacity .2s; }

.marquee {
  position: fixed; z-index: 5; pointer-events: none;
  border: 1.5px solid var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 4px;
}

/* drag & drop */
.drop-hint {
  position: absolute; inset: 70px 16px 16px 92px; display: grid; place-items: center; pointer-events: none;
  border: 2px dashed var(--accent); border-radius: 18px; color: var(--accent); font-weight: 700; font-size: 18px;
  background: color-mix(in srgb, var(--accent) 6%, transparent);
  opacity: 0; transition: opacity .12s;
}
#viewport.dropping .drop-hint { opacity: 1; }

.empty {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 16px 16px 16px 96px;
  color: var(--muted); pointer-events: none;
}
.empty h2 { color: var(--text); margin: 0 0 8px; font-size: 22px; letter-spacing: -.02em; }
.empty p { margin: 0; line-height: 2; }

/* ---------- floating bars ---------- */
.selbar, .fmtbar {
  position: fixed; z-index: 25; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px; padding: 5px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lift);
  max-width: calc(100vw - 24px); flex-wrap: wrap; justify-content: center;
}
.selbar { bottom: 18px; }
.fmtbar { bottom: 18px; }
.selbar button, .fmtbar button, .selbar select {
  height: 30px; min-width: 30px; padding: 0 9px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; color: var(--text);
}
.selbar button:hover, .fmtbar button:hover { background: var(--surface-2); }
.selbar button.on { background: var(--text); color: var(--bg); }
.selbar select { background: var(--surface-2); max-width: 180px; }
.selbar .danger { color: var(--danger); }
.selbar .count-pill { padding: 0 8px; font-size: 12px; color: var(--muted); }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 3px; }
.dots { display: flex; gap: 3px; padding: 0 3px; }
.dot-btn { width: 20px !important; min-width: 20px !important; height: 20px !important; padding: 0 !important; border-radius: 50% !important; border: 1px solid var(--line) !important; }
.dot-btn.on { outline: 2px solid var(--accent); outline-offset: 1px; }
.selbar input[type=color] { width: 30px; height: 30px; padding: 0; border: 0; background: transparent; cursor: pointer; }

.iconpicker {
  position: fixed; z-index: 26; left: 50%; bottom: 70px; transform: translateX(-50%); width: min(400px, calc(100vw - 24px));
  padding: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lift);
}
.ip-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; }
.ip-grid button { aspect-ratio: 1; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 20px; padding: 0; }
.ip-grid button:hover { background: var(--surface-2); }
.ip-grid button.on { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.ip-row { display: flex; gap: 6px; margin-top: 8px; }
.ip-custom { flex: 1; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); outline: none; }
.ip-custom:focus { border-color: var(--accent); }
.ip-remove { height: 32px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; }
@media (max-width: 720px) { .iconpicker { bottom: 140px; } .ip-grid { grid-template-columns: repeat(8, 1fr); } }

/* ---------- side panel ---------- */
.panel {
  position: fixed; z-index: 30; top: 64px; right: 12px; bottom: 12px; width: min(380px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lift);
  overflow-y: auto; padding: 14px;
}
.panel .close {
  position: sticky; top: 0; float: right; z-index: 2; width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-size: 18px; line-height: 1;
}
.panel .p-media { margin: 0 0 12px; border-radius: 10px; overflow: hidden; background: var(--surface-2); clear: both; }
.panel .p-media img, .panel .p-media video { display: block; width: 100%; max-height: 52vh; object-fit: contain; background: #000; }
.panel .frames { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 12px; }
.panel .frames img { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 6px; }
.panel .p-title {
  width: 100%; border: 1px solid transparent; background: transparent; border-radius: 8px; padding: 4px 6px; margin-left: -6px;
  font-size: 17px; font-weight: 700; letter-spacing: -.01em; resize: none; field-sizing: content; min-height: 1.6em;
}
.panel .p-title:hover, .panel .p-title:focus { border-color: var(--line); outline: none; }
.panel .p-meta { color: var(--muted); font-size: 12px; margin: 2px 0 12px; word-break: break-all; }
.panel .open {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text); font-weight: 600; text-decoration: none;
}
.panel label { display: block; margin: 16px 0 6px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.panel textarea, .panel input.p-tags {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); outline: none;
}
.panel textarea:focus, .panel input.p-tags:focus { border-color: var(--accent); }
.panel textarea.p-note { min-height: 80px; resize: vertical; }
.panel .ai, .panel .desc { white-space: pre-wrap; font-size: 13px; }
.panel .ai { padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 9%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--line)); }
.panel .desc { color: var(--muted); }

.toast {
  position: fixed; z-index: 40; left: 50%; bottom: 70px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px; border-radius: 10px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-lift);
  max-width: calc(100vw - 32px);
}
.toast button { border: 0; background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; padding: 0; }

@media (max-width: 720px) {
  .bar { gap: 8px; }
  .tools input[type=search] { width: 100%; flex: 1 1 100%; }
  .count { display: none; }
  .rail { top: auto; bottom: 12px; left: 50%; transform: translateX(-50%); flex-direction: row; max-width: calc(100vw - 24px); overflow-x: auto; }
  .tool { width: 50px; }
  .selbar, .fmtbar { bottom: 92px; }
  .drop-hint { inset: 140px 16px 90px; }
  .empty { padding: 16px; }
}

/* ---------- sketches (Excalidraw) ---------- */
.card.t-sketch .media { background: #fff; }
.card.t-sketch .media img { max-height: calc(var(--w) * 1.2); object-fit: contain; }
.sketch-empty {
  height: 150px; display: grid; place-content: center; justify-items: center; gap: 4px;
  color: #8d877d; font: 34px/1 Excalifont, Virgil, sans-serif;
}
.sketch-empty span { font-size: 15px; }
.card .shared { color: var(--ok); text-transform: none; font-weight: 600; }
.sketch-overlay { position: fixed; inset: 0; z-index: 200; background: var(--bg); }
.sketch-overlay iframe { display: block; width: 100%; height: 100%; border: 0; }

/* Hand-drawn font for notes, headings and to-dos (Excalidraw's Excalifont). */
.card.f-hand .note-body, .card.f-hand .heading-text, .card.f-hand .todo-title, .card.f-hand .todo-text {
  font-family: Excalifont, Virgil, "Segoe Print", "Comic Sans MS", cursive;
}
.card.f-hand .note-body { font-size: 1.12em; }
.selbar .font-btn { font-family: Excalifont, Virgil, cursive; }

/* ---------- sign-in extras, empty-board links ---------- */
.signin-secondary {
  height: 40px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600;
  background: transparent; color: var(--text); border: 1px solid var(--line);
}
.signin-secondary:hover { border-color: var(--accent); }
.signin-secondary:disabled { opacity: .6; cursor: progress; }
.signin-card [hidden] { display: none !important; }
.empty-links { margin-top: 12px; }
.empty-links a { color: var(--accent); font-weight: 600; text-decoration: none; }
.empty-links a:hover { text-decoration: underline; }

/* ---------- account window ---------- */
.modal {
  position: fixed; inset: 0; z-index: 250; display: grid; place-items: center; padding: 16px;
  background: color-mix(in srgb, #000 45%, transparent);
}
.modal[hidden] { display: none; }
.modal-card {
  position: relative; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lift);
}
.modal-card h2 { margin: 0; font-size: 20px; letter-spacing: -.02em; }
.modal-card h3 { margin: 0 0 8px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.modal-card section { padding: 16px 0; border-top: 1px solid var(--line); }
.modal-card section:first-of-type { margin-top: 12px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 18px; line-height: 1;
}
.ac-email { margin: 4px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.ac-muted { margin: 0; color: var(--muted); font-size: 13px; }
.ac-meter { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; margin-bottom: 6px; }
.ac-meter span { display: block; height: 100%; width: 0; background: var(--ok); }
.ac-meter.full span { background: var(--danger); }
.ac-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; }
.ac-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ac-row input {
  flex: 1 1 200px; height: 36px; padding: 0 10px; font: inherit; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; outline: none;
}
.ac-row input:focus { border-color: var(--accent); }
.ac-btn {
  display: inline-flex; align-items: center; height: 36px; padding: 0 12px; border-radius: 9px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none;
}
.ac-btn:hover { border-color: var(--accent); }
.ac-btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.ac-tokens { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ac-tokens li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ac-tokens small { display: block; color: var(--muted); font-size: 12px; }
.ac-danger h3 { color: var(--danger); }
#acMessage { margin-top: 8px; }
