/* ==========================================================================
   Doodle Desk — styles
   App chrome: dark, purple accent. Board: white whiteboard in an aluminium
   frame with marker tray, hand-drawn marker lettering and highlights.
   ========================================================================== */
:root {
  /* chrome */
  --c-bg: #17151d;
  --c-bar: #1e1b26;
  --c-panel: #1f1c28;
  --c-card: #282433;
  --c-line: #332e40;
  --c-text: #ece9f3;
  --c-dim: #9d97ad;
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, .18);
  --canvas: #34323b;
  /* board */
  --ink: #1d1f23;
  --ink-soft: #5d626b;
  /* Shantell Sans is drawn from marker handwriting; the INFM axis adds felt-tip wobble */
  --hand: 'Shantell Sans', 'Segoe Print', 'Comic Sans MS', 'Chalkboard SE', cursive;
  --marker: var(--hand);
  --ink-line: rgba(28, 30, 34, .92);
  --surface: #fafaf8;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --r-card: 18px 14px 20px 15px / 15px 20px 14px 18px;
  --r-sub: 13px 10px 14px 11px / 11px 14px 10px 13px;
  --iz: 1;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font-family: var(--ui); color: var(--c-text); background: var(--c-bg); -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
svg { display: block; }
kbd { font: 600 10.5px var(--ui); color: var(--c-dim); background: rgba(255,255,255,.06); border: 1px solid var(--c-line); border-radius: 4px; padding: 1px 5px; white-space: nowrap; }

.app {
  --panel-w: 320px;
  display: grid; height: 100vh; height: 100dvh;
  grid-template-columns: 56px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "top top" "rail canvas" "status status";
}

/* ---------- top bar ---------- */
.topbar {
  grid-area: top; display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top));
  background: var(--c-bar); border-bottom: 1px solid var(--c-line); z-index: 30; min-width: 0;
}
.topbar > button { flex: none; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; white-space: nowrap; margin-right: 6px; }
.logo img { width: 34px; height: 27px; display: block; object-fit: contain; }
.logo span { font-family: var(--hand); font-weight: 430; font-variation-settings: 'INFM' 25, 'BNCE' 0; font-size: 19px; color: #ece8f4; }
.logo { background: none; border: 0; padding: 4px 6px 4px 2px; border-radius: 8px; cursor: pointer; }
.logo:hover { background: rgba(255,255,255,.05); }
.logo .chev { width: 15px; height: 15px; fill: none; stroke: #9d97ad; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; margin-left: 2px; }
.pill {
  display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 300px;
  background: var(--c-card); border: 1px solid var(--c-line); border-radius: 9px; padding: 6px 12px; cursor: pointer; font-size: 13px;
}
.pill:hover { border-color: #4a4458; }
.pill svg { width: 18px; height: 18px; flex: none; fill: none; stroke: #4ade80; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--c-card); border: 1px solid var(--c-line); border-radius: 9px;
  padding: 6px 10px; min-height: 32px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.tb-btn:hover { background: #312c3d; }
.tb-btn:disabled { opacity: .35; cursor: default; background: var(--c-card); }
.tb-btn.icon { width: 34px; padding: 0; }
.tb-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tb-btn circle { fill: currentColor; stroke: none; }
.tb-btn .chev { width: 13px; height: 13px; opacity: .7; }
.tb-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 18px; }
.tb-btn[aria-pressed="false"] { color: var(--c-dim); }
.show-sm { display: none !important; }

/* ---------- status bar ---------- */
.statusbar {
  grid-area: status; display: flex; align-items: center; gap: 6px;
  padding: 4px 12px; padding-bottom: max(4px, env(safe-area-inset-bottom));
  background: var(--c-bar); border-top: 1px solid var(--c-line); z-index: 30; min-width: 0;
}
.statusbar .tb-btn { min-height: 26px; font-size: 12px; }

/* ---------- tool rail ---------- */
.rail {
  grid-area: rail; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 0; background: var(--c-bar); border-right: 1px solid var(--c-line); overflow-y: auto; z-index: 20;
}
.rail-btn {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  background: none; border: 1px solid transparent; border-radius: 10px; cursor: pointer; color: #d8d3e4;
}
.rail-btn:hover { background: #2b2736; }
.rail-btn svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-btn circle { fill: currentColor; stroke: none; }
.rail-btn.on { border-color: var(--accent); background: var(--accent-soft); color: #fff; }
.rail-btn.add { background: var(--accent); color: #fff; }
.rail-btn.add:hover { background: #7c4ef0; }
.rail-sep { width: 24px; height: 1px; background: var(--c-line); margin: 4px 0; flex: none; }

/* ---------- popovers ---------- */
.pop {
  position: fixed; z-index: 100; display: none; min-width: 220px; max-width: calc(100vw - 16px); max-height: 80vh; overflow: auto;
  background: var(--c-panel); border: 1px solid var(--c-line); border-radius: 12px; padding: 6px;
  box-shadow: 0 18px 40px rgba(0,0,0,.45); color: var(--c-text);
}
.pop.open { display: block; }
.pop hr { border: 0; border-top: 1px solid var(--c-line); margin: 5px 4px; }
.pop-item {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%;
  background: none; border: 0; border-radius: 8px; padding: 8px 10px; font-size: 13px; text-align: left; cursor: pointer;
}
.pop-item:hover, .pop-item:focus-visible { background: #2c2838; outline: none; }
.pop-item.danger { color: #ff8080; }
#board-pop .pop-item { justify-content: flex-start; gap: 10px; }
#board-pop .pop-item svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
#board-pop .pop-item:hover svg, #board-pop .pop-item:focus-visible svg { opacity: 1; }
#add-pop { width: 340px; }
.add-item { display: flex; gap: 10px; align-items: flex-start; justify-content: flex-start; }
.mi-icon { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 8px; background: #2c2838; font-size: 15px; color: #d8d3e4; }
.mi-desc { display: block; color: var(--c-dim); font-size: 12px; margin-top: 2px; line-height: 1.35; }

/* ---------- canvas ---------- */
.viewport {
  grid-area: canvas; position: relative; overflow: hidden; outline: none; touch-action: none;
  background-color: var(--canvas);
  background-image: radial-gradient(circle, rgba(255,255,255,.055) 1px, transparent 1.4px);
}
.viewport.tool-hand, .viewport.space { cursor: grab; }
.viewport.panning, .viewport.panning * { cursor: grabbing !important; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; user-select: none; -webkit-user-select: none; }

/* the physical whiteboard: brushed aluminium rails, molded corner caps, glossy surface, marker tray */
.frame { position: absolute; left: 0; top: 0; pointer-events: none; }
.fr-shadow { position: absolute; inset: -18px; border-radius: 6px; box-shadow: 0 0 34px rgba(0,0,0,.24), 0 22px 42px rgba(0,0,0,.34); }
.fr-surface {
  position: absolute; inset: 0;
  background: var(--surface); /* flat: light variation comes from the gloss overlay drawn above everything */
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.22), inset 0 3px 6px rgba(0,0,0,.12), inset 0 -1px 2px rgba(0,0,0,.08);
}
.fr-rail { position: absolute; }
.fr-rail::after { /* brushed-metal grain */
  content: ''; position: absolute; inset: 0; opacity: .5;
  background: linear-gradient(var(--grain, 90deg), rgba(255,255,255,.0) 0%, rgba(255,255,255,.35) 22%, rgba(255,255,255,0) 40%, rgba(255,255,255,.25) 63%, rgba(255,255,255,0) 85%);
}
.fr-top, .fr-bot { left: 0; right: 0; height: 18px; --grain: 90deg; }
.fr-top { top: -18px; border-radius: 5px 5px 0 0; background: linear-gradient(180deg, #8f949b 0%, #f7f8f9 14%, #e4e6e9 40%, #c3c7cc 72%, #aeb3b9 92%, #7f848b 100%); }
.fr-bot { bottom: -18px; border-radius: 0 0 5px 5px; background: linear-gradient(0deg, #6f747b 0%, #a9aeb4 10%, #d3d6da 45%, #eef0f1 78%, #9a9fa6 100%); }
.fr-left, .fr-right { top: 0; bottom: 0; width: 18px; --grain: 0deg; }
.fr-left { left: -18px; background: linear-gradient(90deg, #858a91 0%, #eceef0 18%, #d8dbde 50%, #b7bbc1 82%, #8c9197 100%); }
.fr-right { right: -18px; background: linear-gradient(270deg, #7c8188 0%, #e2e4e7 18%, #ccd0d4 50%, #adb2b8 82%, #8a8f96 100%); }
.fr-cap { position: absolute; width: 58px; height: 58px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); background: url(assets/corner-cap.svg) center / 100% 100% no-repeat; }
.fr-cap.tl { left: -20px; top: -20px; }
.fr-cap.tr { right: -20px; top: -20px; transform: rotate(90deg); }
.fr-cap.br { right: -20px; bottom: -20px; transform: rotate(180deg); }
.fr-cap.bl { left: -20px; bottom: -20px; transform: rotate(270deg); }
.sheen { position: absolute; left: 0; top: 0; pointer-events: none; background: url(assets/surface-sheen.svg) center / 100% 100% no-repeat; opacity: .9; }
.tray {
  position: absolute; height: 22px; pointer-events: auto; border-radius: 2px 2px 8px 8px;
  background: linear-gradient(180deg, #7d828a 0%, #f2f3f4 12%, #d9dcdf 45%, #b4b8be 80%, #80858c 100%);
  box-shadow: 0 10px 18px rgba(0,0,0,.45), 0 2px 3px rgba(0,0,0,.3);
  display: flex; align-items: flex-end; gap: 26px; padding: 0 44px;
}
.tray::before { content: ''; position: absolute; left: 6px; right: 6px; top: 3px; height: 4px; border-radius: 3px; background: linear-gradient(180deg, rgba(0,0,0,.28), rgba(0,0,0,0)); }
.marker {
  position: relative; width: 226px; height: auto; aspect-ratio: 260 / 44; flex: 0 1 226px !important; min-width: 0; margin-bottom: 9px; border: 0; padding: 0; cursor: pointer;
  background: var(--img) center / 100% 100% no-repeat; transition: transform .15s ease-out; flex: none;
}
.marker:hover { transform: translateY(-5px) rotate(-1.5deg); }
.marker:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.eraser { flex: 0 1 150px; min-width: 0; width: 150px; height: auto; aspect-ratio: 170 / 52; margin: 0 0 8px auto; background: url(assets/eraser.svg) center / 100% 100% no-repeat; }

/* ---------- widgets ---------- */
.widget {
  position: absolute; color: var(--ink); font-family: var(--hand); cursor: grab; touch-action: none;
  font-weight: 460; font-variation-settings: 'INFM' 70, 'BNCE' 10;
  --edge: var(--ink);
}
.widget.ol-color { --edge: var(--line); }
.fit { position: absolute; inset: 0; z-index: 0; overflow: hidden; padding: .6em .85em; line-height: 1.2; font-size: 16px; overflow-wrap: break-word; }
.fit.overflowing { overflow: auto; }

.t-target, .t-list, .t-category, .t-week, .t-note { border-radius: var(--r-card); }
/* box fill only; the outline is a generated marker stroke (svg.sk, see sketch.js) */
.t-target > .fit::before, .t-list > .fit::before, .t-category > .fit::before, .t-week > .fit::before {
  content: ''; position: absolute; inset: 3px; z-index: -1; pointer-events: none;
  border-radius: var(--r-card); background: var(--box-fill);
}
.sk { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: -1; }
.sk:not(.inked) path { fill: none; stroke: var(--edge); stroke-width: 2.8; stroke-linecap: round; stroke-linejoin: round; }
.sub > .sk:not(.inked) path, .day > .sk:not(.inked) path { stroke: var(--ink-line); stroke-width: 2.4; }
.sk.inked { color: var(--edge); }               /* textured ink fragments draw in currentColor */
.sub > .sk.inked, .day > .sk.inked { color: var(--ink-line); }
.sub > .sk, .day > .sk { z-index: 0; }
.widget { --box-fill: color-mix(in srgb, #fff 40%, var(--surface)); }
.widget:not(.ol-color) { --edge: var(--ink-line); }
.t-category.ol-color { --box-fill: color-mix(in srgb, var(--hl) 10%, var(--surface)); }
.t-note { background: color-mix(in srgb, var(--hl) 60%, #fff); box-shadow: 3px 5px 0 rgba(0,0,0,.07); }
/* section titles that sit ON the top line, like the mockup (Rilla Studios, Daily Wins, This Week) */
.t-category > .fit, .t-week > .fit { padding-top: 0; }
.t-category > .fit::before, .t-week > .fit::before { top: .68em; }
.t-category > .fit > .sk, .t-week > .fit > .sk { top: .68em; height: calc(100% - .68em); }
.t-category .w-head, .t-week .w-head { width: fit-content; max-width: 100%; margin: 0 auto .4em; padding: 0 .35em; position: relative; }
.t-target > .fit { padding-top: 0; }
.t-target > .fit::before { top: .62em; }
.t-target > .fit > .sk { top: .62em; height: calc(100% - .62em); }
.t-target .tgt-head { white-space: nowrap; width: fit-content; max-width: 100%; margin: 0 0 .2em .2em; padding: 0 .2em; }

/* chrome on cards: drag dots + more menu, as in the mockup */
.w-dots, .w-more {
  position: absolute; top: 4px; z-index: 2; opacity: 0; transition: opacity .12s;
  font: 700 14px/1 var(--ui); color: #555a62; background: none; border: 0; padding: 4px 6px; border-radius: 6px;
}
.w-dots { left: 6px; pointer-events: none; letter-spacing: -1px; }
.w-more { right: 6px; cursor: pointer; }
.w-more:hover { background: rgba(0,0,0,.06); }
.widget:hover > .w-dots, .widget:hover > .w-more, .widget.selected > .w-dots, .widget.selected > .w-more { opacity: .85; }
.t-header > .w-dots, .t-header > .w-more { display: none; }
@media (hover: none) { .widget.selected > .w-more { opacity: 1; } }

/* marker highlight behind text */
.hl { position: relative; z-index: 0; display: inline-block; max-width: 100%; padding: .07em .45em .05em; margin: 0 -.12em; }
.hl::before { /* chisel-tip highlighter swipe */
  content: ''; position: absolute; inset: 0 -.08em; z-index: -1; pointer-events: none;
  background: var(--hl); opacity: .92;
  -webkit-mask: url(assets/highlight.svg) 0 0 / 100% 100% no-repeat; mask: url(assets/highlight.svg) 0 0 / 100% 100% no-repeat;
}

/* sparkle / burst marks (three strokes) */
.spark {
  display: block; width: .8em; height: 1.05em; flex: none; background: var(--spark-ink, var(--ink-line));
  -webkit-mask: url(assets/spark.svg) center / 100% 100% no-repeat; mask: url(assets/spark.svg) center / 100% 100% no-repeat;
}
.spark.r { transform: scaleX(-1); }

/* header */
.t-header .fit { display: flex; flex-direction: column; padding: .08em .3em; }
.hdr { margin: auto 0; text-align: center; }
.hdr-row { display: flex; align-items: center; justify-content: center; gap: .3em; }
.hdr-row { gap: .22em; }
.hdr-row .spark { --spark-ink: var(--line); width: .78em; height: 1.05em; }
.hdr-title { font-weight: 600; font-size: 1em; margin: 0; line-height: 1.12; min-width: 0; text-transform: uppercase; letter-spacing: .01em; }
.uline {
  display: block; width: 78%; height: .42em; margin: -.06em auto -.08em; background: var(--line);
  -webkit-mask: url(assets/underline.svg) 0 0 / 100% 100% no-repeat; mask: url(assets/underline.svg) 0 0 / 100% 100% no-repeat;
}
.hdr-sub { font-size: .3em; color: var(--ink-soft); margin-top: .25em; }

/* shared heading styles */
.caps { text-transform: uppercase; letter-spacing: .02em; }
.w-head, .tgt-head, .tgt-goal, .sub-head, .day-l, .now, .st-stage .mark, .fld-l { font-weight: 600; }
.w-head { display: flex; align-items: center; justify-content: center; gap: .3em; text-align: center; font-size: 1.2em; line-height: 1.12; margin: .05em 0 .45em; }

/* target card */
.tgt-head { font-size: 1em; margin: .05em 0 .2em .1em; }
.tgt-goal { font-size: 1.15em; line-height: 1.12; margin: .15em 0 .25em .15em; }
.tgt .items { font-size: .92em; }

/* category container + subcategory cards */
.subs { display: flex; flex-wrap: wrap; gap: .7em; align-items: stretch; min-height: 2.2em; }
.sub {
  position: relative; flex: var(--grow, 1) 1 8.5em; min-width: 0; display: flex; flex-direction: column;
  border-radius: var(--r-sub); background: rgba(255,255,255,.7); padding: .5em .65em .55em;
}

.sub-head { font-size: .98em; line-height: 1.15; margin: 0 0 .35em; text-align: center; padding: 0 .5em; }
.sub-head .hl { padding: .02em .45em; }
.blk { position: relative; }
.blk + .blk { margin-top: .35em; }
.blk-title { font-size: .82em; color: var(--ink-soft); margin-bottom: .1em; padding-right: 1em; }
.blk-note .note-text { font-size: .9em; color: var(--ink-soft); }
.blk-field { margin-top: auto; padding-top: .35em; }
.blk + .blk-field { margin-top: auto; }
.fld { display: flex; align-items: flex-end; gap: .4em; }
.fld-l { --hl: var(--cat, #cdb6ff); flex: none; white-space: nowrap; }
.fld-v .ed { display: block; min-height: 1.1em; }
.fld-v { flex: 1; min-width: 2em; border-bottom: 1.8px solid var(--ink-line); padding: 0 .2em .02em; min-height: 1.15em; }

/* sticky note */
.note-text { display: block; white-space: pre-wrap; }

/* list items */
.items { list-style: none; margin: 0; padding: 0; min-height: .7em; }
.it { position: relative; display: flex; align-items: flex-start; gap: .45em; padding: .08em 0; }
.mark { flex: none; width: .95em; height: .95em; margin-top: .14em; display: grid; place-items: center; }
.mark svg { width: 100%; height: 100%; overflow: visible; fill: none; stroke: var(--ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.mark[data-act] { cursor: pointer; }
.mark .tick { stroke-width: 2.6; stroke-dasharray: 30; stroke-dashoffset: 30; transition: stroke-dashoffset .25s ease-out; }
.it.done .tick { stroke-dashoffset: 0; }
.it-text { display: block; flex: 1; min-width: 0; }
.st-check .it.done .it-text, .st-stage .it.done .it-text { text-decoration: line-through; text-decoration-thickness: .08em; color: var(--ink-soft); }
.st-star .mark svg { fill: var(--hl); }
.st-bullet .mark svg { stroke-width: 2.4; }
.st-lines .it { border-bottom: 1.8px solid var(--ink-line); padding: .2em .1em .05em; gap: 0; }
.st-lines .mark { display: none; }
.st-stage .mark {
  width: 1.32em; height: 1.32em; font-size: .78em; margin-top: .1em; font-family: var(--marker);
  border: 1.8px solid var(--ink); border-radius: 52% 46% 55% 47% / 48% 55% 45% 52%; background: #fff;
}
.st-stage .it.done .mark { background: var(--hl); }
.st-stage .it.cur .mark { box-shadow: 0 0 0 .2em color-mix(in srgb, var(--hl) 70%, transparent); }
.st-stage .it:not(:last-child)::after { content: ''; position: absolute; left: .5em; top: 1.25em; bottom: -.15em; border-left: 1.5px dashed #b4b4ac; }
.now { flex: none; align-self: center; font-size: .55em; letter-spacing: .05em; background: var(--ink); color: #fff; padding: .1em .4em; border-radius: .35em .5em .3em .45em; }

/* daily wins week grid */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .55em; }
.day { position: relative; border-radius: var(--r-sub); background: rgba(255,255,255,.7); padding: .3em .45em .4em; min-height: 5.2em; }
.day.today { box-shadow: 0 0 0 .2em color-mix(in srgb, var(--hl) 80%, transparent), 0 0 1em .25em color-mix(in srgb, var(--hl) 55%, transparent); }
.day-l { font-size: 1em; text-align: center; letter-spacing: .02em; margin-bottom: .15em; }
.day .items { font-size: .78em; }
.day .it { gap: .25em; }

/* drag grips + delete buttons (visible on the selected widget) */
.grip { position: absolute; left: -1.05em; top: .15em; width: 1em; text-align: center; font-size: .8em; color: var(--ink-soft); opacity: 0; cursor: grab; touch-action: none; font-family: var(--ui); }
.sub-grip { left: .2em; right: auto; top: .25em; font-size: .85em; }
.day .grip { left: -.85em; }
.widget.selected .it:hover > .grip, .widget.selected .sub:hover > .sub-grip, .widget.selected .sub.selected > .sub-grip { opacity: .85; }
@media (hover: none) { .widget.selected .grip { opacity: .55; } }
.x { flex: none; border: 0; background: none; color: var(--ink-soft); cursor: pointer; opacity: 0; font-size: .9em; padding: 0 .15em; line-height: 1.2; font-family: var(--ui); }
.bx { position: absolute; right: -.15em; top: 0; }
.widget.selected .it:hover > .x { opacity: .75; }
.x:hover { color: #d12d2d; }

/* "+" affordances live outside the text flow, so selecting never reflows a card */
.w-add {
  position: absolute; left: 50%; bottom: calc(-20px * var(--iz)); transform: translate(-50%, 50%); z-index: 3; display: none;
  font: 600 calc(12px * var(--iz)) var(--ui); color: #fff; background: var(--accent); border: 0; white-space: nowrap;
  border-radius: 999px; padding: calc(4px * var(--iz)) calc(11px * var(--iz)); cursor: pointer; box-shadow: 0 3px 10px rgba(0,0,0,.25);
}
.widget.selected > .w-add { display: block; }
.w-add:hover { background: #7c4ef0; }
.mini-add {
  position: absolute; right: -.25em; top: -.1em; z-index: 1; width: 1.25em; height: 1.25em; box-sizing: border-box; padding: 0;
  font: 700 .8em/1 var(--ui); color: var(--ink-soft); background: #fff; border: 1.5px dashed #b9b9b1; border-radius: 50%;
  cursor: pointer; display: none;
}
.mini-add:hover { color: var(--ink); border-color: var(--ink-soft); }
.mini-add svg { display: block; width: 58%; height: 58%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.widget.selected .sub.selected .mini-add, .widget.selected .sub:hover .mini-add, .t-week.selected .mini-add { display: grid; place-items: center; }
.day .mini-add { right: .2em; top: .25em; font-size: .7em; }
.add-line { display: block; width: 100%; height: 1.35em; background: none; border: 0; border-bottom: 1.8px solid var(--ink-line); padding: 0; cursor: text; }
.add-line + .add-line { margin-top: .55em; }
.add-line:hover { background: rgba(0,0,0,.025); }
.blk-name { flex: 1; min-width: 0; font: 12.5px var(--ui); color: var(--c-text); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 3px 5px; }
.blk-name:hover, .blk-name:focus { border-color: var(--c-line); background: var(--c-card); outline: none; }

/* inline editing */
.ed { outline: none; border-radius: 3px; min-width: .4em; }
.ed:empty::before { content: attr(data-ph); opacity: .33; }
.widget.selected .ed { cursor: text; }
.ed.editing { text-transform: none; background: rgba(139,92,246,.08); box-shadow: 0 0 0 2px rgba(139,92,246,.45); cursor: text; user-select: text; -webkit-user-select: text; }
.ed.opt:empty:not(.editing), .tgt-goal:has(> .ed.opt:empty:not(.editing)), .hdr-sub:has(> .ed.opt:empty:not(.editing)) { display: none; }

/* selection + handles (purple, as in the mockup) */
.widget.selected { outline: calc(2px * var(--iz)) solid var(--accent); outline-offset: calc(5px * var(--iz)); }
.sub.selected { outline: calc(2px * var(--iz)) dashed var(--accent); outline-offset: 3px; }
.handle {
  position: absolute; width: calc(12px * var(--iz)); height: calc(12px * var(--iz));
  background: #fff; border: calc(2px * var(--iz)) solid var(--accent); border-radius: calc(3px * var(--iz));
  display: none; z-index: 3; transform: translate(-50%, -50%); touch-action: none;
}
.widget.selected .handle { display: block; }
.h-nw { left: calc(-5px * var(--iz)); top: calc(-5px * var(--iz)); cursor: nwse-resize; }
.h-n  { left: 50%; top: calc(-5px * var(--iz)); cursor: ns-resize; }
.h-ne { left: calc(100% + 5px * var(--iz)); top: calc(-5px * var(--iz)); cursor: nesw-resize; }
.h-e  { left: calc(100% + 5px * var(--iz)); top: 50%; cursor: ew-resize; }
.h-se { left: calc(100% + 5px * var(--iz)); top: calc(100% + 5px * var(--iz)); cursor: nwse-resize; }
.h-s  { left: 50%; top: calc(100% + 5px * var(--iz)); cursor: ns-resize; }
.h-sw { left: calc(-5px * var(--iz)); top: calc(100% + 5px * var(--iz)); cursor: nesw-resize; }
.h-w  { left: calc(-5px * var(--iz)); top: 50%; cursor: ew-resize; }
@media (pointer: coarse) { .handle { width: calc(22px * var(--iz)); height: calc(22px * var(--iz)); border-radius: 50%; } }

/* drag-to-reorder */
.ghost { position: fixed; left: 0; top: 0; margin: 0; padding: 0; list-style: none; pointer-events: none; z-index: 1000; transform-origin: 0 0; opacity: .94; font-family: var(--hand); color: var(--ink); line-height: 1.2; }
.ghost > .it { background: #fff; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.25); padding: .1em .3em; }
.ghost > .sub { box-shadow: 0 10px 28px rgba(0,0,0,.3); }
.ghost .grip, .ghost .x, .ghost .mini-add { display: none; }
.drag-src { opacity: .25; }
.drop-ind { list-style: none; height: 3px; margin: 1px 0; background: var(--accent); border-radius: 3px; }
.subs > .drop-ind { width: 4px; height: auto; margin: 0; align-self: stretch; flex: none; }

/* ---------- panel ---------- */
.inspector { grid-area: canvas; justify-self: end; align-self: stretch; width: min(var(--panel-w), 45vw); min-height: 0; background: var(--c-panel); border-left: 1px solid var(--c-line); box-shadow: -14px 0 34px rgba(0,0,0,.35); overflow: auto; font-size: 13px; z-index: 40; }
.sheet-grab { display: none; }
#inspector-body { padding: 14px 16px 28px; }
.p-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.p-head h2 { font-size: 16px; margin: 0; font-weight: 650; }
.p-close { background: none; border: 0; color: var(--c-dim); font-size: 18px; cursor: pointer; border-radius: 6px; width: 28px; height: 28px; }
.p-close:hover { background: #2c2838; color: var(--c-text); }
.p-desc { color: var(--c-dim); margin: 0 0 6px; line-height: 1.45; font-size: 12.5px; }
.p-sec { border-top: 1px solid var(--c-line); padding-top: 12px; margin-top: 12px; }
.p-label { font-size: 12.5px; font-weight: 600; margin: 0 0 8px; color: #d9d4e4; display: flex; justify-content: space-between; }
.p-label small { color: var(--c-dim); font-weight: 400; }
.p-field { display: block; margin-bottom: 8px; }
.p-field span { display: block; font-size: 11.5px; color: var(--c-dim); margin-bottom: 4px; }
.p-field input[type=text], .p-field textarea, .p-field select, .num input {
  width: 100%; font: 13px var(--ui); color: var(--c-text); padding: 7px 9px;
  background: var(--c-card); border: 1px solid var(--c-line); border-radius: 8px;
}
.p-field textarea { min-height: 80px; resize: vertical; }
.p-field input:focus, .p-field textarea:focus, .p-field select:focus, .num input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.style-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.style-card { display: grid; place-items: center; gap: 5px; padding: 10px 6px; background: var(--c-card); border: 1px solid var(--c-line); border-radius: 10px; cursor: pointer; font-size: 12px; color: var(--c-dim); }
.style-card svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.style-card.on { border-color: var(--accent); background: var(--accent-soft); color: #fff; }
.seg { display: flex; flex-wrap: wrap; gap: 5px; }
.seg button, .p-btn { background: var(--c-card); border: 1px solid var(--c-line); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 12.5px; }
.seg button:hover, .p-btn:hover { background: #312c3d; }
.seg button.on { background: var(--accent-soft); border-color: var(--accent); color: #fff; }
.p-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.p-btn.danger { color: #ff8a8a; }
.p-btn:disabled { opacity: .35; cursor: default; }
.sw-row { display: flex; flex-wrap: wrap; gap: 8px; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 0; padding: 0; background: var(--c); cursor: pointer; position: relative; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.sw.on { box-shadow: 0 0 0 2px var(--c-panel), 0 0 0 4px #fff; }
.sw-custom { background: conic-gradient(#ff8f8f, #ffe27a, #a8e8b6, #a9d6ff, #cdb6ff, #ff8f8f); overflow: hidden; }
.sw-custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; border: 0; padding: 0; cursor: pointer; }
.num-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.num { position: relative; }
.num b { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--c-dim); font-weight: 600; pointer-events: none; }
.num input { padding-left: 26px; font-variant-numeric: tabular-nums; }
.layer-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.layer-row button { height: 34px; display: grid; place-items: center; background: var(--c-card); border: 1px solid var(--c-line); border-radius: 8px; cursor: pointer; padding: 0; }
.layer-row button:hover { background: #312c3d; }
.layer-row svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.p-range { display: flex; align-items: center; gap: 4px; }
.p-range input { flex: 1; min-width: 0; accent-color: var(--accent); } /* range inputs have a ~130px intrinsic min width; let them shrink so the row never overflows the panel */
.p-range output { min-width: 38px; text-align: right; color: var(--c-dim); font-variant-numeric: tabular-nums; }
.p-note { color: var(--c-dim); line-height: 1.45; margin: 6px 0 0; font-size: 12px; }
.p-note b { color: var(--c-text); font-weight: 600; }

/* hierarchy tree */
.tree { list-style: none; margin: 0; padding: 6px; background: #1a1822; border: 1px solid var(--c-line); border-radius: 10px; }
.tree ul { list-style: none; margin: 0; padding: 0 0 0 16px; border-left: 1px solid #3a3447; margin-left: 9px; }
.tree-row { display: flex; align-items: center; gap: 7px; width: 100%; background: none; border: 0; border-radius: 6px; padding: 5px 7px; cursor: pointer; font-size: 12.5px; text-align: left; color: #d6d1e1; }
.tree-row:hover { background: #2a2635; }
.tree-row.on { background: var(--accent-soft); color: #fff; box-shadow: inset 0 0 0 1px rgba(139,92,246,.5); }
.tree-row .dot { width: 11px; height: 11px; border-radius: 3px; flex: none; border: 1.5px solid #8c869a; background: var(--c, transparent); }
.tree-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tree-row .kind { color: var(--c-dim); font-size: 11px; }
.tips { margin: 0; padding-left: 18px; line-height: 1.55; color: #cfcad9; font-size: 12.5px; }
.tips li { margin-bottom: 3px; }

/* ---------- help + toast ---------- */
.help { border: 1px solid var(--c-line); border-radius: 16px; padding: 0; background: var(--c-panel); color: var(--c-text); max-width: min(740px, calc(100vw - 24px)); box-shadow: 0 30px 70px rgba(0,0,0,.55); }
.help::backdrop { background: rgba(8,6,12,.55); }
.help form { padding: 22px 24px; }
.help h2 { margin: 0 0 12px; font-size: 20px; }
.help h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--c-dim); margin: 12px 0 6px; }
.help ul { margin: 0; padding-left: 18px; line-height: 1.6; font-size: 13.5px; color: #d7d2e2; }
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.help-foot { color: var(--c-dim); font-size: 13px; }
.btn-primary { background: var(--accent); color: #fff; border: 0; border-radius: 9px; padding: 8px 16px; font-weight: 600; cursor: pointer; }
.toast { position: fixed; left: 50%; bottom: 52px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: #f4f1fa; color: #1b1822; font-size: 13px; padding: 9px 14px; border-radius: 10px; transition: .25s; z-index: 2000; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive shell ---------- */
@media (max-width: 1100px) {
  .logo span { display: none; }
}
/* Narrow or portrait screens: panel becomes a bottom sheet over the board. */
@media (max-width: 900px), (orientation: portrait) and (max-width: 1200px) {
  .inspector {
    justify-self: stretch; align-self: end; width: auto; max-height: 48vh; max-height: 48dvh;
    border-left: 0; border-top: 1px solid var(--c-line); border-radius: 16px 16px 0 0;
    box-shadow: 0 -14px 34px rgba(0,0,0,.45);
  }
  .sheet-grab { display: block; width: 40px; height: 5px; border-radius: 3px; background: #4a4458; margin: 8px auto 0; }
  .app:not(.no-panel) ~ .toast { bottom: calc(48vh + 52px + env(safe-area-inset-bottom)); bottom: calc(48dvh + 52px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "canvas" "status"; }
  .rail { display: none; }
  .show-sm { display: inline-flex !important; }
  .topbar { gap: 5px; padding-left: 8px; padding-right: 8px; }
  .pill { max-width: 40vw; }
  .help-grid { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  #help-btn { display: none; }
}
@media print {
  .topbar, .statusbar, .rail, .inspector, .handle, .w-add, .mini-add, .w-more, .w-dots, .tray, .sheen { display: none !important; }
  .app { display: block; }
}

/* categories: subcategory cards stretch to fill the container */
.t-category .fit, .t-week .fit { display: flex; flex-direction: column; }
.cat { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.cat .subs { flex: 1; }
.t-week .days { flex: 1; }

/* ruled lines fill whatever space is left, and don't count toward text fitting */
.lst { display: flex; flex-direction: column; height: 100%; }
.t-list > .fit { display: flex; flex-direction: column; }
.ruled { flex: 1 1 auto; min-height: 1.5em; margin-top: .1em; cursor: text; border: 0; padding: 0; width: 100%;
  background: repeating-linear-gradient(180deg, transparent 0 calc(1.6em - 1.8px), var(--ink-line) calc(1.6em - 1.8px) 1.6em) 0 0 / 100% 1.6em; }
.ruled:hover { background-color: rgba(0,0,0,.02); }
.day-l { white-space: nowrap; }


/* collision feedback: the element you bumped into rings briefly */
.widget.bump { animation: dd-bump .55s ease-out; }
@keyframes dd-bump {
  0% { box-shadow: 0 0 0 calc(2px * var(--iz)) rgba(139, 92, 246, .75); }
  100% { box-shadow: 0 0 0 calc(12px * var(--iz)) rgba(139, 92, 246, 0); }
}
.p-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.p-check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* heading font: chosen on fonts.html (fonts.js sets --head-font / --head-weight and html.heads-asis) */
.hdr-title, .w-head, .tgt-head, .sub-head, .day-l { font-family: var(--head-font, var(--hand)); }
.hdr-title, .w-head, .tgt-head, .sub-head, .day-l { font-weight: var(--head-weight, 600); }
html.heads-asis .caps, html.heads-asis .hdr-title { text-transform: none; letter-spacing: normal; }

/* generated highlighter ink (marker.js): each swipe unique; the shared mask remains only as a fallback */
.hl.inked::before { display: none; }
.hl > .hl-ink { z-index: -1; color: var(--hl); }

/* typed text size next to the slider */
.p-range .p-num { width: 44px; flex: none; font: 13px var(--ui); color: var(--c-text); text-align: right; padding: 5px 7px;
  background: var(--c-card); border: 1px solid var(--c-line); border-radius: 7px; font-variant-numeric: tabular-nums; }
.p-range .p-num { -moz-appearance: textfield; appearance: textfield; }
.p-range .p-num::-webkit-inner-spin-button, .p-range .p-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.p-range .p-btn.p-step { width: 24px; height: 24px; flex: none; padding: 0; line-height: 1; }
.p-range .p-num:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.p-range .p-btn { padding: 5px 8px; font-size: 12px; }
.p-range .p-unit { color: var(--c-dim); font-size: 12px; margin-left: -4px; }

/* generated textured marker ink: bursts, underline, ruled + field lines */
.spark.inked { background: none; -webkit-mask: none; mask: none; color: var(--spark-ink, var(--ink-line)); position: relative; }
.spark.r.inked { transform: none; } /* the generator draws the mirrored side itself */
.spark.inked > svg, .uline.inked > svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.uline.inked { background: none; -webkit-mask: none; mask: none; color: var(--line); position: relative; }
.fld-v.inked, .st-lines > .it.inked { border-bottom-color: transparent; position: relative; }
.ruled.inked { background-image: none; position: relative; }
.sk-line { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; color: var(--ink-line); }

/* smart guides */
.guide-layer { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; z-index: 50; }
.guide { position: absolute; background: #ff3d9a; box-shadow: 0 0 0 calc(.5px * var(--iz)) rgba(255,255,255,.6); }
.guide.gx { width: calc(1.5px * var(--iz)); transform: translateX(-50%); }
.guide.gy { height: calc(1.5px * var(--iz)); transform: translateY(-50%); }
.guide.board-center.gx { background: repeating-linear-gradient(180deg, #ff3d9a 0 calc(8px * var(--iz)), transparent 0 calc(13px * var(--iz))); }
.guide.board-center.gy { background: repeating-linear-gradient(90deg, #ff3d9a 0 calc(8px * var(--iz)), transparent 0 calc(13px * var(--iz))); }

.history-row { display:flex; gap:8px; margin: 9px 0; font-size: 13px; line-height: 1.3; }
.history-row small { display:block; color:#777; margin-top:3px; }
.history-dot { flex:none; width:7px; height:7px; margin-top:5px; border-radius:50%; background:#9a6cf0; }

.win-content { flex:1; min-width:0; }
.win-source { display:flex; align-items:center; gap:.3em; min-width:0; font-size:.55em; color:#777; line-height:1.25; }
.win-source > span:last-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.win-source-dot { flex:none; width:.7em; height:.7em; border-radius:50%; }
