/* ============================================================================
   SVG Print Studio — stylesheet (single pass, no duplicated blocks).
   Note: node/handle/ghost RADII and stroke-widths are set by the renderer in
   JS (counter-scaled by zoom), so no r rules live here.
   ========================================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    width: 100vw; height: 100vh; overflow: hidden;
    background-color: #F8F9FA;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* The dot grid lives inside the SVG (#dot-grid) so it pans & zooms with the art. */
}

/* --- Workspace & cursors ---------------------------------------------- */
#workspace { width: 100%; height: 100%; display: block; cursor: crosshair; }
#workspace.move-mode { cursor: grab; }
#workspace.move-mode:active { cursor: grabbing; }
body.panning #workspace { cursor: grab !important; }
body.panning-active #workspace { cursor: grabbing !important; }

/* --- Toolbar ------------------------------------------------------------ */
#toolbar {
    position: absolute; top: 15px; left: 50%; transform: translateX(-50%);
    background: white; padding: 8px 12px; border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); border: 1px solid #E9ECEF;
    display: flex; gap: 15px; align-items: center;
    z-index: 100;
    max-width: 95vw;           /* responsive horizontal scroll, no ugly wrap */
    overflow-x: auto;
    flex-wrap: nowrap;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
#toolbar::-webkit-scrollbar { display: none; }

/* Smart fade: mid-gesture (drawing/dragging) the toolbar ghosts out and lets
   clicks pass through when the pointer comes near, so it never hides the art
   you're actively working on. toolbar.js toggles the body class. */
#toolbar { transition: opacity 0.15s ease; }
body.toolbar-ghost #toolbar { opacity: 0.12; pointer-events: none; }
/* Touch commit pill: the Pencil's Esc/Enter (tool-draw.js shows/hides it). */
#draw-commit {
    position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    display: none; gap: 8px; z-index: 100;
    background: white; padding: 6px; border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); border: 1px solid #E9ECEF;
}
#draw-commit.show { display: flex; }
#draw-commit button {
    border: none; border-radius: 8px; cursor: pointer;
    padding: 10px 16px; font-size: 13px; font-weight: 600;
    background: #F1F3F5; color: #343A40;
}
#draw-commit button:disabled { opacity: 0.35; cursor: default; }
#draw-commit #dc-done { background: #0CA678; color: white; }

/* v23 B1: node pill — same slot and look as the commit pill */
#node-pill {
    position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    display: none; gap: 8px; z-index: 100;
    background: white; padding: 6px; border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1); border: 1px solid #E9ECEF;
}
#node-pill.show { display: flex; }
#node-pill button {
    border: none; border-radius: 8px; cursor: pointer;
    padding: 10px 14px; font-size: 13px; font-weight: 600;
    background: #F1F3F5; color: #343A40;
}
#node-pill #np-delete { background: #FFF0F3; color: #C92A2A; }
#node-pill #np-continue { background: #0CA678; color: white; }

/* Manual collapse: shrink to just the chevron tab. */
#toolbar.collapsed .tool-group { display: none; }
#toolbar.collapsed { padding: 8px; }
#btn-collapse svg { transition: transform 0.2s ease; }
#toolbar.collapsed #btn-collapse svg { transform: rotate(180deg); }

.tool-group {
    display: flex; gap: 5px; align-items: center;
    border-right: 1px solid #E9ECEF; padding-right: 15px;
    flex-shrink: 0;
}
.tool-group:last-child { border-right: none; padding-right: 0; }

.tool-btn {
    background: none; border: none;
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; cursor: pointer;
    color: #495057; transition: all 0.15s ease;
}
.tool-btn:hover { background: #F1F3F5; color: #212529; }
.tool-btn.active { background: #E6FCF5; color: #0CA678; }
.tool-btn:disabled { opacity: 0.35; cursor: default; }
.tool-btn:disabled:hover { background: none; color: #495057; }
.tool-btn svg { pointer-events: none; }
.tool-btn.export { color: #FF007F; }
.tool-btn.zoom-reset { font-size: 11px; font-weight: bold; width: 30px; }

/* --- Colour picker ------------------------------------------------------ */
.color-picker-wrapper {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
}
#shape-color {
    border: none; width: 28px; height: 28px;
    border-radius: 6px; cursor: pointer; padding: 0; background: transparent;
}
#shape-color::-webkit-color-swatch-wrapper { padding: 0; }
#shape-color::-webkit-color-swatch { border: 2px solid #DEE2E6; border-radius: 6px; }

/* --- Selects, sliders, number/text inputs ------------------------------- */
#fill-type, #ink-blend {
    height: 32px; border: 1px solid #DEE2E6; border-radius: 6px;
    background: #fff; color: #495057; font-size: 12px; font-weight: 500;
    padding: 0 6px; cursor: pointer;
}
#fill-scale, #ink-opacity { width: 64px; cursor: pointer; accent-color: #0CA678; }
#fill-angle {
    width: 46px; height: 32px; border: 1px solid #DEE2E6; border-radius: 6px;
    text-align: center; font-size: 12px; font-weight: 500; color: #495057;
}
#fill-angle::-webkit-inner-spin-button { opacity: 0.4; }
#zoom-input {
    width: 45px; text-align: center; border: none; background: transparent;
    font-size: 12px; font-weight: bold; color: #495057;
}

/* --- Regions (screens) -------------------------------------------------- */
.region-fill {
    stroke: none;
    cursor: pointer;
}
.region-stroke {
    fill: none;
    stroke-linejoin: round;
    stroke-linecap: round;
    pointer-events: stroke;   /* the outline is clickable even with no fill */
    cursor: pointer;
}

/* --- Drawing overlay ----------------------------------------------------- */
#preview-line {
    fill: none; stroke: #FF0055;
    stroke-dasharray: 6 4;
    display: none; pointer-events: none;
}
#ghost-cursor {
    fill: none; stroke: #FF0055;
    pointer-events: none;
}
.node {
    fill: white; stroke: #212529;
    cursor: grab;
}
.node:hover { stroke: #FF0055; }
.node.selected { fill: #FF0055; stroke: #FF0055; }
.node-hole { stroke: #7950F2; } /* hole contours: violet ring, fully live */
.selection-box { fill: none; stroke: #0CA678; }
.selection-glow { fill: none; stroke: #0CA678; opacity: 0.30; stroke-linejoin: round; stroke-linecap: round; }
.pencil-preview { fill: none; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; pointer-events: none; }
#workspace.pencil-mode { cursor: crosshair; }
.void-fill { stroke: none; }
.void-fill.shown { stroke: #FA5252; stroke-opacity: 0.7; stroke-dasharray: 4 3; }
.eraser-preview { fill: #FA5252; fill-opacity: 0.22; stroke: #FA5252; stroke-width: 1; stroke-opacity: 0.6; fill-rule: nonzero; pointer-events: none; }
.eraser-cursor { fill: none; stroke: #FA5252; stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
#workspace.eraser-mode { cursor: crosshair; }
#workspace.trim-mode { cursor: crosshair; }
.trim-piece { fill: none; stroke: #0CA678; stroke-linecap: round; pointer-events: none; }
.trim-piece.marked { stroke: #FA5252; stroke-dasharray: 5 4; }
.trim-cross { fill: white; stroke: #0CA678; pointer-events: none; }
#trim-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 60;
    display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: white;
    border: 1px solid #DEE2E6; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); font-size: 12px; color: #495057; }
#trim-bar[hidden] { display: none; }
.selection-box-locked { fill: none; stroke: #ADB5BD; }
.marquee { fill: rgba(12,166,120,0.08); stroke: #0CA678; }
.sel-handle { fill: white; stroke: #0CA678; }
.sel-stem { stroke: #0CA678; }
.sel-rotate { fill: white; stroke: #0CA678; }
.sel-lock { cursor: pointer; }
.sel-lock .sel-lock-halo { fill: white; stroke: #0CA678; stroke-width: 1.5; }
.sel-lock rect { fill: white; stroke: #ADB5BD; stroke-width: 1.5; }
.sel-lock path { stroke: #ADB5BD; stroke-width: 1.5; stroke-linecap: round; }
.sel-lock.on rect { fill: #0CA678; stroke: #0CA678; }
.sel-lock.on path { stroke: #0CA678; }
.selection-label {
    fill: #0CA678; font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    paint-order: stroke; stroke: #F8F9FA; stroke-width: 3px;
}
.node.closable { stroke: #FF0055; } /* node 0 while drawing: click to close */
.node.node-end { rx: 1px; }        /* v23 B1: open-path ends are hollow squares (rect) */
/* v23 B2: panel-hover glow (teal / grey when locked) and lock badges */
.hover-glow { fill: none; stroke: #0CA678; opacity: 0.35; stroke-linejoin: round; stroke-linecap: round; }
.hover-glow-locked { fill: none; stroke: #868E96; opacity: 0.45; stroke-linejoin: round; stroke-linecap: round; }
.lock-badge { fill: white; stroke: #ADB5BD; }
.lock-badge-glyph { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#btn-show-locks.active { background: #E6FCF5; color: #0CA678; }
.handle-line { stroke: #ADB5BD; stroke-dasharray: 4 4; }
.phantom-edge { stroke: #12B886; fill: none; opacity: 0.75; } /* v23 A3: chord that closes an open path for pouring */
.handle-point {
    fill: #F8F9FA; stroke: #0CA678;
    cursor: grab;
}
.handle-point:hover { fill: #0CA678; }

/* --- Tooltips -------------------------------------------------------------- */
/* A single floating element on <body>, positioned by toolbar.js. The old CSS
   ::after approach was clipped by the toolbar's overflow-x scroll container,
   and pseudo-elements can't exist on <input>/<select> at all. */
#floating-tooltip {
    position: fixed; display: none;
    background-color: #212529; color: white;
    padding: 6px 10px; border-radius: 6px;
    font-size: 11px; font-weight: 500;
    white-space: nowrap; pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
    z-index: 10000;
}

/* --- Dropdowns ------------------------------------------------------------ */
/* Panels are MOVED to <body> by toolbar.js (the toolbar clips descendants and
   its transform breaks fixed positioning) and placed under their toggle. */
.dropdown { display: flex; }
.dd-toggle { position: relative; }
.dd-toggle.open { background: #E6FCF5; color: #0CA678; }
.dd-swatch {
    position: absolute; bottom: 4px; left: 9px; right: 9px; height: 3px;
    border-radius: 2px; background: #212529; pointer-events: none;
}
.dd-panel {
    position: fixed; display: none;
    background: white; border: 1px solid #E9ECEF; border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    padding: 12px; z-index: 5000; min-width: 208px;
}
.dd-panel.open { display: block; }
.dd-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; margin-bottom: 10px;
}
.dd-row:last-child { margin-bottom: 0; }
.dd-row label { font-size: 12px; color: #495057; font-weight: 500; }
.dd-row input[type="range"] { width: 110px; cursor: pointer; accent-color: #0CA678; }
.dd-val {
    min-width: 32px; text-align: right; font-size: 11px; font-weight: 600;
    color: #495057; font-variant-numeric: tabular-nums;
}
.dd-row:has(.dd-val) input[type="range"] { width: 86px; }
.dd-row input[type="number"] {
    width: 64px; height: 30px; border: 1px solid #DEE2E6; border-radius: 6px;
    text-align: center; font-size: 12px; font-weight: 500; color: #495057;
}
.dd-row select {
    height: 30px; border: 1px solid #DEE2E6; border-radius: 6px;
    background: #fff; color: #495057; font-size: 12px; font-weight: 500;
    padding: 0 6px; cursor: pointer;
}
.dd-row input[type="color"] {
    border: none; width: 36px; height: 28px; border-radius: 6px;
    cursor: pointer; padding: 0; background: transparent;
}
.dd-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.dd-row input[type="color"]::-webkit-color-swatch { border: 2px solid #DEE2E6; border-radius: 6px; }
.dd-note { font-size: 11px; color: #ADB5BD; margin-top: 10px; max-width: 210px; line-height: 1.5; }
.dd-sep { height: 1px; background: #F1F3F5; margin: 8px 0; }
.dd-head { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #ADB5BD; margin-bottom: 8px; }
.dd-btnrow { display: flex; gap: 6px; }
.dd-item {
    display: flex; gap: 10px; align-items: center; width: 100%;
    padding: 8px 10px; margin-top: 4px;
    background: none; border: none; border-radius: 6px;
    cursor: pointer; font-size: 13px; color: #495057; text-align: left;
}
.dd-item:hover { background: #F1F3F5; color: #212529; }
.mini-toggle {
    padding: 4px 14px; border-radius: 6px; border: 1px solid #DEE2E6;
    background: #fff; cursor: pointer; font-size: 12px; font-weight: 500; color: #868E96;
}
.mini-toggle.active { background: #E6FCF5; color: #0CA678; border-color: #0CA678; }

/* --- Source viewer ------------------------------------------------------------ */
#source-view {
    width: 340px; height: 300px; resize: both;
    font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 10.5px;
    line-height: 1.45; color: #343A40; background: #F8F9FA;
    border: 1px solid #E9ECEF; border-radius: 8px; padding: 8px;
    white-space: pre; overflow: auto;
}

/* --- Pin bar (all dropdown panels) ------------------------------------------ */
.dd-pinbar {
    display: flex; align-items: center; justify-content: space-between;
    margin: -4px -4px 6px -4px; padding: 2px 4px 4px 6px;
    border-bottom: 1px solid transparent;
}
.dd-pintitle { font-size: 11px; font-weight: 600; color: #ADB5BD; opacity: 0; }
.dd-pin {
    background: none; border: none; cursor: pointer; color: #ADB5BD;
    padding: 3px; border-radius: 4px; display: flex;
}
.dd-pin:hover { background: #F1F3F5; color: #495057; }
.dd-pin.on { color: #0CA678; transform: rotate(-35deg); }
.dd-panel.pinned { box-shadow: 0 10px 36px rgba(0,0,0,0.16); }
.dd-panel.pinned .dd-pinbar { cursor: grab; border-bottom-color: #F1F3F5; }
.dd-panel.pinned .dd-pintitle { opacity: 1; }

/* --- Ink Screens panel ------------------------------------------------------- */
#screens-panel {
    position: fixed; top: 80px; right: 16px; width: 236px;
    min-width: 236px; max-width: 70vw;        /* v23 C3: resizable from the left edge */
    max-height: calc(100vh - 100px);
    background: white; border: 1px solid #E9ECEF; border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    display: none; flex-direction: column; z-index: 200;
}
#screens-panel.open { display: flex; }
#sp-resize {
    position: absolute; left: -5px; top: 0; bottom: 0; width: 12px;
    cursor: ew-resize; touch-action: none; z-index: 1;
}
#sp-resize::after {
    content: ''; position: absolute; left: 4px; top: 50%; width: 3px; height: 34px;
    margin-top: -17px; border-radius: 2px; background: #DEE2E6;
}
#sp-resize:hover::after, #screens-panel.resizing #sp-resize::after { background: #0CA678; }
#screens-panel.resizing { user-select: none; -webkit-user-select: none; }
.sp-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 12px; border-bottom: 1px solid #F1F3F5;
    font-size: 13px; font-weight: 600; color: #212529;
}
#screens-list { overflow-y: auto; padding: 6px; }
.screen-row {
    display: flex; align-items: center; gap: 7px;
    padding: 7px 8px; border-radius: 8px; cursor: pointer;
}
.screen-row:hover { background: #F8F9FA; }
.screen-row.active { background: #E6FCF5; }
.screen-row.in-multi { background: #F1FBF7; }
.screen-chip {
    width: 16px; height: 16px; border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.15); flex-shrink: 0;
}
.screen-name {
    flex: 1; font-size: 12.5px; color: #343A40;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.screen-name input {
    width: 100%; font-size: 12.5px; border: 1px solid #0CA678;
    border-radius: 4px; padding: 2px 4px;
}
.row-btn {
    background: none; border: none; cursor: pointer; color: #495057;
    padding: 3px; border-radius: 4px; display: flex; align-items: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.row-btn:hover { background: #E9ECEF; }
.row-btn.off { opacity: 0.28; }
.row-btn.solo.on { color: #0CA678; opacity: 1; }
.row-btn.del:hover { background: #FFE3E3; color: #E03131; }
.screen-row.grouped { border-left: 3px solid #748FFC; }

/* v23 C: screens (inks) with shapes nested under them; substrate section */
.ink-row { font-weight: 600; margin-top: 4px; }
.ink-row .screen-name { font-size: 12.5px; }
.ink-row.active { background: #E6FCF5; }
.ink-count { font-size: 10.5px; color: #868E96; font-weight: 500; flex-shrink: 0; }
.row-btn.fold { padding: 2px; color: #ADB5BD; }
.row-btn.fold svg { transition: transform 0.15s ease; }
.row-btn.fold.closed svg { transform: rotate(-90deg); }
.ink-row.collapsed .ink-count { color: #495057; }
.shape-row { padding-left: 22px; }
.shape-row .screen-name { font-size: 12px; color: #495057; }
.shape-row.keyline-elsewhere .screen-name::after { content: ' ↗'; color: #868E96; font-size: 10px; }
.sub-header { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: #ADB5BD; padding: 8px 8px 2px; }
.row-grip { cursor: grab; color: #CED4DA; touch-action: none; padding: 2px 3px; flex-shrink: 0; font-size: 12px; line-height: 1; user-select: none; -webkit-user-select: none; }
.row-grip:active { cursor: grabbing; }
.screen-row.lifting { opacity: 0.45; }
.screen-row.drop-before { box-shadow: inset 0 2px 0 #0CA678; }
.screen-row.drop-after { box-shadow: inset 0 -2px 0 #0CA678; }
.screen-row.drop-into { box-shadow: inset 0 0 0 2px #0CA678; }
#btn-add-ink { font-size: 16px; font-weight: 700; }

/* --- Help modal --------------------------------------------------------------- */
#help-modal {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0,0,0,0.4); display: none;
    justify-content: center; align-items: center; z-index: 9999;
}
#help-modal.active { display: flex; }
.help-content {
    background: white; padding: 30px; border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2); max-width: 440px;
    max-height: 85vh; overflow-y: auto;
}
.help-content h2 { margin-bottom: 15px; font-size: 20px; color: #212529; }
.help-content ul { list-style: none; margin-bottom: 20px; }
.help-content li { margin-bottom: 10px; font-size: 13.5px; color: #495057; line-height: 1.6; }
.help-content code {
    background: #F1F3F5; padding: 3px 6px; border-radius: 4px;
    font-weight: bold; color: #FF007F;
}
#btn-close-help {
    width: 100%; padding: 12px; background: #0CA678; color: white;
    border: none; border-radius: 6px; font-weight: bold; cursor: pointer;
    transition: background 0.1s;
}
#btn-close-help:hover { background: #099268; }

/* ---- 22.2 align buttons + 22.5 glyph sheet ---- */
.al-btn { width:30px; height:30px; font-size:15px; }
#glyph-grid { display:grid; grid-template-columns:repeat(6,1fr); gap:5px; margin:10px 0; max-height:200px; overflow-y:auto; }
.glyph-cell { border:1px solid #DEE2E6; border-radius:6px; background:#fff; cursor:pointer; padding:3px; height:40px; color:#212529; }
.glyph-cell:hover { border-color:#0CA678; color:#0CA678; }
.glyph-cell svg { width:100%; height:100%; display:block; }
