/* Creator OS prototype: canvas chrome (spec section 5). Fixed --cv-* colours only, so the palette never recolours the
   chrome. The screens inside #world take their colours from the tokens, which the palette sets on #world. */

:root {
  --cv-bg: #cfccc5;
  --cv-dot: #b9b6ae;
  --cv-ink: #1d1d1f;
  --cv-grey: #6f6c65;
  --cv-line: #b4b1a9;
  --cv-panel: #f5f3ee;
  --cv-panel-2: #e8e5de;
  --cv-hot: #ff4d2e;
  --cv-nyet: #8a877f;
  --cv-top: 48px;
}

html, body { margin: 0; height: 100%; overflow: hidden; background: var(--cv-bg); }
body { color: var(--cv-ink); font: 400 12px/1.3 var(--font-mono); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--cv-hot); outline-offset: 1px; }

/* ---------------------------------------------------------------- top bar */
#topbar {
  position: fixed; inset: 0 0 auto 0; z-index: 30; height: var(--cv-top);
  display: flex; align-items: stretch; gap: 16px; padding: 0 12px 0 16px;
  background: var(--cv-panel); border-bottom: 1px solid var(--cv-ink);
}
.tb-brand { align-self: center; flex: none; font-weight: 700; font-size: 12px; letter-spacing: .14em; white-space: nowrap; }
#tabs { flex: 1; min-width: 0; display: flex; align-items: stretch; overflow-x: auto; scrollbar-width: none; }
#tabs::-webkit-scrollbar { display: none; }
#tabs button {
  flex: none; padding: 0 10px; border: 0; background: none; cursor: pointer;
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--cv-grey); white-space: nowrap;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
#tabs button:hover { color: var(--cv-ink); }
#tabs button[aria-current="true"] { color: var(--cv-ink); font-weight: 700; border-bottom-color: var(--cv-ink); }
#tabs button.is-missing { font-style: italic; opacity: .6; }
.tb-tools { flex: none; display: flex; align-items: center; gap: 6px; }
#zoom-readout { min-width: 48px; margin-right: 6px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.tb-tools button {
  height: 28px; padding: 0 10px; border: 1px solid var(--cv-ink); background: none; cursor: pointer;
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
}
.tb-tools button:hover { background: var(--cv-panel-2); }
.tb-tools button[aria-expanded="true"] { background: var(--cv-ink); color: var(--cv-panel); }

/* ---------------------------------------------------------------- viewport and world */
#viewport {
  position: fixed; inset: var(--cv-top) 0 0 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  background-color: var(--cv-bg);
  background-image: radial-gradient(circle, var(--cv-dot) 1.2px, transparent 1.6px);
  background-size: 40px 40px; background-position: 0 0;
}
#viewport.no-dots { background-image: none; }
#viewport.is-panning, body.is-space #viewport { cursor: grabbing; }
body.is-space #viewport:not(.is-panning) { cursor: grab; }
body.is-space .cv-frame * { cursor: grab !important; }
#world { position: absolute; left: 0; top: 0; width: 0; height: 0; transform-origin: 0 0; }

/* ---------------------------------------------------------------- frames */
.cv-frame { position: absolute; z-index: 2; width: 1586px; height: 992px; outline: 1px solid rgba(29, 29, 31, .16); }
.cv-body {
  width: 1586px; height: 992px; overflow: hidden;
  content-visibility: auto; contain-intrinsic-size: 1586px 992px; contain: layout paint style;
}
.cv-frame.is-loading .cv-body { background: #dedbd3; }
.cv-frame.is-loading .cv-body::after {
  content: "LOADING"; display: block; padding: 40px; font: 500 48px/1 var(--font-mono); letter-spacing: .1em; color: var(--cv-nyet);
}
.cv-label {
  position: absolute; left: 0; bottom: 100%; width: 1586px; height: 56px; padding-bottom: 12px; box-sizing: border-box;
  display: flex; align-items: flex-end; gap: 24px; overflow: hidden; white-space: nowrap;
  font: 500 22px/1 var(--font-mono); color: #1d1d1f;
}
.cv-label__id { flex: none; font-weight: 700; letter-spacing: .04em; }
.cv-label__state { flex: none; color: var(--cv-grey); }
.cv-label__base { flex: none; padding: 2px 8px; border: 1.5px solid #1d1d1f; font-size: 16px; letter-spacing: .1em; }
.cv-label__note { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--cv-grey); font-size: 18px; font-weight: 400; }
.lod-far .cv-label__note, .lod-far .cv-label__state { display: none; }
.lod-hide.lod-far .cv-body { content-visibility: hidden; background: #dedbd3; }

.cv-plabel { position: absolute; left: -1100px; width: 1000px; text-align: right; color: #1d1d1f; pointer-events: none; }
.cv-plabel__t { font: 400 160px/.9 var(--font-display); text-transform: uppercase; overflow-wrap: anywhere; }
.cv-plabel__s { margin-top: 24px; font: 500 24px/1.2 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--cv-grey); }

.cv-nyet {
  width: 1586px; height: 992px; box-sizing: border-box; padding: 64px 72px; border: 3px dashed #8a877f; background: rgba(255, 255, 255, .22);
  color: #1d1d1f;
}
.cv-nyet__id { font: 400 120px/.95 var(--font-display); text-transform: uppercase; overflow-wrap: anywhere; }
.cv-nyet__tag { margin-top: 28px; font: 500 28px/1 var(--font-mono); letter-spacing: .16em; color: #6f6c65; }
.cv-nyet__msg { margin-top: 20px; font: 400 20px/1.4 var(--font-mono); color: #6f6c65; }
.cv-frame--nyet { outline-color: transparent; }

.cv-linked { cursor: pointer; }
.cv-linked:hover { outline: 2px solid #ff4d2e; outline-offset: 3px; }

/* ---------------------------------------------------------------- arrows */
/* idle arrows sit under the frames (z 1 < frame z 2); the hovered frame's arrows move to #arrows-hot above them */
#arrows, #arrows-hot { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
#arrows { z-index: 1; }
#arrows-hot { z-index: 6; }
.cv-link { opacity: .25; }
.cv-link path { fill: none; stroke: #1d1d1f; stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.cv-link path.is-dashed { stroke-dasharray: 6 5; }
.cv-link polygon, .cv-link circle { fill: #1d1d1f; }
.cv-link.is-hot { opacity: 1; }
.cv-link.is-hot path { stroke: #ff4d2e; stroke-width: 2.5px; }
.cv-link.is-hot polygon, .cv-link.is-hot circle { fill: #ff4d2e; }
.lod-far .cv-link { opacity: .25; }
.lod-far .cv-link.is-hot { opacity: 1; }

/* ---------------------------------------------------------------- minimap, hint, notice */
#minimap {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; padding: 0; line-height: 0;
  background: rgba(245, 243, 238, .94); border: 1px solid var(--cv-ink); cursor: crosshair;
}
#minimap canvas { display: block; touch-action: none; }
body.palette-open #minimap { right: 316px; }
#cv-hint {
  position: fixed; left: 16px; bottom: 12px; z-index: 20; margin: 0; padding: 4px 8px;
  background: rgba(245, 243, 238, .9); font-size: 11px; letter-spacing: .04em; color: var(--cv-grey); pointer-events: none;
}
#cv-notice {
  position: fixed; left: 50%; top: 64px; z-index: 40; transform: translateX(-50%); max-width: min(720px, calc(100vw - 32px));
  padding: 10px 16px; background: var(--cv-ink); color: var(--cv-panel); font-size: 12px; line-height: 1.5;
}

/* ---------------------------------------------------------------- palette panel */
#palette-panel {
  position: fixed; top: var(--cv-top); right: 0; bottom: 0; z-index: 35; width: 300px; display: flex; flex-direction: column;
  background: var(--cv-panel); border-left: 1px solid var(--cv-ink); color: var(--cv-ink);
}
.pp-head { flex: none; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--cv-line); }
.pp-title { font-weight: 700; letter-spacing: .14em; }
.pp-edited { padding: 1px 6px; border: 1px solid var(--cv-hot); color: var(--cv-hot); font-size: 10px; letter-spacing: .12em; }
.pp-x { margin-left: auto; width: 28px; height: 28px; border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; }
.pp-x:hover { background: var(--cv-panel-2); }
.pp-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 14px 12px; }
.pp-h { margin: 16px 0 8px; font: 700 10px/1 var(--font-mono); letter-spacing: .16em; text-transform: uppercase; color: var(--cv-grey); }
.pp-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pp-preset { display: block; padding: 6px; border: 1px solid var(--cv-line); background: #fff; text-align: left; cursor: pointer; }
.pp-preset:hover { border-color: var(--cv-ink); }
.pp-preset[aria-pressed="true"] { outline: 2px solid var(--cv-ink); outline-offset: -1px; border-color: var(--cv-ink); }
.pp-sw { display: flex; height: 22px; border: 1px solid rgba(0, 0, 0, .25); }
.pp-sw i { flex: 1; }
.pp-name { display: block; margin-top: 5px; font-size: 10.5px; line-height: 1.25; }
.pp-name b { margin-right: 4px; }
.pp-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.pp-row--stack { flex-direction: column; align-items: stretch; gap: 6px; }
.pp-lbl { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.pp-seg { display: flex; border: 1px solid var(--cv-ink); }
.pp-seg button { flex: 1; }
.pp-seg button { padding: 5px 7px; border: 0; border-left: 1px solid var(--cv-ink); background: #fff; font-size: 10px; cursor: pointer; white-space: nowrap; }
.pp-seg button:first-child { border-left: 0; }
.pp-seg button[aria-checked="true"] { background: var(--cv-ink); color: var(--cv-panel); }
.pp-switch { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; cursor: pointer; font-size: 11px; }
.pp-switch i { position: relative; width: 34px; height: 18px; border: 1px solid var(--cv-ink); background: #fff; }
.pp-switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: var(--cv-ink); }
.pp-switch[aria-checked="true"] i { background: var(--cv-ink); }
.pp-switch[aria-checked="true"] i::after { left: 18px; background: var(--cv-panel); }
.pp-tokens { display: flex; flex-direction: column; gap: 4px; }
.pp-tok { display: grid; grid-template-columns: 1fr 26px 76px; align-items: center; gap: 8px; }
.pp-tok label { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pp-tok input[type="color"] { width: 26px; height: 22px; padding: 0; border: 1px solid var(--cv-ink); background: none; cursor: pointer; }
.pp-tok input[type="text"] { width: 100%; box-sizing: border-box; height: 22px; padding: 0 5px; border: 1px solid var(--cv-line); background: #fff; font: 11px var(--font-mono); text-transform: lowercase; }
.pp-tok input[type="text"].is-bad { border-color: var(--cv-hot); color: var(--cv-hot); }
.pp-actions { flex: none; display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--cv-line); background: var(--cv-panel); }
.pp-actions button { flex: 1; height: 30px; border: 1px solid var(--cv-ink); background: none; cursor: pointer; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.pp-actions button:hover { background: var(--cv-panel-2); }
.pp-actions button.is-flash { background: var(--cv-ink); color: var(--cv-panel); }

@media (max-width: 760px) {
  .tb-brand { display: none; }
  #cv-hint { display: none; }
}
