:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --hover: #f1f3f6;
  --line: #e6e8ec;
  --line-2: #d5d9e0;
  --text: #14171f;
  --text-2: #3d4350;
  --muted: #6b7280;
  --faint: #9aa1ad;
  --brand: #2563eb;
  --brand-ink: #ffffff;
  --brand-soft: #eef4ff;
  --brand-line: #bfd3fb;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --ok: #16a34a;
  --warn-soft: #fff6e0;
  --stage: #e9ebef;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-2: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-3: 0 12px 32px rgba(16, 24, 40, .14), 0 2px 6px rgba(16, 24, 40, .06);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent);
  --radius: 12px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --top: 56px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg);
       color: var(--text); -webkit-font-smoothing: antialiased; min-height: 100dvh; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--brand); }
::selection { background: color-mix(in srgb, var(--brand) 25%, transparent); }
.spacer { flex: 1; }

/* ------------------------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
       border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel); cursor: pointer; white-space: nowrap;
       font-weight: 550; font-size: 13.5px; text-decoration: none; color: var(--text); box-shadow: var(--shadow-1);
       transition: background .15s, border-color .15s, box-shadow .15s, transform .1s; }
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .rail-item:focus-visible, .tab:focus-visible { outline: none; box-shadow: var(--ring); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.soft { border-color: transparent; background: var(--brand-soft); color: var(--brand); box-shadow: none; }
.btn.soft:hover { background: color-mix(in srgb, var(--brand) 16%, var(--panel)); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn svg, .icon-btn svg { width: 16px; height: 16px; flex: none; }
.btn.small svg { width: 15px; height: 15px; }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 0;
            background: transparent; color: var(--muted); cursor: pointer; flex: none; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.danger:hover { color: var(--danger); background: var(--danger-soft); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; height: var(--top); flex: none;
          padding: 0 14px; background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(10px);
          border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 15.5px; color: var(--text);
         text-decoration: none; margin-right: 10px; letter-spacing: -.01em; }
.brand .mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--brand);
               color: #fff; }
.brand .mark svg { width: 17px; height: 17px; }
.title-input { min-width: 80px; max-width: 340px; flex: 0 1 auto; field-sizing: content; height: 36px; padding: 0 10px; border-radius: 8px;
               border: 1px solid transparent; background: transparent; font-weight: 650; font-size: 15px;
               text-overflow: ellipsis; transition: border-color .15s, background .15s; }
.title-input:hover { border-color: var(--line); }
.title-input:focus { border-color: var(--brand); outline: none; background: var(--panel); box-shadow: var(--ring); }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); transition: background .3s; }
.status.ok::before { background: var(--ok); }
.status.busy::before { background: var(--brand); animation: pulse 1s ease-in-out infinite; }
.status.bad { color: var(--danger); }
.status.bad::before { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }

/* people switcher */
.tabs { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--hover); overflow-x: auto;
        scrollbar-width: none; max-width: 100%; }
.tab { height: 30px; padding: 0 14px; border-radius: 8px; border: 0; background: transparent; cursor: pointer;
       font-weight: 550; color: var(--muted); white-space: nowrap; transition: background .15s, color .15s, box-shadow .15s; }
.tab:hover { color: var(--text); }
.tab.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-2); }
.tab.add { width: 30px; padding: 0; display: grid; place-items: center; }
.tab.add svg { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ library */
.lib { max-width: 1200px; margin: 0 auto; padding: 32px 24px 80px; }
.lib-head { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 24px; }
.lib-head h1 { margin: 0; font-size: 24px; letter-spacing: -.02em; }
.lib-head p { margin: 4px 0 0; color: var(--muted); }
.lib-head > div:first-child { flex: 1; min-width: 200px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 22px; }
.card { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
        box-shadow: var(--shadow-2); display: flex; flex-direction: column; cursor: pointer;
        transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s; }
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-3); border-color: var(--line-2); }
.card:focus-visible { outline: none; box-shadow: var(--ring), var(--shadow-3); }
.thumb { position: relative; aspect-ratio: 1 / 1.1; overflow: hidden; background: #fff; border-bottom: 1px solid var(--line); }
.thumb .host { position: absolute; top: 0; left: 0; transform-origin: 0 0; pointer-events: none; opacity: 0;
               transition: opacity .3s; }
.thumb .host.drawn { opacity: 1; }
.thumb::after { content: ""; position: absolute; inset: auto 0 0; height: 40px;
                background: linear-gradient(rgba(255, 255, 255, 0), #fff); pointer-events: none; }
.card-body { padding: 13px 14px 4px; display: flex; flex-direction: column; gap: 2px; }
.card-title { font-weight: 650; font-size: 15px; }
.card-meta { font-size: 12.5px; color: var(--muted); }
.card-actions { display: flex; gap: 4px; align-items: center; padding: 8px 10px 10px; }
.card.new { display: grid; place-items: center; min-height: 280px; border-style: dashed; border-width: 1.5px;
            background: transparent; box-shadow: none; color: var(--muted); font-weight: 600; text-align: center; }
.card.new:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); box-shadow: none; }
.card.new .plus { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 10px;
                  background: var(--hover); }
.card.new:hover .plus { background: var(--panel); }
.card.new svg { width: 22px; height: 22px; }
.empty { padding: 56px 20px; text-align: center; color: var(--muted); background: var(--panel);
         border: 1.5px dashed var(--line-2); border-radius: var(--radius); }
.empty .btn { margin-top: 14px; }

/* ------------------------------------------------------------------- editor */
body.editing { height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body.editing #app { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 208px minmax(420px, 620px) minmax(0, 1fr); }

/* section rail */
.rail { display: flex; flex-direction: column; gap: 2px; padding: 16px 10px; border-right: 1px solid var(--line);
        background: var(--panel); overflow-y: auto; min-height: 0; }
.rail-label { padding: 4px 10px 8px; font-size: 11.5px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase;
              color: var(--faint); }
.rail-item { position: relative; display: flex; align-items: center; gap: 10px; height: 38px; padding: 0 10px; border: 0;
             border-radius: 9px; background: transparent; color: var(--text-2); cursor: pointer; text-align: left;
             font-weight: 550; transition: background .15s, color .15s; }
.rail-item svg { width: 17px; height: 17px; flex: none; color: var(--faint); transition: color .15s; }
.rail-item:hover { background: var(--hover); color: var(--text); }
.rail-item.on { background: var(--brand-soft); color: var(--brand); }
.rail-item.on svg { color: var(--brand); }
.rail-item .label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-item .n { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--hover); color: var(--muted);
                font-size: 11.5px; font-weight: 650; display: grid; place-items: center; }
.rail-item.on .n { background: var(--panel); color: var(--brand); }
.rail-foot { margin-top: auto; padding: 12px 10px 0; font-size: 12px; color: var(--faint); line-height: 1.9; }
.rail-foot kbd, .hint kbd { font: 10.5px/1 "JetBrains Mono", monospace; padding: 2px 5px; border: 1px solid var(--line-2);
                            border-bottom-width: 2px; border-radius: 4px; background: var(--panel-2); color: var(--text-2); }

/* the form */
.form-pane { overflow-y: auto; overscroll-behavior: contain; background: var(--bg); border-right: 1px solid var(--line);
             min-height: 0; scrollbar-gutter: stable; }
.form-inner { padding: 26px 26px 140px; }
.panel { animation: panel-in .28s var(--ease); }
@keyframes panel-in { from { opacity: 0; transform: translateY(6px); } }
.panel-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.panel-head > div { flex: 1; min-width: 0; }
.panel-head h2 { margin: 0; font-size: 20px; letter-spacing: -.015em; }
.panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.panel-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 26px; padding-top: 18px;
             border-top: 1px solid var(--line); }

.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.box-pad { padding: 18px; }
.sub-head { display: flex; align-items: center; gap: 8px; margin: 24px 0 10px; }
.sub-head h3 { margin: 0; font-size: 13px; font-weight: 650; color: var(--text-2); flex: 1; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid .wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span:first-child { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.input, .field input, .field textarea, .field select {
  width: 100%; min-height: 38px; padding: 8px 11px; border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--panel); transition: border-color .15s, box-shadow .15s; }
.input::placeholder, .field input::placeholder, .field textarea::placeholder, .point textarea::placeholder { color: var(--faint); }
.field textarea, textarea.input { resize: none; overflow: hidden; line-height: 1.55; }
.input:hover, .field input:hover, .field textarea:hover { border-color: color-mix(in srgb, var(--line-2) 60%, var(--muted)); }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.field input:disabled { color: var(--muted); background: var(--panel-2); }
.hint { font-size: 12px; color: var(--muted); }
.field .hint { margin-top: 1px; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; color: var(--text-2); cursor: pointer;
          user-select: none; }
.switch input { appearance: none; width: 32px; height: 18px; border-radius: 9px; background: var(--line-2); position: relative;
                cursor: pointer; margin: 0; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
                       background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(14px); }
.switch input:focus-visible { outline: none; box-shadow: var(--ring); }

/* an entry in a list section (job, school, project...) */
.entries { display: flex; flex-direction: column; gap: 10px; }
.entry { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1);
         transition: border-color .2s, box-shadow .2s; }
.entry:hover { border-color: var(--line-2); }
.entry.open { border-color: var(--brand-line); box-shadow: var(--shadow-2); }
.entry-head { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 6px; min-height: 60px; }
.entry-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 4px; border: 0;
              background: transparent; cursor: pointer; text-align: left; border-radius: 8px; }
.entry-main:focus-visible { outline: none; box-shadow: var(--ring); }
.entry-title { flex: 1; min-width: 0; }
.entry-title b { display: block; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-title b.placeholder { color: var(--faint); font-weight: 550; }
.entry-title small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden;
                     text-overflow: ellipsis; }
.entry .chev { width: 18px; height: 18px; color: var(--faint); transition: transform .25s var(--ease); flex: none; }
.entry.open .chev { transform: rotate(180deg); }
.entry .tools { display: flex; opacity: 0; transition: opacity .15s; }
.entry:hover .tools, .entry:focus-within .tools, .entry.open .tools { opacity: 1; }
.fold { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s var(--ease); }
.entry.open .fold { grid-template-rows: 1fr; }
.fold > div { overflow: hidden; min-height: 0; }
.entry-body { padding: 16px 18px 18px; border-top: 1px solid var(--line); }
.entry.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent); } }
.leaving { animation: leave .2s var(--ease) forwards; }
@keyframes leave { to { opacity: 0; transform: scale(.98); } }
.entering { animation: enter .3s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(-6px); } }
.list-empty { padding: 30px 18px; text-align: center; color: var(--muted); border: 1.5px dashed var(--line-2);
              border-radius: var(--radius); }
.list-empty .btn { margin-top: 12px; }
.notice { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 14px;
          border-radius: 9px; background: var(--warn-soft); font-size: 13px; }
.notice input { height: 30px; padding: 0 8px; border: 1px solid var(--line-2); border-radius: 7px; background: var(--panel); }

/* drag handle and dragging */
.grip { width: 24px; height: 32px; display: grid; place-items: center; color: var(--faint); opacity: .55; cursor: grab; flex: none;
        border-radius: 6px; touch-action: none; transition: opacity .15s, background .15s; }
.grip:hover { opacity: 1; background: var(--hover); }
.grip svg { width: 14px; height: 14px; }
.sorting, .sorting * { cursor: grabbing !important; user-select: none !important; }
.sort-drag { position: fixed !important; z-index: 90; margin: 0 !important; pointer-events: none; transition: none !important;
             box-shadow: var(--shadow-3) !important; }
.sort-ph { border: 1.5px dashed var(--brand-line); background: var(--brand-soft); border-radius: 10px; flex: none; }

/* bullet points */
.points-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 20px 0 8px; }
.points-head b { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.points { display: flex; flex-direction: column; gap: 6px; }
.point { display: flex; align-items: flex-start; gap: 4px; position: relative; background: var(--panel); border-radius: 10px; }
.point .grip { margin-top: 3px; }
.point textarea { flex: 1; min-height: 38px; padding: 8px 11px 8px 25px; border: 1px solid var(--line); border-radius: 9px;
                  background: var(--panel); resize: none; overflow: hidden; line-height: 1.55;
                  transition: border-color .15s, box-shadow .15s; }
.point::before { content: ""; position: absolute; left: 40px; top: 17px; width: 5px; height: 5px; border-radius: 50%;
                 background: var(--faint); pointer-events: none; transition: background .15s; }
.point:focus-within::before { background: var(--brand); }
.point textarea:hover { border-color: var(--line-2); }
.point textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
.point .icon-btn { margin-top: 3px; opacity: 0; }
.point:hover .icon-btn, .point:focus-within .icon-btn { opacity: 1; }
.add-row { margin: 10px 0 0 28px; }

/* skills */
.groups { display: flex; flex-direction: column; gap: 12px; }
.group { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1);
         padding: 8px 10px 14px 6px; transition: border-color .2s, box-shadow .2s; }
.group:focus-within { border-color: var(--brand-line); box-shadow: var(--shadow-2); }
.group-head { display: flex; align-items: center; gap: 4px; }
.group-name { flex: 1; min-width: 0; height: 36px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px;
              background: transparent; font-weight: 650; font-size: 14.5px; transition: border-color .15s, background .15s; }
.group-name:hover { border-color: var(--line); }
.group-name:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); background: var(--panel); }
.group-name::placeholder { color: var(--faint); font-weight: 550; }
.group .count { font-size: 12px; color: var(--faint); white-space: nowrap; padding: 0 4px; }
.group .tools { display: flex; opacity: 0; transition: opacity .15s; }
.group:hover .tools, .group:focus-within .tools { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; padding: 8px 0 0 32px; min-height: 40px; }
.chip { display: inline-flex; align-items: center; height: 30px; padding: 0 3px 0 11px; border-radius: 7px;
        background: var(--brand-soft); border: 1px solid var(--brand-line); color: var(--text); font-size: 13px;
        cursor: grab; user-select: none; touch-action: none; transition: border-color .15s; max-width: 100%; }
.chip:hover { border-color: var(--brand); }
.chip .txt { cursor: text; padding: 4px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip input { border: 0; outline: none; background: transparent; padding: 0; min-width: 40px; height: 26px; font-size: 13px; }
.chip.editing { background: var(--panel); border-color: var(--brand); box-shadow: var(--ring); cursor: default; padding-right: 8px; }
.chip button { width: 22px; height: 22px; margin-left: 3px; border: 0; background: transparent; border-radius: 5px; cursor: pointer;
               color: var(--muted); display: grid; place-items: center; flex: none; }
.chip button:hover { color: var(--danger); background: var(--danger-soft); }
.chip button svg { width: 12px; height: 12px; }
.chips .sort-ph { border-radius: 7px; height: 30px; }
.chip-add { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px; border-radius: 7px;
            border: 1px dashed var(--line-2); color: var(--muted); min-width: 120px; flex: 0 1 170px; cursor: text;
            transition: border-color .15s, background .15s, box-shadow .15s, flex-basis .2s var(--ease); }
.chip-add svg { width: 14px; height: 14px; flex: none; }
.chip-add input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; height: 28px; padding: 0;
                  font-size: 13px; }
.chip-add input::placeholder { color: var(--muted); }
.chip-add:hover { border-color: var(--muted); }
.chip-add:focus-within { border-style: solid; border-color: var(--brand); background: var(--panel); box-shadow: var(--ring);
                         flex-basis: 230px; color: var(--brand); }
.add-group { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 50px;
             border: 1.5px dashed var(--line-2); border-radius: var(--radius); background: transparent; color: var(--muted);
             cursor: pointer; font-weight: 600; margin-top: 12px; transition: color .15s, border-color .15s, background .15s; }
.add-group:hover { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.add-group svg { width: 17px; height: 17px; }

/* links */
.links { display: flex; flex-direction: column; gap: 8px; }
.link-row { display: grid; grid-template-columns: 24px 150px 1fr 32px; gap: 8px; align-items: center; background: var(--panel); }

/* ------------------------------------------------------------------ preview */
.preview-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--stage); position: relative;
                overflow: hidden; }
.pv-bar { display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 52px; flex: none; background: var(--panel);
          border-bottom: 1px solid var(--line); }
.pv-bar .pages { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--hover); }
.seg button { height: 28px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent; cursor: pointer;
              font-size: 12.5px; font-weight: 550; color: var(--muted); transition: background .15s, color .15s; }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: var(--shadow-2); }
.stage { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 28px 64px 80px 28px; }
.sheet { position: relative; margin: 0 auto; background: #fff; border-radius: 2px;
         box-shadow: 0 1px 3px rgba(0, 0, 0, .1), 0 10px 40px rgba(0, 0, 0, .12); }
.sheet .host { position: absolute; top: 0; left: 0; transform-origin: 0 0; cursor: pointer; }
.page-mark { position: absolute; left: 0; right: 0; height: 0; border-top: 1px dashed rgba(220, 38, 38, .6);
             pointer-events: none; }
.page-mark span { position: absolute; right: -8px; top: -10px; transform: translateX(100%); font-size: 10.5px; font-weight: 650;
                  color: #b91c1c; background: #fee2e2; padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.pv-banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 14px; flex: none;
             background: var(--warn-soft); border-bottom: 1px solid var(--line); font-size: 13px; }
.pv-hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 6px 13px; border-radius: 999px;
           background: rgba(17, 24, 39, .8); color: #fff; font-size: 12px; pointer-events: none; white-space: nowrap;
           transition: opacity .5s; }
.pv-hint.off { opacity: 0; }

/* design drawer */
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(440px, 100%); z-index: 15; background: var(--panel);
          border-left: 1px solid var(--line); box-shadow: var(--shadow-3); display: flex; flex-direction: column;
          animation: drawer-in .28s var(--ease); }
.drawer.closing { animation: drawer-out .2s var(--ease) forwards; }
@keyframes drawer-in { from { transform: translateX(30px); opacity: 0; } }
@keyframes drawer-out { to { transform: translateX(30px); opacity: 0; } }
.drawer-head { display: flex; align-items: center; gap: 8px; padding: 0 10px 0 18px; height: 52px; flex: none;
               border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 15px; flex: 1; }
.drawer-body { overflow-y: auto; overscroll-behavior: contain; padding: 18px; }
.drawer h3 { margin: 0 0 10px; font-size: 12px; color: var(--muted); font-weight: 650; text-transform: uppercase;
             letter-spacing: .06em; }
.drawer section + section { margin-top: 24px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--line-2);
          cursor: pointer; padding: 0; transition: transform .15s, box-shadow .15s; }
.swatch:hover { transform: scale(1.1); }
.swatch.on { box-shadow: 0 0 0 2px var(--text); }
.swatches input[type=color] { width: 30px; height: 30px; padding: 0; border: 0; background: none; cursor: pointer; }
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tpl { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--panel);
       text-align: left; padding: 0; transition: border-color .15s, box-shadow .15s, transform .2s var(--ease); }
.tpl:hover { border-color: var(--line-2); transform: translateY(-2px); box-shadow: var(--shadow-2); }
.tpl.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.tpl .mini { position: relative; aspect-ratio: 1 / 1.05; overflow: hidden; background: #fff; border-bottom: 1px solid var(--line); }
.tpl .mini .host { position: absolute; top: 0; left: 0; transform-origin: 0 0; pointer-events: none; }
.tpl .tpl-name { display: block; padding: 8px 10px 0; font-weight: 650; font-size: 13px; }
.tpl .tpl-desc { display: block; padding: 1px 10px 10px; font-size: 11.5px; color: var(--muted); line-height: 1.4; }

/* ------------------------------------------------------------ menus, dialogs */
.menu { position: fixed; z-index: 60; min-width: 200px; padding: 5px; background: var(--panel); border: 1px solid var(--line);
        border-radius: 11px; box-shadow: var(--shadow-3); animation: pop .14s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; height: 34px; padding: 0 10px; border: 0;
               background: transparent; border-radius: 7px; cursor: pointer; text-align: left; font-size: 13.5px; }
.menu button:hover, .menu button:focus-visible { background: var(--hover); outline: none; }
.menu button.danger { color: var(--danger); }
.menu button.danger svg { color: var(--danger); }
.menu button svg { width: 15px; height: 15px; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 0; }
.menu .menu-label { padding: 6px 10px 3px; font-size: 11.5px; color: var(--muted); font-weight: 650; }

dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 32px));
         background: var(--panel); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, .3); }
dialog[open] { animation: dlg-in .22s var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
dialog::backdrop { background: rgba(15, 18, 25, .45); }
.dlg-head { padding: 20px 22px 0; }
.dlg-head h2 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.dlg-head p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.dlg-body { padding: 16px 22px; display: flex; flex-direction: column; gap: 12px; max-height: 65vh; overflow-y: auto; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 20px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line-2);
          border-radius: 11px; cursor: pointer; transition: border-color .15s, background .15s; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.choice input { margin-top: 3px; accent-color: var(--brand); }
.choice b { display: block; }
.choice small { color: var(--muted); }
.choice select { margin-top: 8px; width: 100%; height: 34px; border: 1px solid var(--line-2); border-radius: 8px;
                 background: var(--panel); padding: 0 8px; }
.versions { display: flex; flex-direction: column; }
.version { display: flex; align-items: center; gap: 8px; padding: 10px 2px; border-top: 1px solid var(--line); }
.version:first-child { border-top: 0; }
.version div { flex: 1; min-width: 0; }
.version small { display: block; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; display: flex; align-items: center; gap: 14px;
         padding: 10px 10px 10px 16px; border-radius: 11px; background: #111827; color: #f9fafb;
         box-shadow: 0 12px 32px rgba(0, 0, 0, .3); font-size: 13.5px; max-width: calc(100vw - 32px); min-height: 44px;
         transform: translate(-50%, 0); transition: transform .25s var(--ease), opacity .25s; }
.toast.off { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }
.toast button { border: 0; background: rgba(255, 255, 255, .1); color: #bfdbfe; font-weight: 650; cursor: pointer;
                padding: 5px 10px; border-radius: 7px; }
.toast button:hover { background: rgba(255, 255, 255, .18); }


@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }

/* ------------------------------------------------------------- medium width */
@media (max-width: 1280px) {
  .workspace { grid-template-columns: 64px minmax(400px, 560px) minmax(0, 1fr); }
  .rail { padding: 14px 8px; align-items: center; }
  .rail-item { width: 44px; justify-content: center; padding: 0; }
  .rail-item .label, .rail-label, .rail-foot { display: none; }
  .rail-item .n { position: absolute; top: 1px; right: 0; min-width: 17px; height: 15px; padding: 0 4px; font-size: 10px; }
  .stage { padding: 22px 56px 80px 22px; }
}

/* ------------------------------------------------------------------- narrow */
@media (max-width: 900px) {
  .workspace { display: flex; flex-direction: column; }
  .rail { flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden; padding: 6px 8px; flex: none;
          border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .rail-item { width: auto; padding: 0 12px; flex: none; }
  .rail-item .label { display: inline; }
  .rail-item .n { position: static; }
  .form-pane, .preview-pane { flex: 1; min-height: 0; border-right: 0; }
  .workspace.show-preview .form-pane, .workspace.show-preview .rail, .workspace:not(.show-preview) .preview-pane { display: none; }
  .stage { padding: 14px 14px 90px; }
  .form-inner { padding: 18px 16px 120px; }
  .topbar { padding: 0 8px; gap: 4px; }
  .editing .topbar .brand { display: none; }
  .editing .title-input { min-width: 0; flex: 1 1 auto; }
  .editing .status:not(.bad) { display: none; }
  .hide-narrow { display: none !important; }
  .page-mark span { right: 4px; transform: none; top: -18px; }
  .pv-hint { display: none; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .lib { padding: 20px 16px 60px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 12px; }
  .link-row { grid-template-columns: 24px 1fr 32px; }
  .link-row .input:nth-child(3) { grid-column: 2; }
  .point .icon-btn, .entry .tools, .group .tools { opacity: 1; }
  .chips { padding-left: 6px; }
}

/* ------------------------------------------------------------------ extras */
.entries, .points, .chips, .groups, .rows, .links { position: relative; }
.no-anim .fold, .no-anim .chev { transition: none !important; }
.rows { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: flex-start; gap: 8px; padding: 8px 8px 8px 4px; background: var(--panel);
       border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); transition: border-color .2s; }
.row:focus-within { border-color: var(--brand-line); }
.row-fields { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.row .input { min-width: 0; }
.row .icon-btn { opacity: .6; margin-top: 3px; }
.row .grip { margin-top: 3px; }
.row:hover .icon-btn, .row:focus-within .icon-btn { opacity: 1; }
.pulse { animation: pulse-ring 1.2s ease-out; }
@keyframes pulse-ring { from { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 40%, transparent); } }
@media (max-width: 560px) {
  .row .input { flex: 1 1 100% !important; }
  .points-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .points-head .kbd-hint { display: none; }
}
@media (max-width: 480px) {
  .cards { grid-template-columns: 1fr; }
  .card.new { min-height: 120px; }
}
