/* 01 Vellum — the cartographer's desk. Warm paper, ink, minimal chrome.
   The map is the window; everything else is a small translucent card laid on it. */

:root {
  --paper: #f3ecd9;
  --paper-deep: #e9dfc6;
  --ink: #2b2118;
  --ink-2: #4a3d30;
  --bg: var(--paper);
  --panel: rgba(250, 246, 235, 0.88);
  --panel-2: rgba(43, 33, 24, 0.06);
  --line: rgba(43, 33, 24, 0.18);
  --line-strong: rgba(43, 33, 24, 0.42);
  --text: var(--ink);
  --muted: #7a6c5a;
  --accent: #d5006c;
  --accent-soft: rgba(213, 0, 108, 0.12);
  --primary: var(--ink);
  --primary-text: #f9f4e8;
  --radius: 7px;
  --card-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset, 0 10px 28px -14px rgba(43, 33, 24, 0.45), 0 1px 2px rgba(43, 33, 24, 0.12);
  --shadow: 0 12px 32px -12px rgba(43, 33, 24, 0.5), 0 1px 2px rgba(43, 33, 24, 0.15);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  color: var(--ink);
  background: var(--paper);
  background-image: radial-gradient(ellipse at 20% 10%, rgba(255, 252, 244, 0.7), transparent 60%), radial-gradient(ellipse at 80% 90%, rgba(190, 168, 130, 0.22), transparent 55%);
}
.app { position: fixed; inset: 0; }
h1, h2, h3 { font-family: 'Lora', Georgia, serif; font-weight: 700; letter-spacing: -0.005em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
kbd.inline { margin: 0; padding: 0 4px; font-size: 10px; border-color: var(--line-strong); color: var(--ink-2); background: rgba(255, 255, 255, 0.5); }

/* ---- shared widget restyle ---- */
.btn { border-color: var(--line); background: rgba(255, 253, 247, 0.7); border-radius: var(--radius); transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover:not(:disabled) { background: #fffdf7; border-color: var(--line-strong); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--primary-text); }
.btn.primary:hover:not(:disabled) { background: #3d3025; border-color: #3d3025; }
.btn.quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.quiet:hover:not(:disabled) { background: var(--panel-2); border-color: transparent; }
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.seg { background: rgba(255, 253, 247, 0.7); border-color: var(--line); }
.seg-btn.on { background: var(--ink); color: var(--primary-text); }
input[type="text"], input[type="search"], input[type="number"], select, input:not([type]) { background: rgba(255, 253, 247, 0.85); border-color: var(--line); }
input[type="range"] { accent-color: var(--ink); }
.chip { background: var(--panel-2); }
code { background: rgba(43, 33, 24, 0.07); }

/* ---- the paper card ---- */
.card {
  position: absolute;
  background: var(--panel);
  -webkit-backdrop-filter: blur(8px) saturate(1.05);
  backdrop-filter: blur(8px) saturate(1.05);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  z-index: 10;
}
.card h3 { font-size: 13px; }

/* ================================================================ desk (world list) */
.desk { position: absolute; inset: 0; overflow: auto; padding: 48px 32px 40px; }
.desk-head { display: flex; align-items: center; gap: 16px; max-width: 1180px; margin: 0 auto 28px; }
.desk-mark { width: 52px; height: 52px; display: grid; place-items: center; border: 1.5px solid var(--ink); border-radius: 50%; color: var(--ink); background: rgba(255, 253, 247, 0.6); }
.desk-title h1 { font-size: 34px; line-height: 1; }
.desk-title p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.desk-head .about-btn { margin-left: auto; }
.desk-list .world-list { grid-template-columns: 340px 1fr; gap: 32px; padding: 0; max-width: 1180px; }
.world-create { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--card-shadow); padding: 20px; gap: 12px; }
.world-create h3 { font-size: 18px; margin-bottom: 4px; }
.world-create label { color: var(--muted); font-size: 12px; letter-spacing: 0.01em; }
.world-create label.file-btn { flex-direction: row; color: var(--ink); font-size: 13px; }
.world-cards { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.world-card { position: relative; padding: 18px 20px 16px 26px; background: linear-gradient(160deg, rgba(255, 253, 247, 0.95), rgba(243, 236, 217, 0.9)); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--card-shadow); transition: transform .18s var(--ease), box-shadow .18s; overflow: hidden; }
.world-card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 9px; background: var(--k0); border-right: 1px solid rgba(43, 33, 24, 0.25); }
.world-card:nth-child(2)::before { background: var(--k1); } .world-card:nth-child(3)::before { background: var(--k2); } .world-card:nth-child(4)::before { background: var(--k3); }
.world-card:nth-child(5)::before { background: var(--k4); } .world-card:nth-child(6)::before { background: var(--k5); } .world-card:nth-child(7)::before { background: var(--k6); }
.world-card { --k0: #c9776a; --k1: #6f95c2; --k2: #7fb07a; --k3: #c9ad63; --k4: #a284c1; --k5: #64b0b0; --k6: #c98ba8; }
.world-card:hover { transform: translateY(-2px); box-shadow: 0 16px 32px -16px rgba(43, 33, 24, 0.55), 0 1px 2px rgba(43, 33, 24, 0.12); }
.world-card-head h3 { font-size: 20px; }
.world-card p { color: var(--muted); }
.world-card .actions .btn { padding: 4px 9px; font-size: 12px; }
.desk-foot { max-width: 1180px; margin: 36px auto 0; text-align: center; }

/* ================================================================ table (map screen) */
.stage { position: absolute; inset: 0; }
.stage .map { position: absolute; inset: 0; }
.stage .mapsvg { --paper: #f3ecd9; }

/* ---- top-left: breadcrumb stack ---- */
.crumb-card { top: 14px; left: 60px; display: flex; gap: 8px; padding: 8px 12px 8px 8px; max-width: 360px; transition: transform .2s var(--ease), max-width .2s; }
.crumb-main { min-width: 0; display: flex; flex-direction: column; }
.crumb-floor:empty { display: none; }
.crumb-floor { margin-top: 6px; padding: 7px 8px 2px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.crumb-floor .floor-select select { padding: 2px 6px; font-size: 12px; }
.crumb-side { display: flex; flex-direction: column; gap: 4px; }
.crumb-side .btn { padding: 4px; }
.crumbs .breadcrumb { flex-direction: column; align-items: stretch; gap: 0; }
.crumbs .crumb-sep { display: none; }
.crumbs .crumb { display: flex; flex-direction: column; align-items: flex-start; gap: 0; padding: 2px 8px; line-height: 1.25; color: var(--ink-2); position: relative; }
.crumbs .crumb + .crumb-sep + .crumb { margin-left: 12px; }
.crumbs .crumb + .crumb-sep + .crumb + .crumb-sep + .crumb { margin-left: 24px; }
.crumbs .crumb + .crumb-sep + .crumb + .crumb-sep + .crumb + .crumb-sep + .crumb { margin-left: 36px; }
.crumbs .crumb + .crumb-sep + .crumb + .crumb-sep + .crumb + .crumb-sep + .crumb + .crumb-sep + .crumb { margin-left: 48px; }
.crumbs .crumb:not(:first-of-type)::before { content: '↳'; position: absolute; left: -8px; top: 3px; font-size: 11px; color: var(--muted); }
.crumbs .crumb-scale { font-size: 9.5px; letter-spacing: 0.08em; opacity: 0.75; }
.crumbs .crumb-label { font-family: 'Lora', Georgia, serif; font-size: 14px; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.crumbs .crumb { max-width: 100%; }
.crumbs .crumb.current .crumb-label { font-size: 16px; font-weight: 700; color: var(--ink); }
.crumbs .crumb:hover:not(:disabled) { background: var(--panel-2); }

/* ---- top-right: toolbar ---- */
.toolbar { top: 14px; right: 14px; display: flex; align-items: center; gap: 6px; padding: 6px 8px; }
.tb-group { display: flex; gap: 4px; align-items: center; }
.tb-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }
.toolbar .btn { padding: 5px 9px; }
.toolbar .btn.icon-btn { padding: 5px; }
.toolbar .about-btn { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; font-family: 'Lora', Georgia, serif; font-weight: 700; font-size: 14px; }
.toolbar .frame-btn.on { background: var(--accent-soft); }

/* ---- layers popover ---- */
.popover { background: var(--panel); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-color: var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.layers-pop { display: flex; flex-direction: column; gap: 2px; min-width: 210px; }
.layers-pop h3 { margin-bottom: 6px; }
.layer-row { display: flex; align-items: center; gap: 9px; width: 100%; padding: 5px 8px; border: none; background: none; border-radius: 6px; cursor: pointer; text-align: left; color: var(--muted); }
.layer-row.on { color: var(--ink); }
.layer-row:hover { background: var(--panel-2); }
.layer-row.mode { margin-top: 6px; border-top: 1px solid var(--line); border-radius: 0 0 6px 6px; padding-top: 9px; }
.export-menu { min-width: 300px; }

/* ---- about ---- */
.about { width: 420px; font-size: 12.5px; line-height: 1.45; }
.about h3 { font-size: 16px; margin-bottom: 4px; }
.about p { margin: 0 0 8px; }
.about ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; }
.about li b { font-family: 'Lora', Georgia, serif; }

/* ---- left edge: tab strip + drawer ---- */
.tabstrip { position: absolute; left: 0; top: 0; bottom: 0; width: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 12px 0; background: linear-gradient(90deg, rgba(243, 236, 217, 0.9), rgba(243, 236, 217, 0.65)); border-right: 1px solid var(--line); z-index: 20; -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.tab { writing-mode: vertical-rl; transform: rotate(180deg); border: 1px solid transparent; background: none; padding: 12px 6px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 700; }
.tab:hover { color: var(--ink); background: rgba(255, 253, 247, 0.6); }
.tab.on { color: var(--ink); background: var(--panel); border-color: var(--line); box-shadow: 0 2px 8px -4px rgba(43, 33, 24, 0.4); }
.drawer { position: absolute; left: 44px; top: 0; bottom: 0; width: 368px; z-index: 19; display: flex; flex-direction: column; background: rgba(250, 246, 235, 0.97); border-right: 1px solid var(--line); box-shadow: 18px 0 40px -24px rgba(43, 33, 24, 0.5); animation: slide-right .16s var(--ease); }
@keyframes slide-right { from { transform: translateX(-16px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 14px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 18px; }
.drawer-hint { margin: 3px 0 0; }
.drawer-body { flex: 1; overflow: auto; padding: 10px 12px 24px; }
.app.drawer-open .crumb-card { transform: translateX(352px); max-width: max(230px, calc(100vw - 1070px)); }
.app.drawer-open .legibility { transform: translateX(352px); }
.app.drawer-open .status, .app.drawer-open ~ .toasts { left: calc(412px + (100vw - 412px) / 2); }
.no-motion *, .no-motion *::before, .no-motion *::after { transition: none !important; animation: none !important; }
.var-group { background: rgba(255, 253, 247, 0.55); border-color: var(--line); }
.var-group.irrelevant { opacity: 0.5; }
.var-group summary { font-family: 'Lora', Georgia, serif; font-size: 13px; }
.var-row { border-top-color: var(--line); }
.list-head .search { background: rgba(255, 253, 247, 0.85); }

/* ---- right edge: inspector + map card ---- */
.inspector { top: 72px; right: 14px; bottom: 238px; width: 336px; display: flex; flex-direction: column; transform: translateX(24px); opacity: 0; pointer-events: none; transition: transform .18s var(--ease), opacity .15s; z-index: 12; }
.inspector.open { transform: none; opacity: 1; pointer-events: auto; }
.inspector-body { flex: 1; overflow: auto; padding: 14px 16px 16px; }
.el-head h2 { font-family: 'Lora', Georgia, serif; font-size: 21px; }
.el-actions .btn { padding: 4px 9px; font-size: 12px; }
.el-nav .btn { justify-content: center; }
table.props th { color: var(--muted); }
table.props tr { border-top-color: var(--line); }
.el-deps { border-top-color: var(--line); }
.map-card { top: 72px; right: 14px; width: 280px; padding: 14px 16px 12px; z-index: 11; }
.map-card .map-info h2 { font-size: 17px; }
.map-card .row .btn { padding: 4px 9px; font-size: 12px; }
.map-card .hint { margin: 10px 0 0; }

/* ---- bottom-left: legibility ---- */
.legibility { left: 60px; bottom: 14px; width: 232px; padding: 10px 12px 10px; display: flex; flex-direction: column; gap: 6px; transition: transform .2s var(--ease); }
.legibility h3 { margin-bottom: 2px; }
.leg-row { display: grid; grid-template-columns: 52px 1fr 26px; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.leg-row output { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-size: 11.5px; }
.leg-row input[type="range"] { min-width: 0; height: 16px; }
.leg-row.toggle-row { grid-template-columns: 1fr auto; margin-top: 2px; }
.leg-row.toggle-row > span:first-child { color: var(--ink-2); }

/* ---- bottom-centre: coordinates + scale bar ---- */
.status { left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; padding: 6px 12px; font-size: 11.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.coords { min-width: 150px; text-align: right; }
.scale-bar { display: inline-flex; align-items: center; gap: 8px; }
.scale-line { display: inline-block; height: 5px; border: 1.5px solid var(--ink); border-top: none; width: 80px; position: relative; }
.scale-line::after { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; border-left: 1px solid var(--ink); }
.scale-text { font-weight: 700; color: var(--ink); }

/* ---- hover callout ---- */
.hover-tip { position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none; display: flex; flex-direction: column; gap: 1px; padding: 4px 9px 5px; background: rgba(255, 253, 247, 0.94); border: 1px solid var(--line-strong); border-radius: 6px; box-shadow: 0 4px 12px -6px rgba(43, 33, 24, 0.5); font-size: 12px; }
.hover-tip b { font-family: 'Lora', Georgia, serif; }
.hover-tip span { font-size: 10.5px; color: var(--muted); }

/* ---- the Frame tool: action bar ---- */
.frame-bar { left: 0; top: 0; display: flex; align-items: center; gap: 8px; padding: 6px 8px; z-index: 30; border-color: var(--preview-c, #1273d8); box-shadow: 0 0 0 3px rgba(18, 115, 216, 0.14), var(--card-shadow); }
.frame-bar .btn { padding: 5px 10px; }
.frame-bar .btn.primary { background: #1273d8; border-color: #1273d8; }
.frame-bar .btn.primary:hover:not(:disabled) { background: #0f5fb4; border-color: #0f5fb4; }
.bar-hint { white-space: nowrap; }
.stepper { display: inline-flex; align-items: center; gap: 3px; padding: 0 4px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255, 253, 247, 0.6); }
.stepper-label { font-size: 11px; color: var(--muted); padding: 0 4px 0 3px; font-weight: 700; letter-spacing: 0.04em; }
.stepper .btn.icon-btn { padding: 3px; border: none; background: none; }
.stepper input[type="number"] { width: 54px; text-align: center; border: none; background: transparent; padding: 4px 0; font-variant-numeric: tabular-nums; appearance: textfield; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper .unit { font-size: 11px; color: var(--muted); padding-right: 4px; }
.stage .mapsvg .preview-label { font-size: calc(var(--upp) * 14); }
.stage .mapsvg .preview-mask { fill-opacity: 0.38; fill: #2b2118; }
.stage .mapsvg .preview-frame { stroke-width: 2.2px; stroke-dasharray: 8 5; }
.stage .mapsvg .handle-box { stroke-width: 2.2; }

/* ---- parent ghost ---- */
.ghost { right: 14px; bottom: 14px; width: 236px; padding: 8px; display: flex; flex-direction: column; gap: 6px; z-index: 13; }
.ghost-head { display: flex; flex-direction: column; line-height: 1.2; padding: 0 2px; }
.ghost-kicker { font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.ghost-head b { font-family: 'Lora', Georgia, serif; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghost-thumb { width: 218px; height: 130px; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; cursor: pointer; position: relative; background: var(--paper); }
.ghost-thumb:hover { box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 3px var(--accent); }
.ghost-thumb .mapsvg { cursor: pointer; }
.ghost-thumb .mapsvg .el { pointer-events: none; }
.ghost-thumb .mapsvg .layer-labels, .ghost-thumb .mapsvg .hl-hov, .ghost-thumb .mapsvg .lock { display: none; }
.ghost-thumb .mapsvg .preview-mask { fill-opacity: 0.45; }
.ghost-thumb .mapsvg .preview-frame { stroke: var(--accent); stroke-dasharray: none; stroke-width: 2px; }
.ghost-thumb .mapsvg .preview-corners, .ghost-thumb .mapsvg .preview-cross { stroke: var(--accent); }
.ghost-thumb .mapsvg .handle-box { stroke: var(--accent); width: 8px; height: 8px; x: -4px; y: -4px; }
.ghost-thumb .mapsvg .preview-body.draggable { fill: var(--accent); fill-opacity: 0.08; }
.ghost-thumb .mapsvg .preview-label { display: none; }
.ghost-foot { display: flex; align-items: center; gap: 6px; }
.ghost-size { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--ink-2); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ghost-foot .btn.small { padding: 3px 8px; font-size: 11.5px; }

/* ---- context menu ---- */
.ctx-menu { background: var(--panel); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-color: var(--line); border-radius: 9px; box-shadow: var(--shadow); }
.ctx-title { font-family: 'Lora', Georgia, serif; font-size: 12px; color: var(--ink-2); }
.ctx-group { border-top-color: var(--line); }
.ctx-item:hover:not(:disabled) { background: var(--panel-2); }

/* ---- progress + toasts ---- */
.progress { height: 3px; background: transparent; border: none; overflow: visible; }
.progress-bar { height: 3px; opacity: 1; background: var(--accent); box-shadow: 0 0 8px rgba(213, 0, 108, 0.5); }
.progress-label { inset: auto; top: 10px; left: 50%; transform: translateX(-50%); position: fixed; padding: 4px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--card-shadow); font-size: 11.5px; color: var(--ink); white-space: nowrap; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.toasts { right: auto; left: 50%; bottom: 60px; transform: translateX(-50%); align-items: center; }
.toast { background: var(--panel); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-color: var(--line); box-shadow: var(--shadow); }

/* ---- map accents: keep ink/paper, sharpen the two highlight colours ---- */
.stage .mapsvg .callout-box { fill: #fffdf7; }
.stage .mapsvg .dim-veil { fill-opacity: 0.62; }
