/*====================================================================
  Master Plan White Board — styles
  A freeform, card-based planning board inspired by SolarLune's MasterPlan.
====================================================================*/

:root {
    --grid: 16px;                 /* world grid size (updated by JS for zoom) */
    --bg: #f3f4f8;
    --grid-dot: #d4d8e4;
    --panel: #ffffff;
    --panel-2: #f7f8fb;
    --text: #2a2d3a;
    --text-soft: #6b7180;
    --border: #e2e5ee;
    --accent: #5564f1;
    --accent-soft: #5564f133;
    --shadow: 0 6px 20px rgba(40, 45, 80, 0.14);
    --toolbar-h: 56px;
}

[data-theme="dark"] {
    --bg: #14161f;
    --grid-dot: #272a37;
    --panel: #1e212d;
    --panel-2: #252937;
    --text: #e7e9f2;
    --text-soft: #9aa0b3;
    --border: #2c3040;
    --accent: #7c87ff;
    --accent-soft: #7c87ff33;
    --shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/*====================================================================
  Scrollbars — thin, no arrows, themed. Applies to every scroll area.
====================================================================*/
* {
    scrollbar-width: thin;                          /* Firefox */
    scrollbar-color: var(--border) transparent;
}
*::-webkit-scrollbar { width: 7px; height: 7px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 7px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-soft); }
*::-webkit-scrollbar-corner { background: transparent; }
/* Kill the up/down (and left/right) stepper arrows. */
*::-webkit-scrollbar-button { display: none; width: 0; height: 0; }

body, html {
    margin: 0;
    height: 100%;
    overflow: hidden;
    font-family: "Roboto", system-ui, sans-serif;
    font-weight: 400;
    color: var(--text);
    background: var(--bg);
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; color: inherit; }

/*====================================================================
  Top toolbar
====================================================================*/
#toolbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    /* Static base height for a single row. Must NOT be var(--toolbar-h): that var
       is set from the toolbar's own offsetHeight, so tying min-height to it ratchets
       the bar taller after it wraps on a small screen and it never shrinks back when
       the window grows again. */
    min-height: 56px;
    z-index: 1000;
    display: flex;
    align-items: center;
    /* Wrap onto extra rows instead of pushing controls off-screen. The canvas
       top follows the toolbar's real height (set from JS via --toolbar-h). */
    flex-wrap: wrap;
    gap: 6px 6px;
    padding: 6px 12px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
}
/* Groups stay intact; they wrap as whole units. */
#toolbar .tool-group, #toolbar .brand { flex: 0 0 auto; }

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.2px;
    padding-right: 10px;
    margin-right: 4px;
    white-space: nowrap;
}
.brand .logo {
    width: 26px; height: 26px;
    border-radius: 7px;
    background: linear-gradient(135deg, #ff5d5d, var(--accent));
}

.tool-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    border-left: 1px solid var(--border);
    height: 34px;
}
.tool-group:first-of-type { border-left: none; }
.spacer { flex: 1; }

.tbtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--panel-2);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s, color .12s, border-color .12s;
}
.tbtn:hover { background: var(--accent); color: #fff; }
.tbtn.active { background: var(--accent-soft); color: var(--accent); }
.tbtn:disabled { opacity: .4; cursor: default; background: var(--panel-2); color: var(--text); }
.tbtn.icon-only { padding: 0; width: 34px; justify-content: center; }
.tbtn .material-symbols-outlined { font-size: 20px; }

/* Instant, project-styled tooltips for toolbar controls (replaces native title). */
#toolbar [data-tip] { position: relative; }
#toolbar [data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    padding: 5px 9px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.1;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;            /* shown instantly on hover — no delay */
}
#toolbar [data-tip]::before {       /* little pointer up toward the button */
    content: '';
    position: absolute;
    top: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    border: 5px solid transparent;
    border-bottom-color: var(--border);
    pointer-events: none;
    opacity: 0;
}
#toolbar [data-tip]:hover::after,
#toolbar [data-tip]:hover::before { opacity: 1; }

#zoomLabel {
    min-width: 52px;
    text-align: center;
    font-size: 13px;
    color: var(--text-soft);
    cursor: pointer;
    user-select: none;
}

/*====================================================================
  Board / viewport / world
====================================================================*/
#viewport {
    position: absolute;
    top: var(--toolbar-h);
    left: 0; right: 0; bottom: 0;
    overflow: hidden;
    background-color: var(--bg);
    background-image: radial-gradient(circle at center, var(--grid-dot) 1.3px, transparent 1.3px);
    background-size: var(--grid) var(--grid);
    cursor: default;
}
#viewport.pan-ready { cursor: grab; }
#viewport.panning { cursor: grabbing; }
#viewport.linking { cursor: crosshair; }
/* While dragging/resizing/panning/linking, stop iframes (PDF, embeds) from
   swallowing the mouse — otherwise the window mousemove stalls over them. */
#viewport.interacting iframe { pointer-events: none; }

#world {
    position: absolute;
    top: 0; left: 0;
    width: 0; height: 0;
    transform-origin: 0 0;
}

/* SVG layer holding connection arrows; sits under the cards */
#links {
    position: absolute;
    top: 0; left: 0;
    overflow: visible;
    pointer-events: none;
    z-index: 0;
}
#links path { pointer-events: stroke; cursor: pointer; }

/*====================================================================
  Selection rubber band
====================================================================*/
#selectionBox {
    position: absolute;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 4px;
    z-index: 5000;
    pointer-events: none;
    display: none;
}

/*====================================================================
  Cards
====================================================================*/
.card {
    position: absolute;
    color: var(--text);
    z-index: 10;
    --card: var(--accent);
}
/* Inner wrapper clips content; the .card itself stays overflow-visible so the
   connect dots & resize handle aren't cut off. */
.card-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 0;
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card.selected { outline: 2px solid var(--card); outline-offset: 2px; border-radius: 0; }
.card.dragging .card-inner { opacity: .92; }
/* (Cards keep their own z-order; raise/lower with the right-click menu. Selecting
   a card still brings it forward. No automatic hover-to-top.) */

.card-header {
    flex: 0 0 auto;
    height: 34px;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 6px;
    background: var(--card);
    color: #fff;
    cursor: grab;
}
.card-header:active { cursor: grabbing; }

.card-type-ico {
    display: inline-flex;
    align-items: center;
    opacity: .9;
}
.card-type-ico .material-symbols-outlined { font-size: 18px; }

.card-title {
    flex: 1;
    min-width: 0;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 34px;
    padding: 0 4px;
    color: #fff;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    outline: none;
    cursor: inherit;          /* part of the drag handle until you rename */
}
/* While renaming, it's an editable field. */
.card-title[contenteditable="true"] {
    cursor: text;
    background: rgba(255, 255, 255, .16);
    border-radius: 5px;
    text-overflow: clip;
}
.card-title:empty::before {
    content: attr(data-placeholder);
    opacity: .6;
}

.hbtn {
    flex: 0 0 auto;
    width: 24px; height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    opacity: .85;
}
.hbtn:hover { background: rgba(255,255,255,.25); opacity: 1; }
.hbtn .material-symbols-outlined { font-size: 18px; }

.card-body {
    flex: 1 1 auto;
    overflow: auto;
    padding: 10px 12px;
    font-size: 13.5px;
    line-height: 1.5;
}

/* Note */
.note-body {
    outline: none;
    cursor: text;
    word-break: break-word;
    white-space: pre-wrap;
}
.note-body:empty::before {
    content: "Write a note…";
    color: var(--text-soft);
}
.note-body img { max-width: 100%; border-radius: 6px; }

/* Checklist */
.check-list { display: flex; flex-direction: column; gap: 4px; }
.check-item { display: flex; flex-direction: column; }
.check-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 2px 0;
}
.check-item .box {
    flex: 0 0 auto;
    width: 18px; height: 18px;
    margin-top: 1px;
    border: 2px solid var(--card);
    border-radius: 5px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}
.check-item.done .box { background: var(--card); }
.check-item .box .material-symbols-outlined { font-size: 14px; display: none; }
.check-item.done .box .material-symbols-outlined { display: block; }
.check-item .txt {
    flex: 1;
    outline: none;
    cursor: text;
    word-break: break-word;
}
.check-item.done .txt { text-decoration: line-through; color: var(--text-soft); }
.check-item .rm {
    flex: 0 0 auto;
    opacity: 0;
    cursor: pointer;
    color: var(--text-soft);
}
.check-item:hover .rm { opacity: 1; }
.check-item .rm:hover { color: #e0405a; }
/* Per-item note */
.check-item .note-btn {
    flex: 0 0 auto;
    opacity: 0;
    cursor: pointer;
    color: var(--text-soft);
    display: inline-flex; align-items: center;
}
.check-item:hover .note-btn, .check-item .note-btn.has { opacity: 1; }
.check-item .note-btn.has { color: var(--card); }
.check-item .note-btn .material-symbols-outlined { font-size: 16px; }
.check-note {
    margin: 1px 0 5px 26px;
    width: calc(100% - 26px);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel-2);
    color: var(--text-soft);
    font: inherit;
    font-size: 12.5px;
    line-height: 1.45;
    padding: 5px 7px;
    resize: vertical;
    outline: none;
}
.check-note:focus { color: var(--text); border-color: var(--card); }
.check-note.hidden { display: none; }
.check-add {
    margin-top: 4px;
    font-size: 12.5px;
    color: var(--text-soft);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.check-add:hover { color: var(--card); }

/* Progress bar inside header for checklist/progress/frame */
.card-progress {
    flex: 0 0 auto;
    height: 5px;
    background: rgba(0,0,0,.08);
}
[data-theme="dark"] .card-progress { background: rgba(255,255,255,.08); }
.card-progress > span {
    display: block;
    height: 100%;
    width: 0%;
    background: var(--card);
    transition: width .15s ease;
}

/* Image card */
.image-card .card-body { padding: 0; display: flex; }
.img-wrap { position: relative; flex: 1; overflow: hidden; }
.img-wrap img {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    object-fit: contain;
    -webkit-user-drag: none;
    user-drag: none;
}
.img-wrap img { cursor: zoom-in; }      /* click for a large preview */
.img-wrap img.pixelated { image-rendering: pixelated; }   /* nearest-neighbor (pixel art) */
.img-canvas {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
}
.img-canvas.active { pointer-events: auto; cursor: crosshair; }

/* Image preview lightbox */
.lightbox {
    position: fixed; inset: 0; z-index: 99999;
    display: none; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, 0.82);
    cursor: zoom-out;
    overflow: hidden;          /* a zoomed image is clipped to the screen */
}
.lightbox.open { display: flex; }
.lightbox img {
    display: block;
    max-width: none;           /* size is driven from JS so zoom stays sharp */
    border-radius: 10px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
    background: var(--panel);
}
/* PDF preview fills most of the screen. */
.pdf-lightbox { cursor: default; }
.pdf-lightbox iframe {
    width: 92vw; height: 92vh;
    border: 0;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
/* Video preview — large, letterboxed. */
.video-lightbox { cursor: default; }
.video-lightbox video {
    max-width: 92vw; max-height: 92vh;
    border-radius: 10px;
    background: #000;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}
.lightbox-close {
    position: absolute; top: 16px; right: 16px;
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px;
    background: var(--panel); color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
}
.lightbox-close:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.lightbox-close .material-symbols-outlined { font-size: 22px; }
.img-tools {
    position: absolute;
    top: 6px; left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 9px;
    box-shadow: var(--shadow);
    opacity: 0;
    transition: opacity .12s;
    z-index: 2;
}
.img-wrap:hover .img-tools, .img-tools.on { opacity: 1; }
.img-tools button {
    width: 26px; height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--panel-2);
    border-radius: 6px;
    cursor: pointer;
}
.img-tools button:hover { background: var(--accent); color: #fff; }
.img-tools button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.img-tools button .material-symbols-outlined { font-size: 17px; }
.img-dcolor {
    width: 16px; height: 16px;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,.25);
}
.img-dcolor:hover { transform: scale(1.15); }
.img-dcolor.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.image-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-soft);
    font-size: 12.5px;
    text-align: center;
    padding: 12px;
}
.image-empty .material-symbols-outlined { font-size: 32px; }
.image-empty button {
    border: 1px solid var(--border);
    background: var(--panel-2);
    border-radius: 8px;
    padding: 5px 10px;
    cursor: pointer;
}
.image-empty button:hover { background: var(--card); color: #fff; }

/* Emoji tile map */
.map-card .card-body { padding: 0; display: flex; flex-direction: column; overflow: hidden; }
.map-pal {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 4px 6px;
    background: var(--panel-2);
    border-bottom: 1px solid var(--border);
}
.map-emoji {
    width: 24px; height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
}
.map-emoji:hover { background: var(--border); }
.map-emoji.active { outline: 2px solid var(--card); }
.map-color {
    width: 22px; height: 22px;
    border-radius: 5px;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,.18);
}
.map-color:hover { transform: scale(1.12); }
.map-color.active { outline: 2px solid var(--text); outline-offset: 1px; }
.map-grid {
    flex: 1 1 auto;
    display: grid;
    overflow: auto;
    align-content: start;
    background:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
}
.map-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    user-select: none;
}
.map-cell:hover { background: var(--accent-soft); }

/* Resize handles — 4 edges + 4 corners */
.card-resize { position: absolute; z-index: 3; }
/* edges (inset from the corners so corner handles win there) */
.card-resize[data-dir="n"] { top: -3px;    left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.card-resize[data-dir="s"] { bottom: -3px; left: 12px; right: 12px; height: 8px; cursor: ns-resize; }
.card-resize[data-dir="e"] { right: -3px;  top: 12px;  bottom: 12px; width: 8px; cursor: ew-resize; }
.card-resize[data-dir="w"] { left: -3px;   top: 12px;  bottom: 12px; width: 8px; cursor: ew-resize; }
/* corners */
.card-resize[data-dir="nw"] { top: -4px;    left: -4px;  width: 15px; height: 15px; cursor: nwse-resize; z-index: 5; }
.card-resize[data-dir="ne"] { top: -4px;    right: -4px; width: 15px; height: 15px; cursor: nesw-resize; z-index: 5; }
.card-resize[data-dir="sw"] { bottom: -4px; left: -4px;  width: 15px; height: 15px; cursor: nesw-resize; z-index: 5; }
.card-resize[data-dir="se"] { bottom: -4px; right: -4px; width: 15px; height: 15px; cursor: nwse-resize; z-index: 5; }
/* subtle grip hint on the bottom-right corner */
.card-resize.corner-se::after {
    content: "";
    position: absolute;
    right: 4px; bottom: 4px;
    width: 7px; height: 7px;
    border-right: 2px solid var(--text-soft);
    border-bottom: 2px solid var(--text-soft);
    opacity: .6;
}

/* Connection drag handles — one on each side */
.link-handle {
    position: absolute;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--card);
    border: 2px solid var(--panel);
    cursor: crosshair;
    opacity: 0;
    transition: opacity .12s, transform .12s;
    z-index: 4;
}
.link-handle[data-side="top"]    { top: -9px;    left: 50%; transform: translateX(-50%); }
.link-handle[data-side="bottom"] { bottom: -9px; left: 50%; transform: translateX(-50%); }
.link-handle[data-side="left"]   { left: -9px;   top: 50%;  transform: translateY(-50%); }
.link-handle[data-side="right"]  { right: -9px;  top: 50%;  transform: translateY(-50%); }
.card:hover .link-handle, .card.selected .link-handle { opacity: 1; }
.link-handle[data-side="top"]:hover,
.link-handle[data-side="bottom"]:hover { transform: translateX(-50%) scale(1.3); }
.link-handle[data-side="left"]:hover,
.link-handle[data-side="right"]:hover  { transform: translateY(-50%) scale(1.3); }

/* Markdown note */
.note-md { word-break: break-word; }
.note-md:empty::before { content: "Click to write…  (Markdown supported)"; color: var(--text-soft); }
.note-md h1, .note-md h2, .note-md h3, .note-md h4 { margin: .45em 0 .3em; line-height: 1.25; }
.note-md h1 { font-size: 1.4em; }
.note-md h2 { font-size: 1.2em; }
.note-md h3 { font-size: 1.05em; }
.note-md p { margin: .4em 0; }
.note-md ul, .note-md ol { margin: .3em 0; padding-left: 1.4em; }
.note-md li { margin: .15em 0; }
.note-md a { color: var(--accent); }
.note-md code { background: var(--panel-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.note-md pre { background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px; padding: 8px 10px; overflow: auto; }
.note-md pre code { background: none; border: 0; padding: 0; }
.note-md blockquote { margin: .4em 0; padding: .2em .8em; border-left: 3px solid var(--border); color: var(--text-soft); }
.note-md img { max-width: 100%; border-radius: 6px; }
.note-md hr { border: 0; border-top: 1px solid var(--border); margin: .6em 0; }
.md-edit {
    width: 100%; height: 100%;
    border: 0; outline: none; resize: none;
    background: transparent;
    color: var(--text);
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.5;
}

/* Sound card */
.sound-card .card-body { display: flex; flex-direction: column; justify-content: center; gap: 10px; }
.snd-name { font-size: 13px; color: var(--text-soft); text-align: center; word-break: break-word; }
.sound-card audio { width: 100%; }

/* Video media card */
.video-card .card-body { padding: 0; display: flex; background: #000; }
.video-card video { width: 100%; height: 100%; object-fit: contain; background: #000; display: block; }

/* Lazy media host (video/audio mount here only while on-screen) */
.media-host { display: flex; min-width: 0; min-height: 0; }
.video-card .media-host { flex: 1; }
.sound-card .media-host { width: 100%; }
.media-ph {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%; min-height: 38px;
    color: var(--text-soft);
}
.media-ph .material-symbols-outlined { font-size: 40px; opacity: .5; }
.video-card .media-ph { color: #888; }

/* Embed card */
.embed-card .card-body { padding: 0; display: flex; }
.embed-frame { width: 100%; height: 100%; border: 0; }
.yt-facade {
    position: relative;
    flex: 1;
    background-color: #000;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.yt-facade::after {
    content: "";
    position: absolute; inset: 0;
    background: rgba(0, 0, 0, .12);
    transition: background .12s;
}
.yt-facade:hover::after { background: rgba(0, 0, 0, .04); }
.yt-play {
    position: relative;
    z-index: 1;
    width: 58px; height: 40px;
    border-radius: 9px;
    background: #f00;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .45);
    transition: transform .12s, background .12s;
}
.yt-facade:hover .yt-play { background: #ff2d2d; transform: scale(1.06); }
.yt-play .material-symbols-outlined { font-size: 30px; }
.embed-empty {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 10px; padding: 16px;
    color: var(--text-soft); text-align: center;
}
.embed-empty .material-symbols-outlined { font-size: 34px; }
.embed-empty input {
    width: 100%; padding: 7px 9px;
    border: 1px solid var(--border); border-radius: 7px;
    background: var(--panel-2); color: var(--text); font: inherit;
}
.embed-empty button {
    border: 1px solid var(--border); background: var(--panel-2);
    border-radius: 7px; padding: 6px 16px; cursor: pointer;
}
.embed-empty button:hover { background: var(--card); color: #fff; border-color: var(--card); }
.embed-link {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 6px; padding: 16px;
    text-decoration: none; color: var(--text); text-align: center;
}
.embed-favicon { width: 48px; height: 48px; border-radius: 10px; }
.embed-host { font-weight: 600; }
.embed-url { font-size: 12px; color: var(--text-soft); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.embed-open { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; color: var(--card); }
.embed-open .material-symbols-outlined { font-size: 16px; }

/* Web-bookmark tile (Embed card, generic links) */
.bookmark { position: relative; flex: 1; min-height: 0; display: flex; }
.bm-link {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    text-decoration: none; color: var(--text);
    overflow: hidden;
}
.bm-img {
    flex: 0 0 auto; height: 50%;
    background-size: cover; background-position: center;
    background-color: var(--panel-2);
    border-bottom: 1px solid var(--border);
}
.bm-body {
    flex: 1 1 auto; min-height: 0;
    display: flex; flex-direction: column; gap: 4px;
    padding: 10px 12px;
    overflow: hidden;
}
.bm-site { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-soft); }
.bm-fav { width: 16px; height: 16px; border-radius: 4px; flex: none; }
.bm-title { font-weight: 600; font-size: 14px; line-height: 1.25; overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bm-desc { font-size: 12px; color: var(--text-soft); line-height: 1.35; overflow: hidden;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.bm-url { margin-top: auto; font-size: 11px; color: var(--accent);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Compact (no metadata) variant: center the favicon + host like before. */
.bookmark:not(.rich) .bm-link { align-items: center; justify-content: center; text-align: center; gap: 6px; padding: 16px; }
.bookmark:not(.rich) .bm-fav { width: 44px; height: 44px; border-radius: 10px; }
.bookmark:not(.rich) .bm-title { font-size: 15px; }
.bm-refresh {
    position: absolute; top: 8px; right: 8px;
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; cursor: pointer;
    background: var(--panel); color: var(--text-soft);
    border: 1px solid var(--border); box-shadow: var(--shadow);
    opacity: 0; transition: opacity .12s;
}
.embed-card:hover .bm-refresh, .bm-refresh:focus { opacity: 1; }
.bm-refresh:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.bm-refresh .material-symbols-outlined { font-size: 17px; }
.bm-spin { animation: bm-spin 0.9s linear infinite; }
@keyframes bm-spin { to { transform: rotate(360deg); } }

/* Bookmarks card — a hand-typed list of links (nothing is fetched) */
.bk-list { display: flex; flex-direction: column; gap: 6px; }
.bk-item {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 7px 8px;
    border: 1px solid var(--border);
    border-left: 3px solid var(--card);
    border-radius: 7px;
    background: var(--panel-2);
}
.bk-open {
    flex: 0 0 auto;
    margin-top: 1px;
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px;
    color: #fff;
    background: var(--card);
    text-decoration: none;
    cursor: pointer;
}
.bk-open:hover { filter: brightness(1.08); }
.bk-open .material-symbols-outlined { font-size: 16px; }
/* No URL yet: a muted, non-clickable placeholder icon. */
.bk-open-off { background: transparent; color: var(--text-soft); border: 1px dashed var(--border); cursor: default; }
.bk-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bk-name {
    outline: none; cursor: text;
    font-weight: 600; font-size: 13.5px;
    word-break: break-word;
}
.bk-url {
    outline: none; cursor: text;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 11.5px;
    color: var(--accent);
    word-break: break-all;
}
.bk-desc {
    outline: none; cursor: text;
    font-size: 12px;
    color: var(--text-soft);
    word-break: break-word;
}
/* Placeholders for the empty editable fields. */
.bk-name:empty::before, .bk-url:empty::before, .bk-desc:empty::before {
    content: attr(data-ph);
    color: var(--text-soft);
    font-weight: 400;
    pointer-events: none;
}
.bk-url:empty::before { font-family: "Roboto", system-ui, sans-serif; }
.bk-del {
    flex: 0 0 auto;
    margin-top: 1px;
    cursor: pointer;
    color: var(--text-soft);
    opacity: 0;
    display: inline-flex; align-items: center;
}
.bk-item:hover .bk-del { opacity: 1; }
.bk-del:hover { color: #e0405a; }
.bk-add {
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--text-soft);
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 4px;
}
.bk-add:hover { color: var(--card); }

/* File card */
.file-card .card-body { padding: 0; display: flex; }
.file-tile {
    flex: 1;
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px;
    text-decoration: none; color: var(--text);
    min-width: 0;
}
.file-tile:hover { background: var(--panel-2); }
.file-ico {
    flex: none;
    width: 46px; height: 46px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in srgb, var(--card) 16%, transparent);
    color: var(--card);
}
.file-ico .material-symbols-outlined { font-size: 28px; }
.file-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.file-name { font-weight: 600; font-size: 13.5px; word-break: break-word; }
.file-sub { font-size: 11.5px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .03em; }
.file-dl-btn {
    flex: none;
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 8px;
    color: var(--text-soft);
}
.file-tile:hover .file-dl-btn { background: var(--card); color: #fff; }
.file-pdf { position: relative; flex: 1; display: flex; }
.pdf-frame { width: 100%; height: 100%; border: 0; background: #fff; }
/* PDF tile (no inline iframe — preview opens on demand) */
.pdf-tile { gap: 10px; cursor: default; }
.pdf-tile .file-dl-btn { border: 0; cursor: pointer; background: color-mix(in srgb, var(--card) 14%, transparent); }
.pdf-tile .file-dl-btn:hover { background: var(--card); color: #fff; }
.pdf-tile .file-dl-btn .material-symbols-outlined { font-size: 18px; }
.file-dl {
    position: absolute; top: 8px; right: 8px;
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--panel); color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    text-decoration: none;
    opacity: 0; transition: opacity .12s;
}
.file-pdf:hover .file-dl { opacity: 1; }
.file-dl:hover { background: var(--card); color: #fff; border-color: var(--card); }
.file-dl .material-symbols-outlined { font-size: 18px; }

/* Kanban card */
.kanban-card .card-body { padding: 8px; overflow: hidden; }
.kb-board { display: flex; gap: 8px; height: 100%; align-items: stretch; overflow-x: auto; overflow-y: hidden; }
/* Circular "+" to the right of the last column — adds a column. */
.kb-addcol {
    flex: 0 0 auto;
    align-self: flex-start;
    width: 30px; height: 30px;
    margin-top: 1px;
    border-radius: 50%;
    border: 1px dashed var(--border);
    background: var(--panel-2);
    color: var(--text-soft);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.kb-addcol:hover { background: var(--card); color: #fff; border-color: var(--card); }
.kb-addcol .material-symbols-outlined { font-size: 18px; }
.kb-col {
    --col: var(--border);
    position: relative;
    flex: 0 0 auto;
    width: 208px;          /* overridden inline per column */
    display: flex; flex-direction: column;
    max-height: 100%;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-top: 3px solid var(--col);   /* colour accent */
    border-radius: 9px;
}
.kb-col-head {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 8px 5px;
    background: color-mix(in srgb, var(--col) 16%, transparent);
    border-radius: 7px 7px 0 0;
}
.kb-col-title { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; outline: none; word-break: break-word; }
.kb-count { flex: 0 0 auto; font-size: 11px; color: var(--text-soft); background: var(--panel); border-radius: 10px; padding: 0 6px; }
.kb-col-color {
    flex: 0 0 auto;
    width: 13px; height: 13px; border-radius: 50%;
    border: 2px solid var(--panel);
    box-shadow: 0 0 0 1px var(--border);
    cursor: pointer;
}
.kb-col-del { flex: 0 0 auto; cursor: pointer; color: var(--text-soft); opacity: 0; display: inline-flex; }
.kb-col:hover .kb-col-del { opacity: 1; }
.kb-col-del:hover { color: #e0405a; }
/* Drag strip in the gap on a column's right edge — resize the column by dragging. */
.kb-resize {
    position: absolute; top: 0; bottom: 0; right: -6px;
    width: 11px; cursor: col-resize; z-index: 6;
}
.kb-resize::after {
    content: ''; position: absolute;
    top: 6px; bottom: 6px; left: 50%; transform: translateX(-50%);
    width: 3px; border-radius: 3px;
    background: var(--accent);
    opacity: 0; transition: opacity .12s;
}
.kb-col:hover .kb-resize::after, .kb-col.kb-resizing .kb-resize::after { opacity: .35; }
.kb-resize:hover::after { opacity: 1 !important; }
.kb-items {
    flex: 1; min-height: 28px;
    overflow-y: auto;
    padding: 4px 6px;
    display: flex; flex-direction: column; gap: 6px;
    border-radius: 0 0 9px 9px;
}
.kb-items.kb-over { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--card); }
.kb-item {
    display: flex; gap: 3px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 6px 6px 6px 2px;
}
.kb-item.kb-dragging { opacity: .4; }
.kb-handle { flex: 0 0 auto; cursor: grab; color: var(--text-soft); display: inline-flex; align-items: flex-start; }
.kb-handle:active { cursor: grabbing; }
.kb-handle .material-symbols-outlined { font-size: 16px; }
.kb-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.kb-item-text { font-size: 12.5px; line-height: 1.35; outline: none; word-break: break-word; }
.kb-item-bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 20px; }
.kb-assignees { display: inline-flex; align-items: center; cursor: pointer; opacity: 0; transition: opacity .12s; }
.kb-item:hover .kb-assignees, .kb-assignees.has { opacity: 1; }
.kb-assignees .avatar { width: 18px; height: 18px; margin-left: -5px; }
.kb-assignees .avatar:first-child { margin-left: 0; }
.kb-assignees .assign-add { width: 20px; height: 20px; }
.kb-assignees .assign-add .material-symbols-outlined { font-size: 14px; }
.kb-item-del { flex: 0 0 auto; cursor: pointer; color: var(--text-soft); opacity: 0; display: inline-flex; }
.kb-item:hover .kb-item-del { opacity: 1; }
.kb-item-del:hover { color: #e0405a; }
.kb-add {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 4px;
    font-size: 12px; color: var(--text-soft); cursor: pointer;
    padding: 6px 8px;
}
.kb-add:hover { color: var(--text); }

/* Minimap */
#minimap {
    position: absolute;
    right: 16px; bottom: 16px;
    width: 210px; height: 150px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 800;
}
#minimap.hidden { display: none; }
#minimapCanvas { width: 100%; height: 100%; display: block; cursor: pointer; }

/*====================================================================
  Outline — toggleable list of every card; click to fly to it
====================================================================*/
#outline {
    position: absolute;
    top: 16px; left: 16px; bottom: 16px;
    width: 244px;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: hidden;
    z-index: 800;
}
#outline.hidden { display: none; }
.outline-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 13px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 13px;
}
.outline-head .material-symbols-outlined { font-size: 18px; color: var(--text-soft); }
.outline-count {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-soft);
    background: var(--panel-2);
    border-radius: 10px;
    padding: 1px 8px;
    min-width: 20px;
    text-align: center;
}
.outline-list { flex: 1 1 auto; overflow-y: auto; padding: 6px; }
.outline-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 8px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text);
    user-select: none;
}
.outline-item:hover { background: var(--panel-2); }
.outline-item.selected { background: var(--accent-soft); }
.outline-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.outline-ico { font-size: 17px !important; color: var(--text-soft); flex: none; }
.outline-name { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.outline-empty { padding: 16px 12px; color: var(--text-soft); font-size: 12.5px; text-align: center; }

/*====================================================================
  Context menu + color palette
====================================================================*/
.menu {
    position: fixed;
    z-index: 9000;
    min-width: 180px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 6px;
    font-size: 13px;
    display: none;
}
.menu.open { display: block; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 7px;
    cursor: pointer;
    white-space: nowrap;
}
.menu-item:hover { background: var(--panel-2); }
.menu-item.danger:hover { background: #e0405a; color: #fff; }
.menu-item .material-symbols-outlined { font-size: 18px; color: var(--text-soft); }
.menu-item:hover .material-symbols-outlined { color: inherit; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-label { padding: 4px 10px 2px; font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: .5px; }

.swatches { display: flex; gap: 6px; padding: 4px 10px 8px; }
.swatch {
    width: 20px; height: 20px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid transparent;
}
.swatch:hover { transform: scale(1.15); }
.swatch.active { border-color: var(--text); }

/*====================================================================
  Help overlay + toast
====================================================================*/
.overlay {
    position: fixed;
    inset: 0;
    z-index: 9500;
    background: rgba(0,0,0,.45);
    display: none;
    align-items: center;
    justify-content: center;
}
.overlay.open { display: flex; }
.modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    width: min(560px, 92vw);
    max-height: 86vh;
    overflow: auto;
    padding: 24px 26px;
}
.modal h2 { margin: 0 0 6px; font-size: 19px; }
.modal p.sub { margin: 0 0 16px; color: var(--text-soft); font-size: 13px; }
.modal .row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 7px 0;
    border-top: 1px solid var(--border);
    font-size: 13.5px;
}
.modal kbd {
    font-family: ui-monospace, Menlo, Consolas, monospace;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 12px;
    white-space: nowrap;
}
.modal .close-row { display: flex; justify-content: flex-end; margin-top: 18px; }

/*====================================================================
  People + assignees
====================================================================*/
/* Round initials avatar */
.avatar {
    flex: 0 0 auto;
    width: 22px; height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    border: 1.5px solid var(--panel);
    box-shadow: 0 0 0 1px rgba(0,0,0,.06);
    user-select: none;
}

/* People manager modal */
.people-list { display: flex; flex-direction: column; gap: 2px; }
.people-row {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 4px;
    border-top: 1px solid var(--border);
}
.people-row .pname { flex: 1; font-size: 14px; }
.people-row .prm {
    cursor: pointer; color: var(--text-soft);
    width: 28px; height: 28px; border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
}
.people-row .prm:hover { background: #e0405a; color: #fff; }
.people-empty { color: var(--text-soft); font-size: 13px; padding: 10px 4px; }

/* Plans manager list */
.plans-list { display: flex; flex-direction: column; gap: 2px; max-height: 50vh; overflow-y: auto; }
.plan-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 8px;
    border-radius: 8px;
    cursor: pointer;
}
.plan-row:hover { background: var(--panel-2); }
.plan-row.active { background: var(--accent-soft); }
.plan-ico { font-size: 20px !important; color: var(--text-soft); flex: none; }
.plan-row.active .plan-ico { color: var(--accent); }
.plan-name { flex: 1; min-width: 0; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plan-badge {
    flex: none; font-size: 11px; font-weight: 600; color: var(--accent);
    background: var(--panel); border: 1px solid var(--accent); border-radius: 20px;
    padding: 1px 8px;
}
.plan-act {
    flex: none; cursor: pointer; color: var(--text-soft);
    width: 28px; height: 28px; border-radius: 7px;
    display: inline-flex; align-items: center; justify-content: center;
}
.plan-act .material-symbols-outlined { font-size: 18px; }
.plan-act.js-plan-rename:hover { background: var(--accent); color: #fff; }
.plan-act.js-plan-delete:hover { background: #e0405a; color: #fff; }

.people-add { display: flex; gap: 8px; margin-top: 14px; }
.people-add input {
    flex: 1; padding: 8px 10px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--panel-2); color: var(--text); font: inherit;
}

/* Assignee cluster inside a checklist item */
.assignees {
    flex: 0 0 auto;
    display: inline-flex; align-items: center;
    cursor: pointer;
}
.assignees .avatar { width: 20px; height: 20px; margin-left: -6px; }
.assignees .avatar:first-child { margin-left: 0; }
.assign-add {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; margin-left: 2px;
    border-radius: 50%;
    color: var(--text-soft);
    border: 1px dashed var(--border);
}
.assignees:hover .assign-add { color: var(--card); border-color: var(--card); }
.assign-add .material-symbols-outlined { font-size: 15px; }
.check-item .assignees { opacity: 0; transition: opacity .12s; }
.check-item:hover .assignees,
.check-item .assignees.has { opacity: 1; }

/* Assignee picker menu */
#assignMenu { min-width: 200px; max-height: 280px; overflow: auto; }
.assign-row {
    display: flex; align-items: center; gap: 9px;
    padding: 7px 9px; border-radius: 7px; cursor: pointer;
}
.assign-row:hover { background: var(--panel-2); }
.assign-row .aname { flex: 1; font-size: 13px; }
.assign-row .acheck { width: 18px; color: var(--card); opacity: 0; }
.assign-row.on .acheck { opacity: 1; }
.assign-row .acheck .material-symbols-outlined { font-size: 18px; }
.assign-manage {
    margin-top: 4px; padding: 7px 9px; border-top: 1px solid var(--border);
    font-size: 12.5px; color: var(--card); cursor: pointer; border-radius: 7px;
}
.assign-manage:hover { background: var(--panel-2); }

#toast {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--text);
    color: var(--bg);
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 13px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 9999;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/*====================================================================
  Task Keeper card — tasks with date, done/important flags, updates log
====================================================================*/
/* In Progress / Done tabs */
.tk-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.tk-tab {
    flex: 1;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 5px 8px;
    font-size: 12px; font-weight: 600;
    color: var(--text-soft);
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    cursor: pointer;
    user-select: none;
}
.tk-tab:hover { color: var(--text); }
.tk-tab.active { background: var(--card); border-color: var(--card); color: #fff; }
.tk-tab-n {
    min-width: 16px; height: 16px; padding: 0 4px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; border-radius: 8px;
    background: rgba(0, 0, 0, .12);
}
[data-theme="dark"] .tk-tab-n { background: rgba(255, 255, 255, .1); }
.tk-tab.active .tk-tab-n { background: rgba(255, 255, 255, .25); }
.tk-empty { color: var(--text-soft); font-size: 12.5px; padding: 8px 2px; }

.tk-list { display: flex; flex-direction: column; gap: 8px; }
.tk-task {
    border: 1px solid var(--border);
    border-left: 4px solid var(--card);
    border-radius: 7px;
    background: var(--panel-2);
    overflow: hidden;
}
.tk-task.important {
    border-color: #d22630;
    border-left-color: #d22630;
    background: rgba(210, 38, 48, .10);
}
/* Top-aligned: a long (wrapped) title must not push the controls to its centre. */
.tk-task-head { display: flex; align-items: flex-start; gap: 6px; padding: 6px 8px; }
.tk-check {
    flex: 0 0 auto;
    width: 18px; height: 18px;
    margin-top: 1px;
    border: 2px solid var(--card);
    border-radius: 5px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff;
}
.tk-check .material-symbols-outlined { font-size: 14px; display: none; }
.tk-task.done .tk-check { background: var(--card); }
.tk-task.done .tk-check .material-symbols-outlined { display: block; }
.tk-title {
    flex: 1;
    outline: none;
    cursor: text;
    font-weight: 600;
    word-break: break-word;
}
.tk-title:empty::before { content: "Task"; color: var(--text-soft); font-weight: 400; }
.tk-task.done .tk-title { text-decoration: line-through; color: var(--text-soft); }
.tk-title img { max-width: 100%; border-radius: 6px; display: block; margin: 4px 0; }
.tk-date {
    flex: 0 0 auto;
    margin-top: 1px;
    font-size: 11px;
    color: var(--text-soft);
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1px 7px;
    white-space: nowrap;
}
.tk-btn {
    flex: 0 0 auto;
    margin-top: 1px;
    opacity: .8;                 /* always visible, anchored in the task's top row */
    cursor: pointer;
    color: var(--text-soft);
    display: inline-flex; align-items: center;
}
.tk-btn:hover { color: var(--card); opacity: 1; }
.tk-btn .material-symbols-outlined { font-size: 16px; }
.js-tk-del:hover { color: #e0405a; }
.tk-task.important .js-tk-important { opacity: 1; color: #d22630; }
.tk-updates { display: flex; flex-direction: column; gap: 4px; padding: 0 8px 8px 8px; }
.tk-updates:empty { display: none; }
.tk-update {
    display: flex; align-items: flex-start; gap: 6px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-left: 3px solid var(--text-soft);
    border-radius: 6px;
    padding: 5px 7px;
}
.tk-update-text {
    flex: 1;
    outline: none;
    cursor: text;
    font-size: 12.5px;
    color: var(--text-soft);
    white-space: pre-wrap;
    word-break: break-word;
}
.tk-update-text:focus { color: var(--text); }
.tk-update-text:empty::before { content: "Update…"; color: var(--text-soft); }
.tk-update-text img { max-width: 100%; border-radius: 6px; display: block; margin: 4px 0; }
.tk-upd-del { flex: 0 0 auto; margin-top: 1px; opacity: 0; cursor: pointer; color: var(--text-soft); }
.tk-update:hover .tk-upd-del { opacity: 1; }
.tk-upd-del:hover { color: #e0405a; }
.tk-upd-del .material-symbols-outlined { font-size: 15px; }
.tk-add {
    margin-top: 2px;
    font-size: 12.5px;
    color: var(--text-soft);
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 4px;
}
.tk-add:hover { color: var(--card); }
.tk-add .material-symbols-outlined { font-size: 16px; }

/* Full-screen mode — a card (Tasks or Table) pops into this centred overlay */
.card-full-overlay {
    position: fixed; inset: 0; z-index: 3000;
    display: none;
    align-items: center; justify-content: center;
    padding: 24px;
    background: rgba(8, 10, 16, .55);
    backdrop-filter: blur(2px);
}
.card-full-overlay.open { display: flex; }
.card-full-close {
    position: absolute; top: 16px; right: 18px;
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    cursor: pointer;
    z-index: 1;
}
.card-full-close:hover { background: rgba(255, 255, 255, .26); }
.card-full-close .material-symbols-outlined { font-size: 24px; }
.card.card-fullscreen {
    position: relative !important;
    left: auto !important; top: auto !important;
    width: min(1100px, 96vw) !important;
    height: 92vh !important;
    transform: none !important;
    cursor: default;
    box-shadow: var(--shadow);
}
.card.card-fullscreen .card-resize,
.card.card-fullscreen .link-handle { display: none !important; }
/* In full screen the in-card delete X + expand toggle are hidden — close via the
   external X (top-right of the overlay), Esc, or the backdrop, like the image card. */
.card.card-fullscreen .js-del,
.card.card-fullscreen .js-card-full { display: none !important; }
/* A touch more breathing room at full size */
.card.card-fullscreen .card-body { padding: 16px 20px; }
.card.card-fullscreen .tk-task-head { padding: 8px 10px; }

/* Table card — a VIRTUALIZED spreadsheet. Only the cells/headers in view exist in
   the DOM (painted by wireTable on scroll); .tbl-grid is sized to the full logical
   sheet so the scrollbars are real. Headers use position:sticky so the COMPOSITOR
   pins them (no per-scroll JS = no lag). Excel-style letters (cols) + numbers. */
.table-card .card-body { padding: 0; overflow: hidden; display: flex; }
.tbl-wrap { flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; }
.tbl-viewport { flex: 1 1 auto; min-height: 0; min-width: 0; overflow: auto; position: relative; }
.tbl-grid { position: relative; }
.tbl-rows { position: absolute; top: 0; left: 0; }

/* Column-letter header row — sticky to the top; its letters scroll horizontally. */
.tbl-headrow { position: sticky; top: 0; z-index: 5; height: 22px; }
.tbl-corner {
    position: sticky; left: 0; z-index: 2;
    width: 46px; height: 100%; box-sizing: border-box;
    background: var(--panel-2); border: 1px solid var(--border);
}
.tbl-colhead {
    position: absolute; top: 0; height: 100%; box-sizing: border-box;
    background: var(--panel-2); border: 1px solid var(--border);
}
.tbl-colhead:hover { background: var(--border); }
.tbl-collabel {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; color: var(--text-soft);
}
.tbl-colhead:hover .tbl-collabel { opacity: 0; }
.tbl-colx {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-soft); cursor: pointer; opacity: 0;
}
.tbl-colhead:hover .tbl-colx { opacity: .7; }
.tbl-colx:hover { opacity: 1 !important; color: #e0405a; }
.tbl-colx .material-symbols-outlined { font-size: 13px; }
.tbl-rcol { position: absolute; top: 0; right: -3px; width: 6px; height: 100%; cursor: col-resize; z-index: 2; }
.tbl-rcol:hover { background: var(--accent); }

/* One data row (absolute; top/height/width set inline). Its number sticks left. */
.tbl-row { position: absolute; left: 0; }
.tbl-rowhead {
    position: sticky; left: 0; z-index: 2;
    width: 46px; height: 100%; box-sizing: border-box;
    display: flex; align-items: center; justify-content: center;
    background: var(--panel-2); border: 1px solid var(--border);
    color: var(--text-soft); font-size: 10px;
}
.tbl-rowhead:hover { background: var(--border); }
.tbl-rownum { opacity: .8; }
.tbl-rowhead:hover .tbl-rownum { opacity: 0; }
.tbl-rowx {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-soft); cursor: pointer; opacity: 0;
}
.tbl-rowhead:hover .tbl-rowx { opacity: .7; }
.tbl-rowx:hover { opacity: 1 !important; color: #e0405a; }
.tbl-rowx .material-symbols-outlined { font-size: 13px; }
.tbl-rrow { position: absolute; left: 0; bottom: -3px; width: 100%; height: 6px; cursor: row-resize; z-index: 3; }
.tbl-rrow:hover { background: var(--accent); }

/* Cells (absolute within their row; right+bottom borders make a clean 1px grid). */
.tbl-cell {
    position: absolute; top: 0; height: 100%; box-sizing: border-box; display: flex;
    border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
    background: var(--panel);
}
.tbl-edit {
    flex: 1 1 auto; min-width: 0;
    padding: 4px 6px;
    font-size: 13px; line-height: 1.35;
    outline: none; cursor: text;
    word-break: break-word; overflow-wrap: anywhere; overflow: hidden;
}
.tbl-cell:focus-within { box-shadow: inset 0 0 0 2px var(--card); z-index: 1; }
.tbl-cell.tbl-drop { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-soft); }
.tbl-edit img { max-width: 100%; max-height: 100%; border-radius: 4px; display: block; }
.tbl-cell.tbl-head { background: var(--panel-2); }
.tbl-cell.tbl-head .tbl-edit { font-weight: 700; }
/* Per-cell image button — small + subtle, appears on hover/focus. */
.tbl-imgbtn {
    position: absolute; top: 1px; right: 1px;
    width: 15px; height: 15px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 4px;
    background: transparent; color: var(--text-soft);
    cursor: pointer; opacity: 0; transition: opacity .12s; z-index: 2;
}
.tbl-cell:hover .tbl-imgbtn, .tbl-cell:focus-within .tbl-imgbtn { opacity: .6; }
.tbl-imgbtn:hover { opacity: 1 !important; color: var(--card); }
.tbl-imgbtn .material-symbols-outlined { font-size: 13px; }

/*====================================================================
  Colour palette card — swatches with hex + rgb and one-click copy
====================================================================*/
.palette-card .card-body { padding: 0; }
/* Overview bar: every colour as a segment, pinned to the top while the list
   scrolls. Clicking a segment jumps to that colour's row. */
.pal-bar {
    position: sticky; top: 0; z-index: 2;
    display: flex; gap: 2px;
    min-width: 392px;       /* match .pal-row so it aligns under horizontal scroll */
    padding: 8px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.pal-bar-seg {
    flex: 1 1 0; min-width: 8px; height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, .15);
    cursor: pointer;
}
.pal-bar-seg:hover { outline: 2px solid var(--accent); outline-offset: 1px; }
.pal-list { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.pal-empty { color: var(--text-soft); font-size: 12.5px; padding: 8px 2px; }
/* Example-artwork image (imported from Lospec) */
.pal-example-wrap { position: relative; }
.pal-example {
    display: block; width: 100%;
    max-height: 160px; object-fit: contain;
    image-rendering: pixelated;          /* keep pixel art crisp */
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel);
    cursor: zoom-in;
}
.pal-example-rm {
    position: absolute; top: 6px; right: 6px;
    width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 6px;
    background: var(--panel); color: var(--text-soft);
    border: 1px solid var(--border); box-shadow: var(--shadow);
    cursor: pointer; opacity: 0;
}
.pal-example-wrap:hover .pal-example-rm { opacity: 1; }
.pal-example-rm:hover { background: #e0405a; color: #fff; border-color: #e0405a; }
.pal-example-rm .material-symbols-outlined { font-size: 16px; }
.pal-row {
    display: flex; align-items: stretch; gap: 8px;
    min-width: 392px;       /* never squash below fitting every control on one line */
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-2);
}
/* Swatch doubles as the native colour picker (input fills it, invisibly).
   Clicking it is the only way to change the colour. */
.pal-swatch {
    flex: 0 0 auto;
    position: relative;
    width: 48px; min-height: 44px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, .18);
    cursor: pointer;
    overflow: hidden;
}
.pal-swatch input[type="color"] {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    margin: 0; padding: 0; border: 0;
    opacity: 0; cursor: pointer;
}
.pal-vals {
    flex: 1 1 auto; min-width: 0;
    display: flex; flex-direction: column; justify-content: center; gap: 5px;
}
.pal-val { display: flex; align-items: center; gap: 5px; }
/* RGB line: the channels wrap among themselves inside .pal-channels, while the
   copy-all button stays pinned on the right (never drops to its own line). */
.pal-rgb-row { align-items: flex-start; gap: 6px; }
.pal-channels { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; gap: 5px 6px; }
.pal-tag {
    flex: 0 0 auto;
    font-size: 10px; font-weight: 700; letter-spacing: .04em;
    color: var(--text-soft);
    min-width: 12px; text-align: center;
}
/* Shared text-field styling for the hex + R/G/B channel inputs. */
.pal-hex, .pal-num {
    border: 1px solid transparent;
    border-radius: 5px;
    background: var(--panel);
    color: var(--text);
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12.5px;
    font-weight: 600;
    padding: 3px 6px;
    outline: none;
}
/* Every value is a read-only read-out — static look, no caret/focus ring.
   (Change the colour by clicking the swatch.) */
.pal-hex { flex: 1; min-width: 0; text-transform: uppercase; cursor: default; }
.pal-num { width: 40px; text-align: center; cursor: default; color: var(--text-soft); }
/* One R/G/B channel: tag + number box + its own copy button. */
.pal-ch { display: inline-flex; align-items: center; gap: 3px; }
.pal-copy {
    flex: 0 0 auto;
    width: 26px; height: 26px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--panel);
    color: var(--text-soft);
    cursor: pointer;
}
.pal-copy:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.pal-copy .material-symbols-outlined { font-size: 15px; }
.pal-copy-sm { width: 22px; height: 22px; }
.pal-copy-sm .material-symbols-outlined { font-size: 13px; }
/* The "copy all three" button stays pinned to the right (lines up under the
   hex copy button) and stands out a little. */
.pal-copyall { flex: 0 0 auto; border-color: var(--accent); color: var(--accent); }
.pal-del {
    flex: 0 0 auto;
    width: 22px;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-soft);
    cursor: pointer;
    opacity: 0;
}
.pal-row:hover .pal-del { opacity: 1; }
.pal-del:hover { color: #e0405a; }
.pal-del .material-symbols-outlined { font-size: 16px; }
.pal-actions { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 2px; }
.pal-add {
    padding: 4px 2px;
    font-size: 12.5px;
    color: var(--text-soft);
    cursor: pointer;
    display: inline-flex; align-items: center; gap: 4px;
}
.pal-add:hover { color: var(--accent); }
.pal-add .material-symbols-outlined { font-size: 16px; }

/*====================================================================
  Pixel-art editor card
====================================================================*/
.pixel-card .card-body { padding: 0; display: flex; flex-direction: column; }
.px-toolbar {
    flex: 0 0 auto;
    display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
    padding: 5px 6px;
    background: var(--panel-2);
    border-bottom: 1px solid var(--border);
}
.px-tool {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent; border-radius: 6px;
    background: transparent; color: var(--text-soft); cursor: pointer;
}
.px-tool:hover { background: var(--border); color: var(--text); }
.px-tool.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.px-tool .material-symbols-outlined { font-size: 18px; }
.px-tool-sep { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--border); }
.px-canvas-wrap {
    flex: 1 1 auto; min-height: 0;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; padding: 8px;
    background: var(--panel);
}
.js-px-canvas { image-rendering: pixelated; cursor: crosshair; box-shadow: 0 0 0 1px var(--border); }
.px-palette-row {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 8px;
    padding: 6px 8px;
    border-top: 1px solid var(--border);
}
.px-color {
    position: relative; flex: 0 0 auto;
    width: 30px; height: 24px;
    border-radius: 6px; border: 1px solid rgba(0,0,0,.2);
    cursor: pointer; overflow: hidden;
}
.px-color input[type="color"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; padding: 0; margin: 0; cursor: pointer; }
.px-swatches { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; max-height: 54px; overflow-y: auto; }
.px-swatch { width: 18px; height: 18px; border-radius: 4px; border: 1px solid rgba(0,0,0,.18); cursor: pointer; }
.px-swatch:hover { transform: scale(1.12); }
.px-swatch.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.px-swatch.active2 { box-shadow: inset 0 0 0 2px rgba(255,255,255,.9), inset 0 0 0 3px rgba(0,0,0,.55); }
.px-colors { flex: 0 0 auto; display: inline-flex; gap: 4px; }
.px-color2 { width: 26px; }
.px-controls {
    flex: 0 0 auto;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 6px 8px;
    border-top: 1px solid var(--border);
}
.px-size { display: inline-flex; align-items: center; gap: 4px; }
.px-x { color: var(--text-soft); }
.px-num {
    width: 42px; text-align: center;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--panel); color: var(--text);
    font: inherit; font-size: 12.5px; padding: 3px 4px; outline: none;
}
.px-num:focus { border-color: var(--accent); }
.px-actions { display: inline-flex; align-items: center; gap: 4px; }
.px-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    height: 26px; padding: 0 8px;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--panel-2); color: var(--text);
    font: inherit; font-size: 12px; cursor: pointer;
}
.px-btn.icon { width: 28px; padding: 0; }
.px-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.px-btn .material-symbols-outlined { font-size: 17px; }
.px-brush-n { font-size: 13px; font-weight: 700; }
/* Frames + layers strips */
.px-frames, .px-layers {
    flex: 0 0 auto;
    display: flex; align-items: center; gap: 4px;
    padding: 5px 8px;
    border-top: 1px solid var(--border);
    background: var(--panel-2);
}
.px-layers-label, .px-fps-label { flex: 0 0 auto; font-size: 11px; color: var(--text-soft); }
.px-mini {
    flex: 0 0 auto; width: 24px; height: 24px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--panel); color: var(--text-soft); cursor: pointer;
}
.px-mini:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.px-mini.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.px-mini .material-symbols-outlined { font-size: 16px; }
.px-fps {
    flex: 0 0 auto; width: 34px; text-align: center;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--panel); color: var(--text); font: inherit; font-size: 12px; padding: 2px; outline: none;
}
.px-fps:focus { border-color: var(--accent); }
.px-frame-list, .px-layer-list { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 3px; overflow-x: auto; }
.px-frame {
    flex: 0 0 auto; min-width: 24px; height: 24px; padding: 0 6px;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--panel); color: var(--text); font: inherit; font-size: 12px; cursor: pointer;
}
.px-frame.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.px-layer {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 1px;
    border: 1px solid var(--border); border-radius: 6px; background: var(--panel); padding: 1px 2px 1px 1px;
}
.px-layer.active { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.px-eye { width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--text-soft); cursor: pointer; border-radius: 5px; }
.px-eye.on { color: var(--accent); }
.px-eye .material-symbols-outlined { font-size: 15px; }
.px-layer-name { border: 0; background: transparent; color: var(--text); font: inherit; font-size: 12px; cursor: pointer; padding: 0 4px 0 0; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
