/* Angell Cloud Viewer v1 */
:root {
  --bg: #0B0F17;
  --panel: #111621;
  --panel-2: #171d2a;
  --line: rgba(255,255,255,0.09);
  --line-strong: rgba(255,255,255,0.18);
  --text: #E8ECF2;
  --muted: #8B94A5;
  --accent: #B6FF3B;
  --accent-ink: #0B0F17;
  --danger: #FF6B6B;
  --rail-w: 52px;
  --top-h: 52px;
  --insp-w: 336px;
  --radius: 10px;
  --font: Inter, -apple-system, "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
a:link, a:visited, a:hover, a:active { color: inherit; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
body { position: absolute; width: 100%; overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Layout grid ---------- */
.app { position: absolute; inset: 0; display: grid; grid-template-columns: var(--rail-w) 1fr var(--insp-w); grid-template-rows: var(--top-h) 1fr 34px; grid-template-areas: "top top top" "rail stage insp" "status status insp"; }
.app.insp-hidden { grid-template-columns: var(--rail-w) 1fr 0; }
.app.insp-hidden .inspector { display: none; }
.app.rail-hidden { grid-template-columns: 0 1fr var(--insp-w); }
.app.rail-hidden .rail { display: none; }
.app.insp-hidden.rail-hidden { grid-template-columns: 0 1fr 0; }

/* ---------- Top bar ---------- */
.topbar { grid-area: top; display: flex; align-items: center; gap: 18px; padding: 0 14px 0 12px; background: var(--panel); border-bottom: 1px solid var(--line); min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex: none; }
.brand img { height: 22px; display: block; }
.brand span { font-size: 13px; color: var(--muted); border-left: 1px solid var(--line-strong); padding-left: 10px; line-height: 1; }
.cloudname { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.cloudname h1 { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cloudname .meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.topbar-actions { display: flex; gap: 8px; flex: none; }
.btn { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: transparent; color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; }
.btn:hover { background: rgba(255,255,255,0.06); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #c7ff66; }
.btn.small { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.loadline { position: absolute; left: 0; top: 0; height: 2px; width: 100%; background: transparent; pointer-events: none; z-index: 5; overflow: hidden; }
.loadline::after { content: ""; position: absolute; inset: 0; background: var(--accent); transform: translateX(-100%); }
.loadline.busy::after { animation: loadslide 1.3s ease-in-out infinite; }
@keyframes loadslide { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* ---------- Tool rail ---------- */
.rail { grid-area: rail; display: flex; flex-direction: column; align-items: center; padding: 8px 0; gap: 2px; background: var(--panel); border-right: 1px solid var(--line); overflow: visible; z-index: 4; }
.rail .gap { flex: 1; }
.rail hr { width: 24px; border: 0; border-top: 1px solid var(--line-strong); margin: 6px 0; }
.tool { position: relative; width: 38px; height: 38px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); display: grid; place-items: center; }
.tool svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.tool.active { color: var(--accent-ink); background: var(--accent); }
.tool.active:hover { background: #c7ff66; }
.tool .tip { position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); background: #1c2331; color: var(--text); font-size: 12px; padding: 5px 9px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; border: 1px solid var(--line-strong); z-index: 30; }
.tool .tip kbd { margin-left: 8px; color: var(--muted); font-family: inherit; font-size: 11px; border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 4px; }
.tool:hover .tip, .tool:focus-visible .tip { opacity: 1; }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.tool.active:focus-visible { outline-color: #fff; }

/* ---------- Stage ---------- */
.stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
#potree_render_area { position: absolute; inset: 0; }
#potree_render_area canvas { outline: none; }
#potree_render_area.exporting { inset: auto; left: 0; top: 0; transform-origin: 0 0; }
.hint { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(17,22,33,0.9); border: 1px solid var(--line-strong); color: var(--text); font-size: 13px; padding: 7px 14px; border-radius: 999px; pointer-events: none; display: none; max-width: calc(100% - 40px); text-align: center; }
.hint.show { display: block; }
.hint b { color: var(--accent); font-weight: 600; }
.stage-empty { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--muted); line-height: 1.6; }
.stage-empty.show { display: flex; }
.stage-empty a { color: var(--accent); }
.orbit-badge { position: absolute; right: 14px; bottom: 14px; background: rgba(17,22,33,0.9); border: 1px solid var(--line-strong); font-size: 12px; color: var(--text); padding: 5px 10px; border-radius: 999px; display: none; pointer-events: none; }
.orbit-badge.show { display: block; }
.orbit-badge i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 1px; }
.export-veil { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(11,15,23,0.55); z-index: 6; }
.export-veil.show { display: flex; }
.export-card { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 12px; padding: 18px 20px; width: 300px; }
.export-card h3 { margin: 0 0 6px; font-size: 14px; }
.export-card p { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

/* ---------- Status ---------- */
.status { grid-area: status; display: flex; align-items: center; gap: 18px; padding: 0 14px; background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 0; overflow: hidden; }
.status span { white-space: nowrap; }
.status .live { color: var(--text); }
.status .right { margin-left: auto; }

/* ---------- Inspector ---------- */
.inspector { grid-area: insp; display: flex; flex-direction: column; background: var(--panel); border-left: 1px solid var(--line); min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; flex: none; }
.tabs button { flex: 1; background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 12px 4px 10px; font-size: 13px; font-weight: 500; margin-bottom: -1px; }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.panes { flex: 1; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.pane { display: none; padding: 14px 16px 24px; }
.pane.active { display: block; }
.group { padding: 12px 0; border-bottom: 1px solid var(--line); }
.group:last-child { border-bottom: 0; }
.group h2 { margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.seg { display: flex; background: rgba(255,255,255,0.05); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--muted); border-radius: 6px; padding: 6px 4px; font-size: 13px; font-weight: 500; }
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--accent); color: var(--accent-ink); }
.row { display: grid; grid-template-columns: 96px 1fr 52px; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; }
.row label { color: var(--text); }
.row .val { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; font-size: 12px; }
.row.wide { grid-template-columns: 96px 1fr; }
.row select, .row input[type=text], .row input[type=number] { width: 100%; background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text); border-radius: 6px; padding: 6px 8px; font-size: 13px; }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 26px !important; }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 0; }
input[type=range]::-webkit-slider-runnable-track { height: 3px; background: rgba(255,255,255,0.16); border-radius: 2px; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--text); margin-top: -5.5px; border: 0; }
input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px var(--accent); }
input[type=range]::-moz-range-track { height: 3px; background: rgba(255,255,255,0.16); border-radius: 2px; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--text); border: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 6px 0; cursor: pointer; }
.check input { width: 15px; height: 15px; accent-color: var(--accent); margin: 0; }
.legend { list-style: none; margin: 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 4px 0; }
.legend li i { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.legend li input { accent-color: var(--accent); margin: 0; }
.legend li span { flex: 1; color: var(--text); }
.legend li span small { color: var(--muted); margin-left: 6px; }
.swatches { display: flex; gap: 6px; }
.swatches button { flex: 1; height: 26px; border-radius: 6px; border: 2px solid transparent; padding: 0; background: #000; }
.swatches button.active { border-color: var(--accent); }
.swatches button[data-bg=gradient] { background: linear-gradient(#0f1523, #2a3140); }
.swatches button[data-bg=white] { background: #fff; }
.swatches button[data-bg=skybox] { background: linear-gradient(#5c8fd6, #c8dcf2); }
.hintline { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.5; }

/* Lists in Tools / Notes / Fly */
.list { list-style: none; margin: 0; padding: 0; }
.item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; background: rgba(255,255,255,0.02); }
.item.selected { border-color: var(--accent); }
.item .head { display: flex; align-items: center; gap: 8px; }
.item .head .name { flex: 1; font-size: 13px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .head .kind { font-size: 11px; color: var(--muted); }
.item .body { margin-top: 6px; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text); }
.item .body .big { font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
.item .body .sub { font-size: 12px; color: var(--muted); }
.item .actions { display: flex; gap: 6px; margin-top: 8px; }
.iconbtn { width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--line-strong); background: transparent; color: var(--muted); display: inline-grid; place-items: center; padding: 0; flex: none; }
.iconbtn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.iconbtn.danger:hover { color: var(--danger); border-color: var(--danger); }
.item input[type=text], .item textarea { width: 100%; background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text); border-radius: 6px; padding: 6px 8px; font-size: 13px; margin-top: 6px; resize: vertical; }
.item textarea { min-height: 52px; }
.item input.dur { width: 58px; background: var(--panel-2); border: 1px solid var(--line-strong); color: var(--text); border-radius: 6px; padding: 4px 6px; font-size: 12px; text-align: right; }
.empty { font-size: 13px; color: var(--muted); padding: 8px 0; line-height: 1.55; }
.empty b { color: var(--text); font-weight: 600; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.btnrow .btn { flex: 1; justify-content: center; }
.playbar { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.playbar .scrub { flex: 1; }
.playbar .time { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 60px; text-align: right; }

/* ---------- Profile (cross-section) panel ---------- */
.profile { position: absolute; left: calc(var(--rail-w) + 14px); right: calc(var(--insp-w) + 14px); bottom: 48px; height: 280px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 12px; display: none; flex-direction: column; overflow: hidden; z-index: 7; }
.app.insp-hidden .profile { right: 14px; }
.profile.show { display: flex; }
.profile .phead { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.profile .phead .name { font-weight: 600; }
.profile .phead .info { color: var(--muted); font-size: 12px; flex: 1; font-variant-numeric: tabular-nums; }
.profile .phead label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.profile .phead input[type=range] { width: 110px; }
.profile .pbody { flex: 1; position: relative; min-height: 0; }
.profile canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; cursor: crosshair; }
.profile .readout { position: absolute; left: 10px; top: 8px; font-size: 12px; color: var(--text); background: rgba(11,15,23,0.8); border: 1px solid var(--line); padding: 3px 8px; border-radius: 6px; display: none; font-variant-numeric: tabular-nums; pointer-events: none; }
.profile .readout.show { display: block; }

/* ---------- Toast ---------- */
.toast { position: absolute; left: 50%; bottom: 52px; transform: translate(-50%, 8px); background: #1c2331; border: 1px solid var(--line-strong); color: var(--text); font-size: 13px; padding: 9px 14px; border-radius: 8px; opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 40; max-width: 80%; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); }

/* ---------- Keyboard help ---------- */
.help { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(11,15,23,0.6); z-index: 50; }
.help.show { display: flex; }
.help .card { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 12px; padding: 18px 22px; width: min(520px, 92vw); }
.help h3 { margin: 0 0 12px; font-size: 15px; }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 13px; }
.help dt { color: var(--muted); }
.help kbd { font-family: inherit; font-size: 12px; border: 1px solid var(--line-strong); border-radius: 4px; padding: 1px 6px; color: var(--text); }
.help .close { margin-top: 14px; }

/* ---------- Catalogue (landing) ---------- */
.catalogue { position: absolute; inset: 0; display: none; overflow-y: auto; background: var(--bg); z-index: 60; }
.catalogue.show { display: block; }
.cat-wrap { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
.cat-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 40px; }
.cat-top img { height: 28px; }
.cat-top a { color: var(--muted); font-size: 13px; text-decoration: none; }
.cat-top a:hover { color: var(--text); }
.cat-hero { margin-bottom: 36px; max-width: 640px; }
.cat-hero h1 { margin: 0 0 10px; font-size: 34px; letter-spacing: -0.02em; font-weight: 600; line-height: 1.1; }
.cat-hero p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.55; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
a.cat-card:link, a.cat-card:visited, a.cat-card:hover { color: var(--text); }
.cat-card { display: block; text-decoration: none; color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 18px 18px 16px; background: var(--panel); position: relative; }
.cat-card:hover { border-color: var(--line-strong); background: var(--panel-2); }
.cat-card:focus-visible { outline: 2px solid var(--accent); }
.cat-card .thumb { height: 120px; border-radius: 8px; margin-bottom: 14px; background: radial-gradient(120% 90% at 30% 20%, #2a3446 0, #141a26 60%, #0f141e 100%); position: relative; overflow: hidden; }
.cat-card .thumb::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(182,255,59,0.55) 0.8px, transparent 1.2px); background-size: 9px 9px; opacity: 0.35; mask-image: linear-gradient(160deg, transparent 20%, #000 60%, transparent 95%); -webkit-mask-image: linear-gradient(160deg, transparent 20%, #000 60%, transparent 95%); }
.cat-card h2 { margin: 0 0 6px; font-size: 16px; font-weight: 600; }
.cat-card p { margin: 0 0 12px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.cat-card .facts { display: flex; gap: 14px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.cat-card .facts b { color: var(--text); font-weight: 500; }
.cat-card .open { position: absolute; right: 16px; bottom: 14px; font-size: 12px; color: var(--accent); font-weight: 500; }
.cat-empty { color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  :root { --insp-w: 300px; }
}
@media (max-width: 760px) {
  :root { --rail-w: 0px; --top-h: 48px; }
  .app { grid-template-columns: 1fr; grid-template-rows: var(--top-h) 1fr 34px; grid-template-areas: "top" "stage" "status"; }
  .app.insp-hidden { grid-template-columns: 1fr; }
  .rail { display: flex !important; position: absolute; left: 12px; right: 12px; bottom: 46px; flex-direction: row; width: auto; height: 46px; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 12px; overflow-x: auto; overflow-y: hidden; gap: 0; z-index: 8; }
  .rail hr { width: 0; height: 22px; border: 0; border-left: 1px solid var(--line-strong); margin: 0 4px; }
  .rail .gap { display: none; }
  .tool .tip { display: none; }
  .brand span { display: none; }
  .cloudname .meta { display: none; }
  .inspector { display: flex !important; position: absolute; left: 0; right: 0; bottom: 0; top: 40%; border-left: 0; border-top: 1px solid var(--line-strong); border-radius: 16px 16px 0 0; z-index: 9; transform: translateY(100%); transition: transform .2s ease; }
  .app.sheet-open .inspector { transform: translateY(0); }
  .app.insp-hidden .inspector { display: flex !important; }
  .profile { left: 12px; right: 12px; bottom: 100px; height: 220px; }
  .status .right { display: none; }
  .btn .label { display: none; }
  .btn:has(.label) { width: 32px; padding: 0; justify-content: center; }
  .hint { top: 10px; font-size: 12px; }
  .cat-hero h1 { font-size: 26px; }
}

.cat-card .thumb.has-img { background-size: cover; background-position: center; }
.cat-card .thumb.has-img::before, .cat-card .thumb.has-img::after { display: none; }
