/* 03 Twin — parent and child, side by side. Calm light chrome, ink maps. */
:root {
  --bg: #ece8dd;
  --panel: #fbf9f3;
  --panel-2: #f1ede2;
  --line: #d9d3c4;
  --line-soft: #e6e1d4;
  --text: #2a251d;
  --muted: #7d7565;
  --accent: #d5006c;
  --accent-soft: rgba(213, 0, 108, 0.1);
  --primary: #2a251d;
  --primary-text: #fbf9f3;
  --frame: #1273d8;
  --frame-soft: rgba(18, 115, 216, 0.1);
  --radius: 6px;
  --shadow: 0 8px 28px rgba(40, 30, 15, 0.16);
}
body { background: var(--bg); color: var(--text); }
h1, h2, h3 { font-family: var(--display-font); }
.btn { border-radius: var(--radius); }
.btn:hover:not(:disabled) { background: #fff; border-color: #c4bba6; }
.btn.primary { background: var(--primary); border-color: var(--primary); }
.btn.frame { color: var(--frame); border-color: rgba(18, 115, 216, 0.45); background: #fff; }
.btn.frame:hover:not(:disabled) { background: var(--frame-soft); }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- world list */
.list-screen { height: 100vh; overflow: auto; }
.list-hero { display: flex; align-items: baseline; gap: 16px; padding: 34px 40px 6px; max-width: 1200px; margin: 0 auto; }
.list-hero h1 { font-size: 30px; font-weight: 600; }
.list-hero p { margin: 0; color: var(--muted); font-size: 13px; }
.list-hero .badge { margin-left: auto; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); padding: 3px 8px; border-radius: 999px; }
.world-list { grid-template-columns: 340px 1fr; gap: 28px; padding: 18px 40px 40px; }
.world-create { border-radius: 12px; box-shadow: 0 1px 0 rgba(255,255,255,0.8) inset; padding: 18px; }
.world-create h3 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.world-card { border-radius: 12px; padding: 16px 18px; transition: box-shadow .15s, transform .15s; }
.world-card:hover { box-shadow: 0 6px 18px rgba(40, 30, 15, 0.08); transform: translateY(-1px); }
.world-card-head h3 { font-size: 20px; font-weight: 600; }
.world-card .actions .btn:not(.primary) { border-color: transparent; background: none; color: var(--muted); }
.world-card .actions .btn:not(.primary):hover { background: var(--panel-2); color: var(--text); }

/* ---------------------------------------------------------------- app frame */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); flex: none; }
.topbar .brand { display: flex; align-items: center; gap: 8px; }
.topbar .brand .btn { color: var(--muted); border-color: transparent; background: none; }
.topbar .brand .btn:hover { background: var(--panel-2); color: var(--text); }
.topbar .right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.topbar .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

/* thumbnail chain as breadcrumb */
.chain { display: flex; align-items: center; gap: 4px; overflow-x: auto; padding: 2px 4px; flex: 1; min-width: 0; scrollbar-width: thin; }
.chain-sep { color: var(--muted); display: inline-flex; flex: none; opacity: 0.7; }
.thumb { flex: none; display: flex; flex-direction: column; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); cursor: pointer; text-align: left; width: 128px; transition: border-color .12s, box-shadow .12s; }
.thumb:hover { border-color: #b8ae97; box-shadow: 0 2px 8px rgba(40, 30, 15, 0.1); }
.thumb.current { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); cursor: default; }
.thumb-map { width: 120px; height: 72px; border-radius: 5px; overflow: hidden; background: #f3ecd9; pointer-events: none; }
.thumb-map .mapsvg { cursor: default; }
.thumb-cap { display: flex; flex-direction: column; padding: 0 3px 2px; line-height: 1.2; min-width: 0; }
.thumb-cap b { font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }
.thumb-cap span { font-size: 11.5px; font-family: var(--display-font); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb.current .thumb-cap b { color: var(--text); }

/* ---------------------------------------------------------------- panes */
.panes { display: grid; grid-template-columns: 2fr 3fr; flex: 1; min-height: 0; background: var(--line); gap: 1px; }
.pane { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 5px 10px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 12px; min-height: 34px; flex: none; }
.pane-head .scale { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
.pane-head .name { font-family: var(--display-font); font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-head .hint { color: var(--muted); font-size: 11.5px; margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pane-head .tools { display: flex; gap: 4px; margin-left: auto; align-items: center; flex: none; }
.pane-head .btn.small { padding: 3px 7px; }
.pane-body { flex: 1; position: relative; min-height: 0; }
.pane-body .mapsvg-container { position: absolute; inset: 0; }
.pane-foot { display: flex; align-items: center; gap: 8px; padding: 5px 10px; font-size: 11.5px; color: var(--muted); background: var(--panel); border-top: 1px solid var(--line); min-height: 28px; flex: none; line-height: 1.35; }
.pane-foot .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--frame); flex: none; }
.pane-foot .dot.anchor { background: var(--accent); }
.pane.parent .mapsvg { --paper: #eee7d6; --sea: #d5dfe6; --land: #ebe3cf; }
.pane.child .mapsvg { --paper: #f4eedc; }
.pane.parent .mapsvg .hl-anchor .hl-ring { stroke: var(--frame); stroke-width: 2.2; }
.pane.parent .mapsvg .hl-anchor .hl-ring-outer { fill: var(--frame); fill-opacity: 0.18; animation: none; transform: scale(1.25); }
.pane.parent .mapsvg .hl-anchor .hl-glow, .pane.parent .mapsvg .hl-anchor .hl-shape { stroke: var(--frame); }
.pane.parent .mapsvg .hl-anchor .hl-glow { fill: var(--frame); fill-opacity: 0.12; stroke-opacity: 0.25; }
.pane.parent .mapsvg .hl-anchor .hl-shape { fill: none; stroke-width: 2.2px; }
.pane.parent .mapsvg .preview-label { font-size: calc(var(--upp) * 12.5); }

/* floating controls over a pane */
.pane-float { position: absolute; z-index: 5; display: flex; gap: 6px; align-items: center; }
.pane-float.tr { top: 10px; right: 10px; }
.pane-float.bc { bottom: 12px; left: 50%; transform: translateX(-50%); }
.open-region { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px; background: var(--frame); color: #fff; border: none; font-weight: 600; font-size: 13px; cursor: pointer; box-shadow: 0 6px 18px rgba(18, 115, 216, 0.35); }
.open-region:hover { background: #0f62b9; }
.open-region kbd { color: rgba(255,255,255,0.8); border-color: rgba(255,255,255,0.4); }
.preview-badge { position: absolute; left: 10px; top: 10px; z-index: 5; display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: 999px; background: rgba(251, 249, 243, 0.92); border: 1px solid var(--line); font-size: 11px; color: var(--muted); pointer-events: none; }
.preview-badge .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--frame); animation: blink 1.4s ease-in-out infinite; }
.preview-badge.pinned .pulse { animation: none; }
@keyframes blink { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.pane-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; text-align: center; padding: 30px; pointer-events: none; }
.pane-empty p { max-width: 320px; line-height: 1.5; }

/* leader line between the panes */
.leader-overlay { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 40; overflow: visible; }
.leader-overlay .leader { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 5 4; opacity: 0.9; }
.leader-overlay .leader-glow { fill: none; stroke: #fff; stroke-width: 4; opacity: 0.8; }
.leader-overlay .leader-end { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.leader-overlay .leader-end.clamped { fill: var(--accent); }

/* ---------------------------------------------------------------- status line */
.statusline { display: flex; align-items: center; gap: 18px; padding: 4px 14px; font-size: 11.5px; color: var(--muted); background: var(--panel-2); border-top: 1px solid var(--line); flex: none; min-height: 26px; font-variant-numeric: tabular-nums; }
.statusline .cover { color: var(--text); font-weight: 500; }
.statusline .spacer { flex: 1; }
.statusline kbd { margin-left: 0; }

/* ---------------------------------------------------------------- drawer */
.drawer { display: flex; flex-direction: column; height: 262px; background: var(--panel); border-top: 1px solid var(--line); flex: none; transition: height .16s ease-out; }
.drawer.collapsed { height: 35px; }
.drawer.collapsed .drawer-body { display: none; }
.drawer-tabs { display: flex; align-items: center; gap: 2px; padding: 4px 10px 0; border-bottom: 1px solid var(--line); flex: none; }
.tab { border: none; background: none; padding: 7px 12px; font-size: 12.5px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; display: inline-flex; gap: 6px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab .count { font-size: 10.5px; padding: 0 6px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-weight: 400; }
.drawer-tabs .collapse { margin-left: auto; }
.drawer-body { flex: 1; overflow: auto; padding: 12px 16px; min-height: 0; }
.drawer-body > .tabpane { display: none; }
.drawer-body > .tabpane.on { display: block; }

/* inspect: lay the element panel out in three columns */
.tabpane.inspect .element-panel { display: grid; grid-template-columns: minmax(240px, 320px) minmax(300px, 1fr) minmax(240px, 340px); grid-template-rows: auto auto auto 1fr; grid-template-areas: "head props deps" "acts props deps" "nav props deps" "warn props deps"; gap: 8px 28px; align-items: start; }
.tabpane.inspect .el-head { grid-area: head; }
.tabpane.inspect .el-actions { grid-area: acts; }
.tabpane.inspect .el-nav { grid-area: nav; }
.tabpane.inspect .element-panel > .warning { grid-area: warn; }
.tabpane.inspect .element-panel > table.props { grid-area: props; }
.tabpane.inspect .el-deps { grid-area: deps; border-top: none; padding-top: 0; }
.tabpane.inspect .el-head h2 { font-size: 21px; font-weight: 600; }
.tabpane.inspect .el-nav .btn { width: auto; }
.tabpane.inspect table.props th { width: 38%; }
.tabpane.inspect .map-info { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 6px 32px; align-items: start; }
.tabpane.inspect .map-info h2 { grid-column: 1 / -1; font-size: 20px; font-weight: 600; margin-bottom: 0; }
.tabpane.inspect .map-info .row { margin-top: 0; }
.tabpane.inspect .map-info .hint { grid-column: 2; margin: 0; }
.tabpane.inspect .map-info .warning { grid-column: 1 / -1; }

/* elements: multi-column list */
.tabpane.elements .list-head { max-width: 560px; }
.tabpane.elements .element-list { columns: 230px; column-gap: 28px; }
.tabpane.elements .element-list li { break-inside: avoid; }
.tabpane.elements .element-list .group { padding-top: 6px; }

/* variables: grid of groups */
.tabpane.variables .vars { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px 14px; align-items: start; }
.tabpane.variables .var-group summary { font-weight: 600; font-family: var(--display-font); font-size: 13.5px; }

/* ---------------------------------------------------------------- popovers */
.popover { border-radius: 10px; }
.layers-pop { display: flex; flex-direction: column; gap: 10px; width: 300px; }
.layers-pop h3, .about h3 { font-size: 15px; font-weight: 600; }
.layers-pop .grid { display: flex; flex-wrap: wrap; gap: 5px; }
.layers-pop .opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--line-soft); font-size: 12.5px; cursor: pointer; }
.layers-pop .opt .switch { flex: none; }
.layers-pop .opt small { display: block; color: var(--muted); font-size: 11px; margin-top: 1px; }
.about { width: 460px; max-height: 70vh; overflow: auto; font-size: 12.5px; line-height: 1.5; }
.about h3 { font-size: 20px; margin-bottom: 4px; }
.about h4 { margin: 12px 0 3px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); font-weight: 600; }
.about p { margin: 0 0 4px; }
.about .lede { color: var(--muted); font-size: 13px; }
.about .keys { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; align-items: center; }
.about .keys kbd { margin: 0; justify-self: start; }
.ctx-menu { border-radius: 8px; }

/* toasts sit under the top bar over the child pane, clear of the drawer */
.toasts { top: 172px; bottom: auto; right: 14px; }
/* progress bar sits under the top bar rather than over it */
.progress-wrap { top: auto; bottom: 0; }
.progress { background: rgba(251, 249, 243, 0.96); border-top: 1px solid var(--line); border-bottom: none; }
.progress-bar { opacity: 0.4; }
