/* Application chrome: themes, top bar, home screen, settings, preview column, editing affordances, history panel */

/* ---------- design tokens ---------- */
:root {
  color-scheme: light;
  --accent:#4b5580;            /* the CV's accent colour (set from the document) */
  --s:1;
  --ui:#3b4a8a;                /* the app's own accent */
  --bg:#e9eaee; --panel:#fff; --hover:#f1f2f6; --field:#fff;
  --line:#dfe1e7; --ink:#16181d; --muted:#6b7080;
  --danger:#c0392b; --ok:#2e8b57;
  --shadow:0 4px 30px rgba(0,0,0,.15);
  --barh:44px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ui:#8b9bff;
  --bg:#14161b; --panel:#1d2027; --hover:#292d36; --field:#252932;
  --line:#2c303a; --ink:#e7e9ee; --muted:#959cae;
  --danger:#ff6b5e; --ok:#5ec48a;
  --shadow:0 4px 30px rgba(0,0,0,.55);
}
* { box-sizing:border-box; margin:0; padding:0; }
html, body { height:100%; }
/* Scrolling pages: the body must grow with the content, or the sticky top bar scrolls away with it. */
body.view-profile, body.view-import, body.view-home { height:auto; min-height:100%; }
body { font-family:Inter,"Segoe UI",system-ui,sans-serif; background:var(--bg); color:var(--ink); font-size:13px; }
button, select, input { font:inherit; color:inherit; }
.hint { color:var(--muted); font-size:12px; }
.sp { flex:1; }

/* ---------- the single top bar (doubles as the window title bar in the desktop app) ---------- */
.bar {
  position:sticky; top:0; z-index:40; height:var(--barh); display:flex; align-items:center; gap:6px;
  background:var(--panel); border-bottom:1px solid var(--line);
  padding-left:max(10px, env(titlebar-area-x, 0px));
  padding-right:calc(100vw - env(titlebar-area-x, 0px) - env(titlebar-area-width, 100vw) + 10px);
  -webkit-app-region:drag; user-select:none; white-space:nowrap;
}
.bar button, .bar input, .bar select, .bar .menu, .bar .seg { -webkit-app-region:no-drag; }
.bar .grp { display:flex; align-items:center; gap:2px; }
.bar .sep { width:1px; height:20px; background:var(--line); margin:0 6px; }
#docname { font-weight:600; max-width:240px; overflow:hidden; text-overflow:ellipsis; padding:0 6px; }
.btn { border:1px solid transparent; background:transparent; border-radius:7px; padding:5px 10px; cursor:pointer; display:inline-flex; align-items:center; gap:6px; height:30px; }
.btn:hover:not(:disabled) { background:var(--hover); }
.btn:disabled { opacity:.4; cursor:default; }
.btn.line { border-color:var(--line); }
.btn.ic { padding:0; width:30px; justify-content:center; font-size:15px; }
.btn[aria-pressed="true"] { background:color-mix(in srgb, var(--ui) 18%, transparent); color:var(--ui); border-color:color-mix(in srgb, var(--ui) 40%, transparent); }
.btn.primary { background:var(--ui); color:#fff; border-color:var(--ui); }
:root[data-theme="dark"] .btn.primary { color:#10131a; }
.btn.primary:hover:not(:disabled) { filter:brightness(1.08); background:var(--ui); }

.seg { display:inline-flex; background:var(--hover); border-radius:8px; padding:2px; }
.seg button { border:none; background:transparent; border-radius:6px; padding:4px 10px; height:26px; cursor:pointer; color:var(--muted); }
.seg button.on { background:var(--panel); color:var(--ink); box-shadow:0 1px 3px rgba(0,0,0,.18); font-weight:500; }

/* the one Save button: Saved (greyed) / Saving… (spinner) / Save / Retry / Save… */
.save { min-width:92px; justify-content:center; }
.save[data-state="saved"] { color:var(--muted); }
.save[data-state="error"] { color:var(--danger); border-color:var(--danger); }
.spin { width:12px; height:12px; border:2px solid currentColor; border-right-color:transparent; border-radius:50%; animation:spin .7s linear infinite; display:inline-block; }
@keyframes spin { to { transform:rotate(360deg); } }

/* dropdown menus */
.menu { position:relative; }
.menu .pop { display:none; position:absolute; right:0; top:calc(100% + 6px); min-width:210px; padding:6px; background:var(--panel);
             border:1px solid var(--line); border-radius:10px; box-shadow:0 12px 36px rgba(0,0,0,.28); z-index:60; -webkit-app-region:no-drag; }
.menu.open .pop { display:block; }
.menu .pop .item2 { display:flex; width:100%; justify-content:space-between; gap:18px; text-align:left; border:none; background:transparent; padding:7px 10px; border-radius:6px; cursor:pointer; }
.menu .pop .item2:hover { background:var(--hover); }
.menu .pop .item2 kbd { color:var(--muted); font:inherit; font-size:11px; }
.menu .pop hr { border:none; border-top:1px solid var(--line); margin:5px 0; }
.menu .pop .field { padding:6px 10px; }
.menu .pop .field > .hint { display:block; margin-bottom:6px; }
.menu .pop input[type="range"] { width:100%; }
.swatches { display:flex; flex-wrap:wrap; gap:6px; }
.swatches button { width:22px; height:22px; border-radius:50%; border:2px solid var(--panel); box-shadow:0 0 0 1px var(--line); cursor:pointer; padding:0; }
.swatches button.on { box-shadow:0 0 0 2px var(--ui); }
.swatches input[type="color"] { width:24px; height:24px; border:none; padding:0; background:none; cursor:pointer; }

/* ---------- views ---------- */
.view-home .editor-only, .view-home .stage, .view-home .hist, .view-home .treeprev { display:none !important; }
.view-editor .home, .view-editor .home-only { display:none; }

/* ---------- editor stage ---------- */
.stage { padding:24px 12px 60px; display:flex; justify-content:center; align-items:flex-start; gap:24px; }
.edcol { flex:none; }
.pvcol { display:none; flex:1 1 0; min-width:0; max-width:794px; }
@media (min-width:1500px) { .pvcol { display:block; } .nopv .pvcol { display:none; } }
.pvhead { display:flex; align-items:center; gap:8px; margin-bottom:10px; color:var(--muted); }
.pvhead select { background:var(--field); border:1px solid var(--line); border-radius:6px; padding:4px 8px; }
.pvhead button { background:var(--field); border:1px solid var(--line); border-radius:6px; padding:4px 10px; cursor:pointer; }
.pvhead button:hover { background:var(--hover); }
.pvwrap { overflow:hidden; }
.po { display:none; }
.popout .po { display:inline-block; }
.popout #pop { display:none; }
.popout .pvcol { display:block !important; max-width:none; }
.popout .edcol, .popout .bar, .popout .home { display:none !important; }
.popout .stage { padding-top:16px; }
.popped .pvcol { display:none !important; }

/* ---------- editing affordances ---------- */
.ed { outline:none; border-radius:2px; }
.ed:hover { background:rgba(75,85,128,.08); }
.ed:focus { background:rgba(75,85,128,.14); box-shadow:0 0 0 2px rgba(75,85,128,.25); }
.ed:empty::before { content:attr(data-ph); color:#bbb; }
a.lk { color:inherit; text-decoration:none; }
.pvwrap a.lk:hover { text-decoration:underline; }
.item { position:relative; }
.ctl { position:absolute; top:0; right:-4px; display:none; gap:2px; z-index:2; }
.ctl button { width:18px; height:18px; line-height:16px; text-align:center; font-size:12px; border:none; border-radius:9px; background:#3a3d47; color:#fff; cursor:pointer; padding:0; }
.ctl button.x { background:#c0392b; font-size:13px; }
.ctl button:disabled { opacity:.3; cursor:default; }
.item:hover > .ctl { display:flex; }
.add { font-size:.8em; color:var(--muted); background:none; border:1px dashed #c9ccd6; border-radius:4px; padding:1px 8px; cursor:pointer; margin-top:4px; }
.add:hover { color:var(--accent); border-color:var(--accent); }
.exporting .ctl, .exporting .add, .exporting .hist { display:none !important; }
.exporting .ed:empty::before { content:none; }
.exporting .ed:hover, .exporting .ed:focus { background:none; box-shadow:none; }
.exporting .page { box-shadow:none; }

/* ---------- history panel (undo tree) ---------- */
.hist { display:none; position:fixed; left:0; right:0; bottom:0; height:230px; z-index:20; background:var(--panel); border-top:1px solid var(--line); box-shadow:0 -6px 24px rgba(0,0,0,.18); flex-direction:column; }
.histopen .hist { display:flex; }
.histopen .stage { padding-bottom:260px; }
.popout .hist { display:none !important; }
.hist-head { display:flex; align-items:center; gap:12px; padding:6px 16px; border-bottom:1px solid var(--line); }
.hist-head b { font-weight:600; }
.tree { flex:1; overflow:auto; }
.tree svg { display:block; }
.tree .edge { stroke:var(--line); stroke-width:2; fill:none; }
.tree .edge.on { stroke:var(--ui); }
.tree .grid { stroke:var(--hover); stroke-width:1; }
.tree .tick { fill:var(--muted); font-size:10px; text-anchor:middle; font-family:Inter,system-ui,sans-serif; }
.tree .hit { fill:transparent; cursor:pointer; }
.tree .dot { fill:var(--panel); stroke:var(--muted); stroke-width:2; pointer-events:none; }
.tree .dot.act { stroke:var(--ui); }
.tree .dot.cur { fill:var(--ui); stroke:var(--ui); }
.tree g[data-id]:hover .dot { stroke:var(--ink); }
.treeprev { position:fixed; z-index:70; background:var(--panel); border:1px solid var(--line); border-radius:8px; box-shadow:0 8px 30px rgba(0,0,0,.35); padding:8px; pointer-events:none; font-size:12px; }
.treeprev[hidden] { display:none; }
.treeprev .pvmeta { display:flex; justify-content:space-between; gap:14px; margin-bottom:6px; }
.treeprev .pvmeta span { color:var(--muted); }
.treeprev .pvfit { overflow:hidden; border:1px solid var(--line); }
.treeprev .page { box-shadow:none; }

/* ---------- home screen ---------- */
.home { max-width:1180px; margin:0 auto; padding:32px 40px 80px; }
.home h1 { font-size:26px; font-weight:700; letter-spacing:-.02em; }
.home .sub { color:var(--muted); margin-top:4px; }
.home section { margin-top:34px; }
.home h2 { font-size:12px; text-transform:uppercase; letter-spacing:.12em; color:var(--muted); font-weight:600; margin-bottom:14px; display:flex; align-items:center; gap:12px; }
.home h2 .seg { text-transform:none; letter-spacing:0; }
.home .row { display:flex; gap:10px; flex-wrap:wrap; }
.home .big { height:40px; padding:0 16px; border:1px solid var(--line); background:var(--panel); }
.home .big:hover { background:var(--hover); }
.home .big.primary { background:var(--ui); border-color:var(--ui); }
.cards { display:grid; grid-template-columns:repeat(auto-fill, 170px); gap:22px 20px; }
.tile { position:relative; text-align:left; background:none; border:none; padding:0; cursor:pointer; width:170px; }
.tile .thumb { width:170px; height:240px; overflow:hidden; background:#fff; border:1px solid var(--line); border-radius:6px; box-shadow:0 2px 10px rgba(0,0,0,.12); transition:transform .12s, box-shadow .12s; position:relative; }
.tile:hover .thumb { transform:translateY(-3px); box-shadow:0 8px 22px rgba(0,0,0,.25); }
.tile .thumb .page { box-shadow:none; pointer-events:none; transform-origin:top left; }
.tile .thumb.missing { display:flex; align-items:center; justify-content:center; color:#9aa0b0; font-size:12px; background:var(--hover); }
.tile .name { margin-top:8px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tile .meta { color:var(--muted); font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tile .rm { position:absolute; top:6px; right:6px; width:22px; height:22px; border-radius:11px; border:none; background:rgba(20,22,27,.75); color:#fff; cursor:pointer; display:none; line-height:20px; padding:0; }
.tile:hover .rm { display:block; }
.tile .swatch { display:inline-block; width:9px; height:9px; border-radius:50%; margin-right:6px; vertical-align:-1px; }
.home .empty { color:var(--muted); }

/* ---------- settings dialog ---------- */
dialog#settings { margin:auto; border:1px solid var(--line); border-radius:14px; background:var(--panel); color:var(--ink); padding:0; width:min(560px, 92vw); box-shadow:0 20px 60px rgba(0,0,0,.4); }
dialog#settings::backdrop { background:rgba(0,0,0,.45); }
.sd-head { display:flex; align-items:center; justify-content:space-between; padding:16px 20px; border-bottom:1px solid var(--line); }
.sd-head b { font-size:16px; }
.sd-body { padding:6px 20px 18px; max-height:70vh; overflow:auto; }
.sd-group { margin-top:16px; }
.sd-group > .hint { text-transform:uppercase; letter-spacing:.1em; font-weight:600; display:block; margin-bottom:6px; }
.sd-row { display:flex; align-items:center; justify-content:space-between; gap:16px; padding:9px 0; border-bottom:1px solid var(--line); }
.sd-row:last-child { border-bottom:none; }
.sd-row small { display:block; color:var(--muted); margin-top:2px; max-width:300px; word-break:break-all; }
.sd-row select { background:var(--field); border:1px solid var(--line); border-radius:6px; padding:5px 8px; }
.switch { position:relative; width:38px; height:22px; flex:none; }
.switch input { opacity:0; width:100%; height:100%; position:absolute; margin:0; cursor:pointer; z-index:1; }
.switch i { position:absolute; inset:0; background:var(--line); border-radius:11px; transition:.15s; }
.switch i::after { content:""; position:absolute; top:3px; left:3px; width:16px; height:16px; border-radius:50%; background:#fff; transition:.15s; }
.switch input:checked + i { background:var(--ui); }
.switch input:checked + i::after { transform:translateX(16px); }

/* ---------- print / export ---------- */
@media print {
  @page { size:A4; margin:0; }
  body { background:#fff; }
  .bar, .home, .hist, .treeprev, dialog { display:none !important; }
  .stage { padding:0; display:block; }
  .page { box-shadow:none; min-height:296.8mm; }
  .ctl, .add { display:none !important; }
  .pvcol { display:none !important; }
  .popout .pvcol { display:block !important; }
  .popout .pvhead { display:none; }
  .pvwrap .page { zoom:1 !important; }
  .ed:hover, .ed:focus { background:none; box-shadow:none; }
}

/* ---------- right-click menu + link box ---------- */
.ctx { position:fixed; z-index:90; min-width:220px; padding:6px; background:var(--panel); border:1px solid var(--line); border-radius:10px; box-shadow:0 12px 36px rgba(0,0,0,.35); }
.ctx[hidden], .linkpop[hidden] { display:none; }
.ctx .item2 { display:flex; width:100%; justify-content:space-between; gap:22px; text-align:left; border:none; background:transparent; padding:6px 10px; border-radius:6px; cursor:pointer; }
.ctx .item2:hover:not(:disabled) { background:var(--hover); }
.ctx .item2:disabled { opacity:.38; cursor:default; }
.ctx .item2 kbd { color:var(--muted); font:inherit; font-size:11px; }
.ctx hr { border:none; border-top:1px solid var(--line); margin:5px 0; }
.linkpop { position:fixed; z-index:90; padding:10px; background:var(--panel); border:1px solid var(--line); border-radius:10px; box-shadow:0 12px 36px rgba(0,0,0,.35); width:380px; max-width:92vw; }
.linkpop .hint { margin-bottom:6px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.linkpop .lp-row { display:flex; gap:6px; }
.linkpop input { flex:1; min-width:0; background:var(--field); border:1px solid var(--line); border-radius:7px; padding:0 10px; height:30px; outline:none; }
.linkpop input:focus { border-color:var(--ui); }
@media print { .ctx, .linkpop { display:none !important; } }

.ctx .item2.sug { font-weight:600; }
.sd-input { background:var(--field); border:1px solid var(--line); border-radius:7px; padding:0 10px; height:30px; flex:1; min-width:0; outline:none; }
.sd-input:focus { border-color:var(--ui); }
.words { display:flex; flex-wrap:wrap; gap:6px; max-width:300px; justify-content:flex-end; }
.chip { display:inline-flex; align-items:center; gap:2px; background:var(--hover); border-radius:12px; padding:2px 4px 2px 10px; }
.chip button { border:none; background:none; cursor:pointer; color:var(--muted); padding:0 4px; font-size:14px; }
.chip button:hover { color:var(--danger); }

/* ---------- profile: badge, view, form ---------- */
.view-profile .editor-only, .view-profile .stage, .view-profile .hist, .view-profile .treeprev, .view-profile .home { display:none !important; }
.view-home .not-home { display:none !important; }
.badge { border:1px solid color-mix(in srgb, var(--ui) 45%, transparent); background:color-mix(in srgb, var(--ui) 14%, transparent); color:var(--ui); border-radius:999px; padding:2px 10px; height:24px; cursor:pointer; font-size:12px; -webkit-app-region:no-drag; }
.badge[hidden] { display:none; }
.badge.off { border-color:var(--line); background:transparent; color:var(--muted); }
.askdlg .choices .btn:hover { border-color:var(--ui); }
.toast { position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:var(--ink); color:var(--bg); padding:9px 16px; border-radius:10px; z-index:100; box-shadow:0 8px 24px rgba(0,0,0,.3); }
.toast[hidden] { display:none; }

.home .profilecard { display:flex; gap:26px; align-items:center; padding:18px 20px; border:1px solid var(--line); background:var(--panel); border-radius:14px; }
.home .profilecard h2 { margin-bottom:6px; }
.home .profilecard .pc-name { font-size:20px; font-weight:700; }

.profile-view { display:none; }
.view-profile .profile-view { display:block; }
.pv-wrap { max-width:clamp(1180px, 92vw, 2200px); margin:0 auto; padding:28px 40px 80px; display:grid; grid-template-columns:minmax(0,1fr) clamp(440px, 38vw, 920px); gap:36px; align-items:start; }
@media (max-width:1050px) { .pv-wrap { grid-template-columns:1fr; } .pv-side { display:none; } }
.pv-top { display:flex; justify-content:space-between; gap:20px; align-items:flex-start; }
.pv-top h1 { font-size:26px; letter-spacing:-.02em; }
.pv-top .sub { color:var(--muted); margin-top:4px; max-width:520px; }
/* profile form (My profile + import review): one card per section */
.pv-nav { position:sticky; top:var(--barh); z-index:5; display:flex; flex-wrap:wrap; gap:4px; margin:18px -6px 0; padding:8px 6px; background:var(--bg); box-shadow:0 1px 0 var(--line); }
.pv-nav button:not(.btn) { border:1px solid transparent; background:transparent; color:var(--muted); border-radius:999px; padding:4px 12px; cursor:pointer; font:inherit; font-size:13px; }
.pv-nav .pv-done { margin-left:auto; }
.pv-nav .pv-done + .btn { margin-left:2px; }
.pv-nav button i { font-style:normal; font-size:11px; opacity:.7; margin-left:2px; }
.pv-nav button:not(.btn):hover { background:var(--hover); color:var(--ink); }
.pv-nav button.on:not(.btn) { background:var(--panel); border-color:var(--line); color:var(--ink); font-weight:600; }
.ps { margin-top:14px; padding:18px 20px 20px; background:var(--panel); border:1px solid var(--line); border-radius:14px; scroll-margin-top:120px; }
.ps-head { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:6px; }
.ps h3 { font-size:15px; font-weight:650; letter-spacing:-.01em; margin:0; }
.ps-head .hint { margin-top:2px; font-size:12px; }
.sublbl { font-size:12px; font-weight:600; color:var(--muted); margin:16px 0 6px; }
.sublbl small { font-weight:400; opacity:.8; margin-left:4px; }
.fld { display:block; margin-top:10px; min-width:0; }
.fld > span { display:block; font-size:12px; color:var(--muted); margin-bottom:4px; }
.fld > span:empty { display:none; }
.fld input, .fld textarea { width:100%; background:var(--field); border:1px solid var(--line); border-radius:8px; padding:7px 10px; outline:none; font:inherit; color:inherit; resize:none; line-height:1.45; }
.fld input { height:34px; }
.fld input::placeholder, .fld textarea::placeholder { color:var(--muted); opacity:.7; }
.fld input:focus, .fld textarea:focus { border-color:var(--ui); box-shadow:0 0 0 3px color-mix(in srgb, var(--ui) 20%, transparent); }
.grid2 { display:grid; grid-template-columns:1fr 1fr; gap:0 12px; }
.grid2.wide1 { grid-template-columns:minmax(0,1.6fr) minmax(0,1fr); }
.grid2.skill { grid-template-columns:minmax(0,.7fr) minmax(0,2fr); align-items:start; }
.split { display:grid; grid-template-columns:1fr 1fr; gap:0 20px; }
@media (max-width:1250px) { .split { grid-template-columns:1fr; } }

/* entry cards (a job, a school, a project, a skill group) */
.pc { border:1px solid var(--line); background:var(--hover); border-radius:11px; padding:10px 14px 14px; margin-top:10px; }
.pc-head { display:flex; align-items:center; justify-content:space-between; gap:10px; min-height:24px; }
.pc-title { font-weight:600; font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.pc .fld:first-child, .pc .grid2 .fld { margin-top:6px; }

/* compact rows of short lists (address lines, links, subjects) */
.lrow { display:flex; align-items:center; gap:6px; margin-top:6px; }
.pc .lrow > .fld, .lrow > .fld { flex:1; margin-top:0; }
.lrow.g > .fld:nth-child(2) { flex:0 0 96px; }
.lrow input { height:32px; }
.grades .lrow:first-child { margin-top:0; }

/* move / remove: quiet until the row or card is hovered or focused */
.pc-ctl { display:inline-flex; gap:2px; white-space:nowrap; opacity:.35; transition:opacity .12s; }
.pc-head:hover .pc-ctl, .pc:focus-within > .pc-head .pc-ctl, .lrow:hover .pc-ctl, .lrow:focus-within .pc-ctl, .pc-ctl:focus-within { opacity:1; }
.pc-ctl button { width:24px; height:24px; border:none; border-radius:6px; background:transparent; color:var(--ink); cursor:pointer; font-size:13px; }
.pc-ctl button:hover:not(:disabled) { background:var(--line); }
.pc-ctl button.x:hover { background:var(--danger); color:#fff; }
.pc-ctl button:disabled { opacity:.25; cursor:default; }

.addrow { display:block; width:100%; margin-top:10px; padding:8px; border:1px dashed var(--line); border-radius:9px; background:transparent; color:var(--muted); cursor:pointer; font:inherit; font-size:13px; text-align:center; }
.addrow:hover { border-color:var(--ui); color:var(--ui); background:color-mix(in srgb, var(--ui) 6%, transparent); }
.pc .addrow { background:var(--panel); }
.toast { display:flex; align-items:center; gap:14px; }
.toast[hidden] { display:none; }
.toast-act { border:none; background:transparent; color:inherit; font:inherit; font-weight:700; text-decoration:underline; cursor:pointer; padding:0; }
.pv-side { position:sticky; top:calc(var(--barh) + 20px); }
.pv-sidehead { display:flex; align-items:center; gap:10px; margin-bottom:10px; }
.pv-sidehead .hint { margin-left:auto; }
.pv-sidehead select { background:var(--field); border:1px solid var(--line); border-radius:6px; padding:4px 8px; }
.pp-frame { width:100%; max-height:calc(100vh - var(--barh) - 110px); overflow-x:hidden; overflow-y:auto; scrollbar-gutter:stable; cursor:zoom-in; background:#fff; border:1px solid var(--line); border-radius:6px; box-shadow:var(--shadow); }
.pp-frame .page { box-shadow:none; }
@media print { .profile-view, .toast { display:none !important; } }

/* ---------- projects on the home screen ---------- */
.home h2 .projtools { margin-left:auto; display:flex; gap:8px; text-transform:none; letter-spacing:0; font-weight:400; }
.home h2 .projtools input { width:200px; }
.home h2 .projtools select { background:var(--field); border:1px solid var(--line); border-radius:7px; padding:0 8px; height:30px; }
.tile .more { position:absolute; top:6px; right:6px; width:26px; height:22px; border-radius:6px; background:rgba(20,22,27,.78); color:#fff; display:none; text-align:center; line-height:19px; }
.tile:hover .more, .tile:focus-visible .more { display:block; }
.tile .tag { display:inline-block; background:color-mix(in srgb, var(--ui) 18%, transparent); color:var(--ui); border-radius:4px; padding:0 6px; font-size:11px; }
.tile.gone .thumb { opacity:.55; }
.ctx .item2.danger { color:var(--danger); }
dialog.askdlg { margin:auto; border:1px solid var(--line); border-radius:12px; background:var(--panel); color:var(--ink); padding:20px; width:min(420px, 92vw); box-shadow:0 20px 60px rgba(0,0,0,.4); }
dialog.askdlg::backdrop { background:rgba(0,0,0,.45); }
dialog.askdlg h3 { font-size:16px; margin-bottom:12px; }
dialog.askdlg label { display:block; color:var(--muted); font-size:12px; }
dialog.askdlg input { display:block; width:100%; margin-top:6px; background:var(--field); border:1px solid var(--line); border-radius:8px; padding:0 10px; height:34px; color:var(--ink); outline:none; font:inherit; }
dialog.askdlg input:focus { border-color:var(--ui); }
@media print { dialog.askdlg { display:none !important; } }

/* ---------- import ---------- */
.view-import .editor-only, .view-import .stage, .view-import .hist, .view-import .treeprev, .view-import .home, .view-import .profile-view { display:none !important; }
.import-view { display:none; }
.view-import .import-view { display:block; }
.imp-wrap { max-width:760px; margin:0 auto; padding:28px 40px 80px; }
.imp-head { margin:18px 0 22px; }
.imp-head h1 { font-size:26px; letter-spacing:-.02em; }
.imp-head .sub { color:var(--muted); margin-top:6px; }
.dropzone { display:flex; align-items:center; justify-content:space-between; gap:20px; padding:28px; border:2px dashed var(--line); border-radius:14px; background:var(--panel); }
.or { display:flex; align-items:center; gap:14px; color:var(--muted); margin:22px 0 12px; font-size:12px; text-transform:uppercase; letter-spacing:.1em; }
.or::before, .or::after { content:""; flex:1; border-top:1px solid var(--line); }
#imp-paste { width:100%; background:var(--field); border:1px solid var(--line); border-radius:10px; padding:12px; font:inherit; color:inherit; outline:none; resize:vertical; }
#imp-paste:focus { border-color:var(--ui); }
.imp-error { color:var(--danger); margin-top:12px; min-height:18px; }
.dropveil { position:fixed; inset:0; z-index:120; background:rgba(20,22,27,.72); display:flex; align-items:center; justify-content:center; color:#fff; font-size:20px; font-weight:600; pointer-events:none; }
.dropveil[hidden] { display:none; }
.dropveil > div { padding:40px 60px; border:3px dashed rgba(255,255,255,.7); border-radius:18px; }

.imp-ctl { display:flex; align-items:center; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.imp-ctl select { background:var(--field); border:1px solid var(--line); border-radius:7px; padding:0 8px; height:28px; }
.badge2 { font-size:11px; padding:1px 8px; border-radius:999px; border:1px solid var(--line); white-space:nowrap; }
.badge2.ok { color:var(--ok); border-color:color-mix(in srgb, var(--ok) 50%, transparent); }
.badge2.warn { color:#c27a00; border-color:#c27a00; }
:root[data-theme="dark"] .badge2.warn { color:#ffb454; border-color:#ffb454; }
.badge2.none { color:var(--muted); }
.unsorted { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:8px 12px; border:1px solid var(--line); border-radius:8px; background:var(--panel); margin:6px 0; }
.unsorted > span:first-child { min-width:0; overflow-wrap:anywhere; }
.pc-ctl.wide button { width:auto; padding:0 8px; font-size:12px; }
.card.apply { border:1px solid var(--line); background:var(--panel); border-radius:12px; padding:14px; }
.card.apply .hint { margin:6px 0 12px; }
details.src { margin-top:14px; border:1px solid var(--line); border-radius:10px; background:var(--panel); padding:8px 12px; }
details.src summary { cursor:pointer; color:var(--muted); }
details.src pre { white-space:pre-wrap; font:12px/1.5 "JetBrains Mono", Consolas, monospace; max-height:340px; overflow:auto; margin-top:8px; }
.notice { margin-top:14px; padding:10px 14px; border:1px solid var(--line); background:var(--panel); border-radius:10px; display:flex; align-items:center; justify-content:space-between; gap:12px; }
@media print { .import-view, .dropveil { display:none !important; } }
.pv-top .btn { white-space:nowrap; }

/* ---------- palettes ---------- */
.swatches { max-width:238px; }
.swatches button { box-shadow:0 0 0 1px var(--line); }
.colorpair { display:flex; gap:16px; }
.colorpair label { display:flex; flex-direction:column; gap:4px; }
.colorpair input[type="color"] { width:44px; height:28px; border:1px solid var(--line); border-radius:6px; padding:2px; background:var(--field); cursor:pointer; }
.designrow { display:flex; gap:40px; align-items:flex-start; flex-wrap:wrap; }
.designrow .cards { grid-template-columns:repeat(3, 170px); }
.palbox { min-width:260px; flex:1; }
.palbox > .hint { margin-bottom:10px; }
.palettes { display:grid; grid-template-columns:repeat(auto-fill, 64px); gap:12px 10px; }
.pal { display:flex; flex-direction:column; align-items:center; gap:5px; background:none; border:none; padding:0; cursor:pointer; color:var(--muted); font-size:11px; }
.pal i { width:34px; height:34px; border-radius:50%; box-shadow:0 0 0 1px var(--line); transition:transform .1s; }
.pal:hover i { transform:scale(1.1); }
.pal.on { color:var(--ink); font-weight:600; }
.pal.on i { box-shadow:0 0 0 2px var(--panel), 0 0 0 4px var(--ui); }

/* ---------- empty projects: one big call to action ---------- */
.noproj .projtools, .noproj #h-count { display:none; }
.bigstart { grid-column:1 / -1; width:100%; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:6px; padding:44px 20px; border:2px dashed var(--line); border-radius:16px; background:var(--panel); color:var(--ink); cursor:pointer; transition:border-color .12s, background .12s; }
.bigstart:hover { border-color:var(--ui); background:color-mix(in srgb, var(--ui) 8%, var(--panel)); }
.bigstart .plus { font-size:40px; line-height:1; color:var(--ui); }
.bigstart b { font-size:20px; letter-spacing:-.01em; }
.bigstart span:last-child { color:var(--muted); }
.home .noproj h2 .projtools, .home .noproj h2 #h-count { display:none; }
.home .noproj .cards { display:block; }

/* ---------- custom colour ---------- */
.pal i.rainbow { background:conic-gradient(from 0deg, #ff3b30, #ff9500, #ffd60a, #34c759, #00c7be, #0a84ff, #bf5af2, #ff2d92, #ff3b30); }
.customrow { display:flex; gap:10px; margin-top:16px; flex-wrap:wrap; }
.cfield { display:flex; align-items:center; gap:10px; padding:8px 14px 8px 8px; border:1px solid var(--line); border-radius:12px; background:var(--panel); cursor:pointer; }
.cfield:hover { border-color:var(--ui); }
.cfield input[type="color"] { width:36px; height:36px; padding:0; border:none; background:none; cursor:pointer; }
.cfield input[type="color"]::-webkit-color-swatch-wrapper { padding:0; }
.cfield input[type="color"]::-webkit-color-swatch { border:1px solid var(--line); border-radius:9px; }
.cfield b { display:block; font-size:12px; font-weight:600; }
.cfield small { color:var(--muted); font-family:"JetBrains Mono", Consolas, monospace; font-size:11px; text-transform:uppercase; }

.designrow .cards { grid-template-columns:repeat(4, 170px); }
.colorpair[hidden] { display:none; }
.swatches button.rainbow { background:conic-gradient(from 0deg, #ff3b30, #ff9500, #ffd60a, #34c759, #00c7be, #0a84ff, #bf5af2, #ff2d92, #ff3b30); }
#layoutlist .item2.sel { background:var(--hover); font-weight:600; }
#layoutlist { min-width:250px; }

/* ---------- zoom ---------- */
.zoombar { position:fixed; right:22px; bottom:18px; z-index:25; display:flex; gap:2px; padding:4px; background:var(--panel); border:1px solid var(--line); border-radius:12px; box-shadow:0 6px 24px rgba(0,0,0,.2); }
.histopen .zoombar { bottom:246px; }
.zoombar button { min-width:30px; height:28px; border:none; border-radius:8px; background:transparent; color:var(--ink); cursor:pointer; padding:0 8px; }
.zoombar button:hover { background:var(--hover); }
.zoombar #zoomval { min-width:52px; font-variant-numeric:tabular-nums; }
.popout .zoombar { display:none; }
.exporting .edcol { zoom:1 !important; }
@media print { .zoombar { display:none !important; } .edcol { zoom:1 !important; } }

/* ---------- in-page dialogs (alert / confirm / prompt) ---------- */
dialog.askdlg .askmsg { line-height:1.5; white-space:pre-line; }
.btn.danger { background:var(--danger); color:#fff; border-color:var(--danger); }
.btn.danger:hover:not(:disabled) { filter:brightness(1.08); background:var(--danger); }

/* ---------- phones and narrow windows ---------- */
/* Touch screens have no hover: keep the per-item and per-tile controls reachable. */
@media (hover:none) {
  .tile .more { display:block; }
  .item:focus-within > .ctl { display:flex; }
  .ctl button { width:26px; height:26px; line-height:24px; border-radius:13px; font-size:14px; }
  .pc-ctl { opacity:1; }
  .pc-ctl button { width:32px; height:32px; }
}
@media (max-width:700px) {
  body { -webkit-text-size-adjust:100%; }
  /* the bar wraps onto two rows instead of running off the screen; menus open full width under it */
  .bar { height:auto; min-height:var(--barh); flex-wrap:wrap; row-gap:4px; padding:6px 8px; padding-top:max(6px, env(safe-area-inset-top)); }
  .bar .sep, .bar .sp { display:none; }
  .bar .menu { position:static; }
  .menu .pop { left:8px !important; right:8px !important; min-width:0; max-height:70vh; overflow:auto; }
  .menu .pop .item2 { padding:10px 12px; }
  #layoutlist { min-width:0; }
  #docname { max-width:40vw; flex:1; min-width:0; }
  #pvtoggle { display:none; } /* the side-by-side preview needs a wide screen */
  .bar .btn:not(.ic) { padding:5px 8px; }
  .save { min-width:0; }
  .btn { height:34px; }
  .btn.ic { width:34px; }
  .swatches { max-width:none; }
  .swatches button { width:30px; height:30px; }

  .stage { padding:12px 4px 90px; }
  .zoombar { right:50%; transform:translateX(50%); bottom:max(12px, env(safe-area-inset-bottom)); }
  .zoombar button { height:34px; min-width:38px; }
  .hist { height:45vh; }
  .histopen .zoombar { bottom:calc(45vh + 12px); }
  .hist-head { flex-wrap:wrap; gap:8px; padding:6px 10px; }
  .hist-head > .hint:nth-of-type(2) { display:none; }

  .home { padding:18px 16px 60px; }
  .home h1 { font-size:22px; }
  .home h2 { flex-wrap:wrap; }
  .home h2 .projtools { margin-left:0; width:100%; }
  .home h2 .projtools input { flex:1; width:auto; min-width:0; }
  .home .profilecard { flex-direction:column; align-items:stretch; gap:14px; }
  .cards, .designrow .cards { grid-template-columns:repeat(auto-fill, 170px); gap:18px 12px; justify-content:center; }
  .designrow { gap:24px; }
  .palbox { min-width:0; }

  .pv-wrap, .imp-wrap { padding:18px 16px 60px; }
  .pv-top { flex-direction:column; }
  .pv-top h1, .imp-head h1 { font-size:22px; }
  .grid2, .grid2.wide1, .grid2.skill { grid-template-columns:1fr; }
  .lrow.g > .fld:nth-child(2) { flex-basis:72px; }
  .dropzone { flex-direction:column; align-items:stretch; text-align:center; padding:20px; }
  .imp-ctl { justify-content:flex-start; }
  .fld input, .fld textarea, .sd-input, #imp-paste, .linkpop input { font-size:16px; } /* iOS zooms into smaller inputs */

  dialog#settings { width:100vw; max-width:100vw; max-height:100dvh; border-radius:0; }
  .sd-body { max-height:calc(100dvh - 60px); }
  .sd-row { flex-wrap:wrap; }
  .words { max-width:none; justify-content:flex-start; }
  .toast { left:12px; right:12px; transform:none; bottom:max(16px, env(safe-area-inset-bottom)); }
  .linkpop { left:8px !important; right:8px; width:auto; }
}

.pp-tip { margin-top:8px; }
.pp-zoom { position:fixed; inset:0; z-index:60; background:rgba(0,0,0,.72); display:flex; flex-direction:column; }
.pp-zoom-bar { display:flex; justify-content:space-between; align-items:center; gap:12px; padding:10px 20px; color:#fff; font-size:13px; }
.pp-zoom-scroll { flex:1; overflow-x:hidden; overflow-y:auto; display:flex; justify-content:center; padding:0 24px 28px; }
.pp-zoom-page { flex:none; background:#fff; box-shadow:var(--shadow); height:max-content; cursor:default; }

/* ---------- RobCo account (bar) ---------- */
.acct-signin[hidden], #acctmenu[hidden] { display:none; }
.acct-signin .short { display:none; }
.acct-signin.waiting { color:var(--muted); }
.acct-signin.waiting::before { content:""; width:10px; height:10px; border-radius:50%; border:2px solid currentColor; border-right-color:transparent; animation:acct-spin .8s linear infinite; }
@keyframes acct-spin { to { transform:rotate(360deg); } }
.avatar { width:24px; height:24px; border-radius:50%; flex:none; display:inline-grid; place-items:center; overflow:hidden;
  background:color-mix(in srgb, var(--ui) 22%, var(--panel)); color:var(--ui); font-size:10px; font-weight:600; letter-spacing:.02em; }
.avatar img { width:100%; height:100%; object-fit:cover; display:block; }
.avatar.lg { width:40px; height:40px; font-size:15px; }
.acct-btn { border-radius:50%; }
.acct-pop { min-width:240px; }
.acct-head { display:flex; align-items:center; gap:12px; padding:8px 10px 6px; }
.acct-who { display:flex; flex-direction:column; min-width:0; }
.acct-who b, .acct-who .hint { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; max-width:200px; }
@media (max-width:1100px) { .acct-signin .long { display:none; } .acct-signin .short { display:inline; } }
@media print { .acct-signin, #acctmenu { display:none !important; } }
