/* ═══════════════════════════════════════════════════════════════════════════
   planner.css — Strategy Planner IDE shell.
   Reuses the PurpleClear design tokens defined in blog.css (--purple,
   --purple-dark, --bg-white, --border, --border-radius: 0 sharp corners,
   --font-brand/body). Only the IDE-style two-pane layout (left brand/project/
   version tree + center node canvas) is added here.
   ═══════════════════════════════════════════════════════════════════════════ */

html, body {
    margin: 0;
    height: 100%;
    font-family: var(--font-body);
    color: var(--text-primary);
    background: var(--bg-light);
}

/* The UI toggles visibility via the `hidden` attribute (JS sets el.hidden).
   Components like .modal-overlay / .canvas-empty / .ctx-menu set `display`, which
   at equal specificity would override the UA [hidden] rule — leaving modals stuck
   open and Cancel unable to close them. Make `hidden` authoritative everywhere. */
[hidden] {
    display: none !important;
}

.planner-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
    /* anchor for the left edge tab so it rides the panel border. */
    position: relative;
}

/* ── Left IDE tree panel ─────────────────────────────────────────────────── */

.planner-tree {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    box-shadow: 0 6px 20px rgba(51, 0, 76, 0.08);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.planner-tree__header {
    padding: 16px;
    background: var(--bg-white);
    color: var(--purple-dark);
    border-bottom: 1px solid var(--border);
    font-family: var(--font-brand);
    font-size: 15px;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.planner-tree__body {
    padding: 8px 0;
    flex: 1;
}

.planner-tree__empty {
    padding: 16px;
    color: var(--text-muted);
    font-size: 13px;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    /* redesign rows pack their own guides/caret/icon, so a tighter row metric is
       used and the per-kind left padding (below) is reset to a uniform 4px. */
    padding: 3px 10px 3px 4px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    border-left: 3px solid transparent;
}

.tree-item:hover {
    background: var(--bg-light);
}

.tree-item--active {
    background: var(--purple-light);
    border-left-color: var(--purple);
}

.tree-item--brand   { padding-left: 12px; font-weight: 600; }
.tree-item--project { padding-left: 28px; }
.tree-item--version { padding-left: 44px; color: var(--text-muted); }

/* ── Center node canvas ──────────────────────────────────────────────────── */

.planner-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.planner-topbar {
    height: 48px;
    flex-shrink: 0;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-family: var(--font-brand);
    color: var(--purple-dark);
    box-shadow: 0 2px 6px rgba(51, 0, 76, 0.05);
    justify-content: space-between;
    gap: 12px;
}

.planner-canvas {
    flex: 1;
    position: relative;
    overflow: auto;
    background:
        repeating-linear-gradient(0deg, transparent 0 31px, rgba(66, 33, 134, 0.05) 31px 32px),
        repeating-linear-gradient(90deg, transparent 0 31px, rgba(66, 33, 134, 0.05) 31px 32px),
        var(--bg-light);
    cursor: grab;
}

.canvas-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
    gap: 8px;
    padding: 24px;
}

.canvas-empty h2 {
    font-family: var(--font-brand);
    color: var(--purple-dark);
    margin: 0;
}

/* ── Tree header / footer chrome (auth + tree layer) ─────────────────────── */

.planner-tree__new {
    background: var(--bg-white);
    color: var(--purple);
    border: 1px solid var(--border);
    width: 22px;
    height: 22px;
    line-height: 18px;
    font-size: 16px;
    cursor: pointer;
    border-radius: var(--border-radius);
}

.planner-tree__new:hover { background: rgba(255, 255, 255, 0.3); }

.planner-tree__footer {
    border-top: 1px solid var(--border);
    padding: 10px 12px;
    margin: 0;
}

.planner-tree__logout {
    width: 100%;
    background: var(--bg-white);
    color: var(--purple-dark);
    border: 1px solid var(--border);
    padding: 8px 10px;
    font-family: var(--font-brand);
    font-size: 12px;
    cursor: pointer;
    border-radius: var(--border-radius);
}

.planner-tree__logout:hover { background: var(--bg-light); color: var(--purple); }

.planner-topbar__crumb { font-size: 13px; }
.planner-topbar__host { font-size: 11px; color: var(--text-muted); font-family: var(--font-body); }

/* ── Right-click context menu ────────────────────────────────────────────── */

.ctx-menu {
    position: fixed;
    z-index: 50;
    min-width: 168px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(51, 0, 76, 0.18);
    border-radius: var(--border-radius);
    padding: 4px 0;
}

.ctx-menu__item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: 0;
    padding: 8px 14px;
    font-size: 13px;
    font-family: var(--font-body);
    color: var(--text-primary);
    cursor: pointer;
}

.ctx-menu__item:hover { background: var(--purple-light); color: var(--text-on-purple); }

/* ── Modals (create / copy-from) ─────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(51, 0, 76, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: 0 16px 48px rgba(51, 0, 76, 0.28);
    width: 100%;
    max-width: 420px;
    padding: 24px;
    /* Native <dialog open> UA resets: keep the flex-centred card layout. */
    position: static;
    margin: 0;
    border: 0;
    box-sizing: border-box;
    color: var(--text-primary);
}

.modal__title {
    margin: 0 0 16px;
    font-family: var(--font-brand);
    color: var(--purple-dark);
    font-size: 18px;
}

.modal__label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-brand);
    margin-bottom: 12px;
}

.modal__input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-top: 4px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--text-primary);
}

.modal__input:focus { border-color: var(--purple); outline: none; }

.modal__error {
    color: #b00020;
    font-size: 12px;
    margin-bottom: 12px;
}

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}

.modal__btn {
    background: var(--purple);
    color: var(--text-on-purple);
    border: 1px solid var(--purple);
    padding: 8px 16px;
    font-family: var(--font-brand);
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--border-radius);
}

.modal__btn:hover { background: var(--purple-dark); border-color: var(--purple-dark); }

.modal__btn--ghost {
    background: var(--bg-white);
    color: var(--purple-dark);
    border-color: var(--border);
}

.modal__btn--ghost:hover { background: var(--bg-light); color: var(--purple); }

/* ── Login landing ───────────────────────────────────────────────────────── */

.login-body {
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--purple-gradient-start), var(--purple-gradient-end));
    padding: 24px;
}

.login-card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: 0 16px 48px rgba(51, 0, 76, 0.3);
    width: 100%;
    max-width: 380px;
    padding: 36px 32px;
    text-align: center;
}

.login-card__brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.login-card__mark {
    width: 28px;
    height: 28px;
    background: var(--purple);
    border-radius: 50%;
    /* hosts an inline SVG: centre it + tint white inside the purple chip. */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-on-purple);
}

.login-card__title {
    font-family: var(--font-brand);
    font-size: 18px;
    color: var(--purple-dark);
    letter-spacing: 0.03em;
}

.login-card__lead { color: var(--text-muted); font-size: 13px; margin: 0 0 24px; }

.login-card__sso {
    display: block;
    background: var(--purple);
    color: var(--text-on-purple);
    text-decoration: none;
    padding: 12px 16px;
    font-family: var(--font-brand);
    font-size: 14px;
    border-radius: var(--border-radius);
}

.login-card__sso:hover { background: var(--purple-dark); text-decoration: none; color: var(--text-on-purple); }

.login-card__error {
    background: #fde8ea;
    color: #b00020;
    border: 1px solid #f3b6bd;
    padding: 10px 12px;
    font-size: 12px;
    margin-bottom: 16px;
    border-radius: var(--border-radius);
}

.login-card__hint { color: var(--text-muted); font-size: 11px; margin: 16px 0 0; }
.login-card__host { color: var(--text-muted); font-size: 11px; margin: 24px 0 0; font-family: var(--font-mono); }

/* ═══════════════════════════════════════════════════════════════════════════
   Blueprint node editor (canvas.js). A pannable/zoomable "world" layer holds an
   SVG connector layer behind absolutely-positioned node cards. Blender/Unreal-
   blueprint feel within the PurpleClear theme (sharp corners, purple accents).
   ═══════════════════════════════════════════════════════════════════════════ */

.planner-canvas:active { cursor: grabbing; }

.bp-world {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
}

.bp-edges {
    position: absolute;
    top: 0;
    left: 0;
    width: 6000px;
    height: 6000px;
    overflow: visible;
    pointer-events: none;
}

.bp-edge {
    fill: none;
    stroke: var(--purple);
    stroke-width: 2;
    opacity: 0.55;
}

.bp-cards { position: absolute; top: 0; left: 0; }

.bp-node {
    position: absolute;
    width: 240px;
    box-sizing: border-box;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-top: 4px solid var(--purple);
    box-shadow: 0 6px 18px rgba(51, 0, 76, 0.16);
    border-radius: var(--border-radius);
    font-size: 12px;
    cursor: pointer; /* grabbable card; :active shows grabbing, form controls reset to auto */
}

/* The card accent is tinted by node TYPE (the model classifies each child; the user
   may re-edit the type). A user-chosen colour overrides it inline via applyNodeColor. */
.bp-node--master    { border-top-color: var(--purple-dark); }
.bp-node--ad        { border-top-color: #2a7de1; }
.bp-node--post      { border-top-color: #1f9d6b; }
.bp-node--coop      { border-top-color: #d98a00; }
.bp-node--influencer{ border-top-color: #b5179e; }

.bp-node__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
}

.bp-node__type {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 10px;
    font-family: var(--font-brand);
    color: var(--purple-dark);
}

.bp-node__x {
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}
.bp-node__x:hover { color: #b00020; }

.bp-node__body { padding: 8px 10px; }
.bp-node__title { font-family: var(--font-brand); color: var(--purple-dark); font-size: 13px; word-break: break-word; }
.bp-node__desc {
    color: var(--text-muted);
    margin-top: 4px;
    max-height: 54px;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
}

.bp-node__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--border);
}

.bp-btn {
    background: var(--purple);
    color: var(--text-on-purple);
    border: 1px solid var(--purple);
    padding: 5px 10px;
    font-family: var(--font-brand);
    font-size: 11px;
    cursor: pointer;
    border-radius: var(--border-radius);
}
.bp-btn:hover { background: var(--purple-dark); border-color: var(--purple-dark); }

.bp-btn--ghost { background: var(--bg-white); color: var(--purple-dark); border-color: var(--border); }
.bp-btn--ghost:hover { background: var(--bg-light); color: var(--purple); }
.bp-btn--danger { color: #b3261e; border-color: #e6b4b0; }
.bp-btn--danger:hover { background: #fdecea; color: #8c1d18; border-color: #d99a95; }
.bp-btn--mini { padding: 3px 8px; font-size: 10px; }

.bp-panel {
    border-top: 1px solid var(--border);
    padding: 10px;
    background: var(--bg-light);
    max-height: 360px;
    overflow-y: auto;
}

.bp-field { margin-bottom: 8px; }
.bp-field__label {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-family: var(--font-brand);
    margin-bottom: 3px;
}

.bp-input {
    width: 100%;
    box-sizing: border-box;
    padding: 5px 7px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-primary);
    background: var(--bg-white);
}
.bp-input:focus { border-color: var(--purple); outline: none; }
.bp-input--area { resize: vertical; }

.bp-channels { display: flex; flex-wrap: wrap; gap: 6px; }
.bp-channels__item { font-size: 11px; color: var(--text-primary); display: inline-flex; align-items: center; }

.bp-image { display: flex; flex-direction: column; gap: 4px; }
.bp-image__status { font-size: 10px; color: var(--text-muted); }

.bp-search { border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 8px; }
.bp-search__results { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
.bp-search__status { font-size: 11px; color: var(--text-muted); }

.bp-result {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 6px 8px;
}
.bp-result__title { font-family: var(--font-brand); font-size: 11px; color: var(--purple-dark); word-break: break-word; }
.bp-result__handle { font-size: 10px; color: var(--purple); }
.bp-result__desc { font-size: 10px; color: var(--text-muted); margin: 3px 0 6px; word-break: break-word; }

.bp-addchild { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.bp-addchild .bp-input { flex: 1; }

/* ── Reference documents (per-node attachments) ──────────────────────────────── */

.bp-docs { border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 8px; }
.bp-docs__list { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.bp-docs__status { font-size: 11px; color: var(--text-muted); }

.bp-doc {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 4px 6px;
}
.bp-doc__name { font-size: 11px; color: var(--purple-dark); word-break: break-word; flex: 1; }
.bp-doc__size { font-size: 10px; color: var(--text-muted); }
.bp-doc__dl { font-size: 10px; color: var(--purple); text-decoration: none; }
.bp-doc__dl:hover { text-decoration: underline; }

/* Node cards advertise that their body can be grabbed and dragged. */
.bp-node:active { cursor: grabbing; }
.bp-node input, .bp-node textarea, .bp-node select, .bp-node button, .bp-node a, .bp-node label {
    cursor: auto;
}

/* ═══════════════════════════════════════════════════════════════════════════
   v2 UI (Phase 2e): view tabs, project split (canvas + right-side inspector),
   compact-card selection + completed graying, generate spinner, timeline Gantt.
   Appended after the user's hand-tuned rules — reuses the existing tokens above
   and never restructures earlier blocks.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── View tabs (Project | Timeline) in the topbar ─────────────────────────── */
.planner-tabs { display: flex; gap: 4px; margin: 0 auto 0 16px; }

.planner-tab {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-bottom: 2px solid transparent;
    padding: 6px 14px;
    font-family: var(--font-brand);
    font-size: 12px;
    cursor: pointer;
    border-radius: var(--border-radius);
}
.planner-tab:hover { color: var(--purple); }
.planner-tab--active {
    color: var(--purple-dark);
    border-bottom-color: var(--purple);
}

/* ── Project view split: canvas (flex) + inspector (fixed right) ──────────── */
.planner-view { flex: 1; display: flex; min-height: 0; overflow: hidden; }
.planner-view--project .planner-canvas { flex: 1; }

.planner-inspector {
    width: 340px;
    flex-shrink: 0;
    background: var(--bg-white);
    border-left: 1px solid var(--border);
    box-shadow: -6px 0 20px rgba(51, 0, 76, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.bp-insp__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
}
.bp-insp__type {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 11px;
    font-family: var(--font-brand);
    color: var(--purple-dark);
}
.bp-insp__close {
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}
.bp-insp__close:hover { color: var(--purple); }

.bp-insp__body { padding: 12px 14px; overflow-y: auto; flex: 1; }

.bp-insp__gen {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-light);
}
.bp-gen__status { font-size: 11px; color: var(--text-muted); }
.bp-insp__gen--busy .bp-gen__status::before {
    content: "";
    display: inline-block;
    width: 11px;
    height: 11px;
    margin-right: 5px;
    vertical-align: -1px;
    border: 2px solid var(--purple-light);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: bp-spin 0.7s linear infinite;
}
@keyframes bp-spin { to { transform: rotate(360deg); } }

.bp-btn:disabled { opacity: 0.6; cursor: default; }

.bp-completed { margin: 8px 0; }
.bp-completed__item {
    display: inline-flex;
    align-items: center;
    font-size: 12px;
    color: var(--text-primary);
    cursor: pointer;
}

/* ── Compact card: selected + completed treatments ────────────────────────── */
.bp-node--selected {
    border-color: var(--purple);
    box-shadow: 0 0 0 2px var(--purple-light), 0 6px 18px rgba(51, 0, 76, 0.22);
}
.bp-node--completed { opacity: 0.62; }
.bp-node--completed:hover { opacity: 0.85; }

/* Focus mode: descendants of a node whose "dim children" toggle is on fade right
   back so the user can concentrate on the node they are working on. Hover lifts them
   enough to read/click without turning the focus mode off. */
.bp-node--dimmed { opacity: 0.1; transition: opacity 0.15s ease; }
.bp-node--dimmed:hover { opacity: 0.85; }
.bp-node__done {
    font-size: 10px;
    color: #1f9d6b;
    font-family: var(--font-brand);
    letter-spacing: 0.04em;
}

/* ── Timeline (Gantt) view ────────────────────────────────────────────────── */
.planner-view--timeline { display: flex; }
.planner-timeline {
    flex: 1;
    overflow: auto;
    padding: 16px;
    background: var(--bg-light);
}

.tl-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.tl-status { font-size: 11px; color: var(--text-muted); }

.tl-empty { color: var(--text-muted); font-size: 13px; padding: 12px 0; }

.tl-fieldlabel {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    font-family: var(--font-brand);
}

.tl-input {
    padding: 5px 7px;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    font-family: var(--font-body);
    font-size: 12px;
    color: var(--text-primary);
    background: var(--bg-white);
}
.tl-input:focus { border-color: var(--purple); outline: none; }
.tl-input--dur { width: 64px; }

/* Rows take their CONTENT width (label + full-span track) rather than stretching to
   the viewport, and the gantt scrolls horizontally so a bar scheduled far to the
   right stays reachable instead of being clipped at the window edge. */
.tl-gantt { display: flex; flex-direction: column; gap: 6px; overflow-x: auto; align-items: flex-start; }

.tl-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 8px 10px;
}
.tl-row__label { width: 200px; flex-shrink: 0; }
.tl-row__title {
    font-family: var(--font-brand);
    font-size: 12px;
    color: var(--purple-dark);
    word-break: break-word;
}
/* The title is a button that opens the node in the project editor. Reset the native
   button chrome so it reads as text, but keep a pointer + hover underline as an
   affordance that it is clickable. */
.tl-row__title--link {
    display: block;
    width: 100%;
    padding: 0;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
}
.tl-row__title--link:hover { text-decoration: underline; }
.tl-row__title--link:focus-visible { outline: 2px solid var(--purple); outline-offset: 2px; }
.tl-row__dates { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.tl-row__controls { display: flex; gap: 8px; flex-shrink: 0; }

.tl-row__track {
    position: relative;
    flex: 0 0 auto; /* respect the JS-set width (= full timeline span), don't grow/shrink to the viewport */
    min-width: 120px;
    height: 22px;
    background:
        repeating-linear-gradient(90deg, transparent 0 23px, rgba(66, 33, 134, 0.06) 23px 24px);
    border-left: 1px solid var(--border);
}
.tl-bar {
    position: absolute;
    top: 3px;
    height: 16px;
    background: var(--purple);
    border-radius: var(--border-radius);
    opacity: 0.82;
    cursor: grab;
    touch-action: none;
    overflow: hidden;
}

/* ── Minute-based hierarchical timeline (Purple Planner) ───────────────────────
   Appended for the minute-based, draggable, hierarchical timeline: a per-row
   own/total summary, workday gridlines on the minute track, a darker leading
   "own-time" slice on each group bar, and a grab cursor / dragging state on the
   draggable group bars. Append-only; nothing above is modified. */

.tl-row__times { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* A faint vertical rule at each workday boundary, with a small day label. */
.tl-grid {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dashed rgba(66, 33, 134, 0.18);
    pointer-events: none;
}
.tl-grid__label {
    position: absolute;
    top: -1px;
    left: 2px;
    font-size: 9px;
    color: var(--text-muted);
}

/* The group bar is draggable (cursor/grab merged into the .tl-bar rule above); the
   leading slice marks the node's OWN time, the rest is the rolled-up children. */
.tl-bar--dragging { cursor: grabbing; opacity: 1; box-shadow: 0 0 0 2px var(--purple-dark); }
.tl-bar__own {
    height: 100%;
    background: var(--purple-dark);
    border-radius: var(--border-radius) 0 0 var(--border-radius);
    opacity: 0.9;
}

/* ── Radial canvas: node pop-in, working spinner, global Abort, toast ──────────
   Appended for the radial layout + async-generation UX (pop-in on freshly
   generated nodes, a per-node ⟳ working spinner, and a global Abort button while
   a generation job runs). Append-only; nothing above is modified. */

/* One-shot entrance animation: a freshly-appeared node scales up from 0.85 and
   fades in (~250ms) so a newly-generated card visibly "lands". */
@keyframes bp-popin {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}
.bp-node--popin {
    animation: bp-popin 250ms ease-out both;
}

/* Per-node working spinner shown next to the title of a node the background build
   is currently expanding (driven by active_node_ids). */
@keyframes bp-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.bp-node__spin {
    display: inline-block;
    margin-left: 6px;
    color: var(--purple);
    font-weight: 700;
    animation: bp-spin 1s linear infinite;
}

/* Global Abort button: a top-menu control (in #canvas-actions), visible only while
   a generation job is running. */
.bp-abort {
    padding: 6px 12px;
    background: #b3261e;
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-brand);
    font-size: 13px;
    cursor: pointer;
}
.bp-abort:hover { background: #951c16; }
.bp-abort:disabled { opacity: 0.6; cursor: default; }

/* Brief auto-dismissing toast (e.g. "Generation stopped"). */
.bp-toast {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 21;
    padding: 8px 16px;
    background: var(--purple-dark);
    color: #fff;
    border-radius: var(--border-radius);
    font-size: 13px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Reorganize button: a top-menu control (in #canvas-actions), visible whenever a
   version is loaded. Clicking it re-applies the radial star layout to every node
   and persists the result. */
.bp-reorganize {
    padding: 6px 12px;
    background: var(--purple);
    color: #fff;
    border: none;
    border-radius: var(--border-radius);
    font-family: var(--font-brand);
    font-size: 13px;
    cursor: pointer;
}
.bp-reorganize:hover { background: var(--purple-dark); }
.bp-reorganize:disabled { opacity: 0.6; cursor: default; }

/* Top-menu "Dim children" toggle — a lighter, outlined sibling of Reorganize that
   only appears while a node is selected, fading that node's descendants for focus. */
.bp-dim-children {
    padding: 6px 12px;
    background: #fff;
    color: var(--purple-dark);
    border: 1px solid var(--purple);
    border-radius: var(--border-radius);
    font-family: var(--font-brand);
    font-size: 13px;
    cursor: pointer;
}
.bp-dim-children:hover { background: var(--purple); color: #fff; }

/* ── FEATURE 1 (#12): `text` content node — the detailed post-plan deliverable ──
   A distinct teal-violet card accent + a short single-line description snippet on
   the card. The full plan is edited in the inspector's large textarea (below).
   Appended (append-only CSS); the existing per-type accents are untouched. */
.bp-node--text { border-top-color: #6f42c1; }
.bp-node__snippet {
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.35;
    word-break: break-word;
}

/* The text node's inspector deliverable textarea: a tall editing surface the user
   copies the plan out of. rows=16 is set in JS; this scopes the extra height to the
   text deliverable only (the base .bp-input--area rule at the top is untouched). */
.bp-insp__body textarea.bp-input--area[rows="16"] {
    min-height: 260px;
    font-family: var(--font-brand);
    line-height: 1.5;
}

/* ── FEATURE 2 (#13): clickable influencer links (http(s)-only, new tab) ───────
   The small "open ↗" affordance on an influencer/search card and the inspector
   link rows. Links are http(s)-only (safeHref) and open in a new tab. */
.bp-node__open,
.bp-result__open {
    display: inline-block;
    margin-top: 4px;
    font-size: 10px;
    color: var(--purple);
    text-decoration: none;
}
.bp-node__open:hover,
.bp-result__open:hover { color: var(--purple-dark); text-decoration: underline; }

.bp-insp__links { display: flex; flex-direction: column; gap: 4px; }
.bp-linkrow { font-size: 12px; word-break: break-all; }
.bp-linkrow__label { color: var(--text-muted); }
.bp-link { color: var(--purple); text-decoration: none; }
.bp-link:hover { color: var(--purple-dark); text-decoration: underline; }
.bp-insp__nolink { font-size: 12px; color: var(--text-muted); font-style: italic; }

/* ── FEATURE 3 (#14): per-node "Max child nodes" control (default 10) ──────────
   A compact number input + hint shown above the Generate button in the inspector
   generate row. */
.bp-maxchildren {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
}
.bp-maxchildren__label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.bp-input--num { width: 80px; }
.bp-maxchildren__hint { font-size: 10px; color: var(--text-muted); font-style: italic; }

/* ── Planning UI: card meta chips, inspector planning controls, post channel ────
   Appended for the priority/time-needed/channel pass. The inspector gains a
   Priority (1=highest..5) picker and a Time-needed (30-minute-step) number input,
   and each non-master card shows a compact meta row of channel / priority / time
   chips. Append-only; reuses the existing tokens, nothing above is restructured. */

/* Per-card meta row under the title: a horizontal strip of small chips. */
.bp-node__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
}
.bp-node__meta:empty { display: none; }

/* Channel pill (posts only) — read from payload_json.channel, set via textContent. */
.bp-node__chan {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: var(--font-brand);
    color: var(--purple-dark);
    background: var(--purple-light);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 1px 6px;
}

/* Priority badge P1..P5 — the level drives the colour (P1 hottest → P5 coolest). */
.bp-node__prio {
    font-size: 9px;
    font-family: var(--font-brand);
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #fff;
    border-radius: var(--border-radius);
    padding: 1px 6px;
}
.bp-node__prio--p1 { background: #b3261e; }
.bp-node__prio--p2 { background: #d98a00; }
.bp-node__prio--p3 { background: #7a6f00; }
.bp-node__prio--p4 { background: #2a7de1; }
.bp-node__prio--p5 { background: #5a6470; }

/* Time-needed chip (e.g. "1h" / "90m"). */
.bp-node__time {
    font-size: 9px;
    font-family: var(--font-brand);
    color: var(--text-muted);
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    padding: 1px 6px;
}

/* Inspector planning row: Priority picker + Time-needed input stacked as fields. */
.bp-planning { display: flex; flex-direction: column; gap: 0; }
.bp-input--priority { width: 100px; }
.bp-input--time { width: 110px; }

/* Read-only rolled-up group-total line under the editable own-time field. */
.bp-grouptotal {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

/* Post node channel read-only display in the inspector. */
.bp-insp__channel {
    font-size: 12px;
    font-family: var(--font-brand);
    color: var(--purple-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Promotion→post links (drawEdges): dashed accent so a viewer sees what
   promotes which post, distinct from the solid structural parent edges. */
.bp-edge--promo {
    stroke: #d98a00;
    stroke-width: 2;
    stroke-dasharray: 7 5;
    opacity: 0.85;
}

/* ── Multi-node group cards + the inspector "Add group" control ────────────────
   A `group` container card gets its own neutral-purple accent (distinct from the
   item types), and the inspector Add-group row mirrors the Add-child layout with a
   small explanatory hint about empty-description groups inheriting the parent's
   context. Append-only; the existing per-type accents and add-child rules untouched. */
.bp-node--group { border-top-color: #8e7cc3; }
.bp-addgroup { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.bp-addgroup .bp-input { flex: 1; }
.bp-addgroup__hint {
    flex-basis: 100%;
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.35;
}

/* ═══════════════════════════════════════════════════════════════════════════
   v3 universal redesign (Wave E): "Purple Planner" branding, tree icons/carets,
   contextual top-menu action toolbar, collapsible panels with edge tabs, the top
   progress bar, multi-select rings, the universal-node inspector (colour picker +
   swatches, multi-image grid) and the Settings / Share modal extras. Append-only;
   reuses the existing PurpleClear tokens, nothing above is restructured.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Branding: white-bg / purple logotype in the tree header (matches the shared
   viewer's Purple Planner logo — purple text on white, not white on purple). ── */
.planner-brand { display: inline-flex; align-items: center; gap: 8px; }
.planner-brand__mark { display: inline-flex; align-items: center; color: var(--purple); }
.planner-brand__name {
    font-family: var(--font-brand);
    font-size: 15px;
    letter-spacing: 0.5px;
    color: var(--purple-dark);
}

/* The login mark hosts an inline SVG now (was a solid dot); flex-centring is merged
   into the base .login-card__mark rule above. */
.login-card__mark svg { display: block; }

/* ── Real tree look: indent guide rails + expand/collapse carets + kind icons ─── */
/* (.tree-item row metric merged into its base rule above.) */
/* Neutralise the v1 per-kind left padding now that guides handle indentation. */
.tree-item--brand,
.tree-item--project,
.tree-item--version { padding-left: 4px; }
.tree-item--brand .tree-item__label { font-weight: 600; }
.tree-item--version .tree-item__label { color: var(--text-muted); }

.tree-item__label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }

.tree-guides { display: inline-flex; flex-shrink: 0; }
.tree-guide {
    display: inline-block;
    width: 16px;
    align-self: stretch;
    border-left: 1px solid var(--border);
    margin-left: 7px;
}

.tree-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--text-muted);
    cursor: pointer;
    transition: transform 0.12s ease;
}
.tree-caret svg { display: block; }
.tree-caret--collapsed { transform: none; }
.tree-caret:not(.tree-caret--collapsed):not(.tree-caret--leaf) { transform: rotate(90deg); }
.tree-caret--leaf { cursor: default; }
.tree-caret:hover:not(.tree-caret--leaf) { color: var(--purple); }

.tree-icon { display: inline-flex; align-items: center; flex-shrink: 0; }
.tree-icon svg { display: block; }
.tree-icon--brand { color: var(--purple-dark); }
.tree-icon--project { color: var(--purple); }
.tree-icon--version { color: var(--purple); }
.tree-item--active .tree-icon { color: var(--purple-dark); }

/* ── Contextual top-menu action toolbar ──────────────────────────────────────── */
.planner-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
}
.planner-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--purple-dark);
    cursor: pointer;
    border-radius: var(--border-radius);
}
.planner-action:hover { background: var(--purple-light); color: var(--text-on-purple); border-color: var(--purple-light); }
.planner-action__icon { display: inline-flex; }
.planner-action__icon svg { display: block; }

/* ── Comment notifications: bell badge + dropdown panel ───────────────────────
   The bell is a normal .planner-action; the unseen-count badge floats on its
   top-right corner (so .planner-action is positioned relative just for the bell).
   The panel is a fixed dropdown anchored under the top bar's right edge. */
#notif-bell { position: relative; }
.notif-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 15px;
    height: 15px;
    padding: 0 3px;
    border-radius: 8px;
    background: #c0392b;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 15px;
    text-align: center;
    box-sizing: border-box;
}
.notif-panel {
    position: fixed;
    top: 52px;
    right: 12px;
    width: 320px;
    max-height: 60vh;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 28px rgba(66, 33, 134, 0.18);
    z-index: 60;
}
.notif-panel__head {
    padding: 10px 12px;
    font-family: var(--font-brand);
    font-weight: 600;
    color: var(--purple-dark);
    border-bottom: 1px solid var(--border);
}
.notif-panel__empty { padding: 16px 12px; color: var(--text-muted); font-size: 13px; }
.notif-row {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    text-align: left;
    cursor: pointer;
}
.notif-row:hover { background: var(--purple-light); }
.notif-row__who { font-size: 12px; font-weight: 600; color: var(--purple-dark); }
.notif-row__where { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.notif-row__body {
    font-size: 12px;
    color: var(--text);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}
.planner-action__sep {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 6px;
    flex-shrink: 0;
}

/* ── Collapsible panels + edge tabs ──────────────────────────────────────────── */
.planner-panel--collapsed { display: none !important; }

/* The edge tabs anchor to these containers (the left tab to the whole shell — see
   .planner-shell above — the right tab to the project view), riding the panel borders. */
.planner-view--project { position: relative; }

.panel-edge {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 30;
    width: 16px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-white);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(51, 0, 76, 0.12);
}
.panel-edge:hover { color: var(--purple); }
.panel-edge svg { display: block; }
/* Open: the tab rides the tree/canvas BORDER (where a collapse handle is expected,
   not lost against the window's far-left edge). Collapsed: it sits at left:0 so the
   hidden tree can be re-opened. */
.panel-edge--left { left: calc(var(--sidebar-width) - 8px); border-left: none; }
.panel-edge--left.panel-edge--collapsed { left: 0; }
.panel-edge--right { right: 0; border-right: none; }
/* Chevron points "inward" (toward collapse) when open, "outward" when collapsed. */
.panel-edge--left svg { transform: rotate(180deg); }
.panel-edge--left.panel-edge--collapsed svg { transform: none; }
.panel-edge--right.panel-edge--collapsed svg { transform: rotate(180deg); }

/* ── Top progress bar (YouTube-style red bar across the top frame border) ─────── */
.planner-progress {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 100;
    background: transparent;
    overflow: hidden;
    pointer-events: none;
}
.planner-progress__bar {
    height: 100%;
    width: 0;
    background: #e53935;
    box-shadow: 0 0 6px rgba(229, 57, 53, 0.6);
    transition: width 0.4s ease;
}
.planner-progress__bar--indeterminate {
    width: 40% !important;
    transition: none;
    animation: pp-progress-slide 1.1s ease-in-out infinite;
}
@keyframes pp-progress-slide {
    0%   { transform: translateX(-110%); }
    100% { transform: translateX(280%); }
}

/* ── Multi-select rings (.bp-node--selected defined above; anchor ring here) ──── */
.bp-node--anchor {
    box-shadow: 0 0 0 3px var(--purple), 0 6px 18px rgba(51, 0, 76, 0.26);
}

/* Universal-node accent (the default v3 node kind). */
.bp-node--node { border-top-color: var(--purple); }

/* ── Inspector: colour picker + swatches ──────────────────────────────────────── */
.bp-color { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.bp-color__picker {
    width: 42px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    background: var(--bg-white);
    cursor: pointer;
}
.bp-color__swatches { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.bp-swatch {
    width: 18px;
    height: 18px;
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 0;
    border-radius: var(--border-radius);
}
.bp-swatch:hover { outline: 2px solid var(--purple-light); }
.bp-swatch--clear {
    background:
        linear-gradient(45deg, transparent 45%, #b3261e 45%, #b3261e 55%, transparent 55%),
        var(--bg-white);
}

/* ── Inspector: multiple images (thumbnail grid) ──────────────────────────────── */
.bp-images { border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 8px; }
.bp-images__status { font-size: 11px; color: var(--text-muted); }
.bp-images__grid {
    margin-top: 6px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 6px;
}
.bp-thumb {
    position: relative;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--border);
    background: var(--bg-light);
    overflow: hidden;
}
.bp-thumb__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bp-thumb__x {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    line-height: 14px;
    border: none;
    background: rgba(51, 0, 76, 0.7);
    color: #fff;
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--border-radius);
}
.bp-thumb__x:hover { background: #b3261e; }

/* Max-children field uses the standard field layout; widen its number input. */
.bp-maxchildren .bp-input--num { width: 120px; }

/* ── Modal extras: hint text, mini buttons, settings + share rows ─────────────── */
.modal__hint { font-size: 11px; color: var(--text-muted); margin: -4px 0 12px; line-height: 1.4; }
.modal__btn--mini { padding: 6px 10px; font-size: 12px; }

.share-list { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 16px; }
.share-row { display: flex; align-items: center; gap: 6px; }
.share-row__url { flex: 1; font-family: var(--font-mono); font-size: 12px; }
.share-empty { font-size: 12px; color: var(--text-muted); margin: 0 0 8px; }

/* ── Plan import / export ─────────────────────────────────────────────────────
   Export + Import sit in the top canvas-actions bar beside Reorganize; the import
   modal reuses the shared .modal styling with a wider body for the JSON textarea.
   Appended (never restructured) per the project's CSS-ownership convention. */
.bp-plan-btn { margin-left: 6px; }
.modal--wide { width: min(640px, 92vw); }
.import-modes { display: flex; gap: 16px; margin-top: 6px; font-weight: normal; }
.import-modes label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.import-json {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 12px;
    resize: vertical;
    min-height: 160px;
}
.import-tools { display: flex; gap: 8px; margin: 8px 0 4px; }
