/* Phos Editor · Diffused layer (v0.03)
   Same mark, palette and type as the core identity; set on blackout with
   diffused glass, grain and the Kelvin gradient around it. The diagram
   stays sharp and neutral: the light lives in the UI, not on the plan. */

@property --ga { syntax: "<number>"; inherits: false; initial-value: 0; }
@property --gx { syntax: "<percentage>"; inherits: false; initial-value: 50%; }

:root,
[data-theme=dark] {
  --deep: #050506;
  --surface: #0a0a0b;
  --surface-alt: rgba(255,255,255,0.05);
  --ink: #ffffff;
  --ink-subtle: #a1a1aa;
  --ink-faint: #71717a;
  --ink-muted: #a1a1aa;
  --hairline: rgba(255,255,255,0.09);
  --radius-2xl: 28px;

  --glass-top: rgba(255,255,255,0.10);
  --glass-mid: rgba(255,255,255,0.03);
  --glass-low: rgba(255,255,255,0.05);
  --glass-edge: rgba(255,255,255,0.09);
  --glass-tint: rgba(10,10,11,0.62);
  --glass-field: rgba(19,19,21,0.82);
  --key-wash: rgba(255,90,31,0.16);
  --key-line: rgba(255,90,31,0.55);
  --shadow-glass: inset 0 0 0 1px rgba(255,255,255,0.09), 0 22px 44px -24px rgba(0,0,0,0.9);
  --shadow-lit: inset 0 0 0 1px rgba(255,90,31,0.55);
  --shadow-focus: inset 0 0 0 1px #FF5A1F, 0 0 0 4px rgba(255,90,31,0.16);
  --blur-glass: 28px;
  --blur-nav: 40px;

  --kelvin: linear-gradient(90deg, #0A0A0B 0%, #5C1410 14%, #E2351C 30%, #FF5A1F 40%, #FF961F 50%, #FFD64A 60%, #FFF6DC 70%, #7FE6FF 80%, #2BB4FF 89%, #2A45D0 96%, rgba(16,22,80,0) 100%);

  /* the glass material, as one background stack (glow sits under the fill) */
  --glow: radial-gradient(70% 140% at var(--gx) 0%, rgba(255,128,64,calc(0.34 * var(--ga))) 0%, rgba(255,90,31,calc(0.12 * var(--ga))) 45%, rgba(255,90,31,0) 75%);
  --glass-fill: linear-gradient(180deg, var(--glass-top) 0%, var(--glass-mid) 42%, var(--glass-low) 100%);
}

html, body { background: var(--deep); }
body { color: var(--ink); }
::selection { background: rgba(255,90,31,0.35); color: #fff; }

/* ── Grain over everything (never on exports: the PNG comes from the scene) */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 9999; pointer-events: none;
  opacity: 0.14; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.4 -.2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 220px 220px;
}

/* ── Layout: the canvas runs full height, the header bar floats over it */
.app { grid-template: "top" 72px "canvas" 1fr / 1fr; background: var(--deep); }
.canvas { grid-area: 1 / 1 / -1 / -1; }

/* Kelvin light around the set: warm from the key side, cool from the far side.
   Kept low and to the edges so the plan reads cleanly. */
.canvas::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(42% 46% at 0% 100%, rgba(226,53,28,0.20) 0%, rgba(255,90,31,0.10) 38%, rgba(255,90,31,0) 72%),
    var(--surface);
}
.canvas-grid {
  z-index: 0;
  background-color: transparent;
  /* one weight for every line: the light one */
  --grid-line: rgba(255,255,255,0.035);
  background-image:
    linear-gradient(to right, var(--grid-line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid-line) 1px, transparent 1px);
  background-size: calc(var(--grid-step) / 2) calc(var(--grid-step) / 2);
}
.canvas-grid[data-minor="0"] { background-size: var(--grid-step) var(--grid-step); }
.canvas .excalidraw { --default-bg-color: transparent; }
.canvas .excalidraw .excalidraw__canvas { background: transparent; }

/* ── Glass material ─────────────────────────────────────────────── */
.toolbar, .inspector, .tb-pop, .sheet, .notice, .hint.quiet,
.canvas .excalidraw .Island,
.canvas .excalidraw .dropdown-menu-container,
.canvas .excalidraw .context-menu,
.canvas .excalidraw .zoom-actions,
.canvas .excalidraw .undo-redo-buttons,
.canvas .excalidraw .main-menu-trigger {
  background: var(--glow), var(--glass-fill), rgba(10,10,11,0.55) !important;
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(170%) contrast(1.06);
          backdrop-filter: blur(var(--blur-glass)) saturate(170%) contrast(1.06);
  box-shadow: var(--shadow-glass) !important;
  border: 0 !important;
  color: var(--ink);
  transition: --ga .32s var(--ease-out), --gx .12s linear;
}
@media (prefers-reduced-transparency: reduce) {
  .topbar, .toolbar, .inspector, .tb-pop, .sheet, .notice { background: #1F1F22 !important; -webkit-backdrop-filter: none; backdrop-filter: none; }
}

/* ── Header bar: the landing page's glass pill (Diffused HeaderBar) */
.topbar {
  grid-area: top; position: relative; z-index: 8; isolation: isolate; box-sizing: border-box;
  width: calc(100% - 32px); max-width: 1280px; margin: 12px auto 0; justify-self: center;
  height: auto; min-height: 60px; padding: 8px 8px 8px 20px; gap: 12px;
  border: 0; border-radius: var(--radius-pill);
  background: linear-gradient(180deg, rgba(31,31,34,0.56) 0%, rgba(10,10,11,0.526) 55%, rgba(255,90,31,0) 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.07);
  -webkit-backdrop-filter: blur(40px) saturate(170%);
          backdrop-filter: blur(40px) saturate(170%);
  color: #fff;
  --mx: 50%; --my: 0px; --gl: 0; --eg: 0.55;
}
/* warm glow rising from the bottom edge under the cursor */
.topbar::before {
  content: ""; position: absolute; z-index: -1; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(ellipse 90% 130% at var(--bx, var(--mx)) 100%, rgba(255,128,64,0.34), rgba(255,90,31,0.12) 45%, rgba(255,90,31,0) 80%);
  opacity: var(--gl);
}
/* the rim light: rests at the top centre, follows the cursor around the pill */
.topbar::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; padding: 1px;
  background: radial-gradient(240px circle at var(--mx) var(--my), rgba(255,242,228,0.95), rgba(255,150,90,0.55) 38%, rgba(255,255,255,0) 72%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: var(--eg);
}
@media (prefers-reduced-transparency: reduce) { .topbar { background: #1F1F22; -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (prefers-contrast: more) { .topbar { background: #1F1F22; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.6); } }

.brand { gap: 8px; color: #fff; }
.brand svg { width: 26px; height: 26px; flex: none; }
.wordmark { font-size: 26px; font-weight: 600; letter-spacing: -0.04em; line-height: 1; }
.tag { color: var(--ink-subtle); font-size: 11px; letter-spacing: 0.1em; padding-left: 8px; }
.title { color: #fff; border: 0; border-radius: var(--radius-pill); padding: 0 14px; min-height: 44px; font-size: 15px; font-weight: 500; background: transparent; }
.title:hover { background: rgba(255,255,255,0.06); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.09); }
.title:focus { background: var(--glass-field); box-shadow: var(--shadow-focus); outline: 0; }
.topbar .actions { gap: 12px; }
/* links in Geist Mono, one white action */
.topbar .actions .ghost, .topbar .actions .ghost:not(.icon) {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; border: 0; border-radius: 8px;
  background: transparent; box-shadow: none; color: #fff;
  font-family: var(--font-mono); font-size: 11px; font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase;
  transition: color .2s var(--ease-out);
}
.topbar .actions .primary, [data-theme=dark] .topbar .actions .primary {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; border: 0; border-radius: var(--radius-pill);
  background: #fff; color: #0A0A0B; box-shadow: none; font-size: 15px; font-weight: 500;
  transition: transform .16s var(--ease-out), background-color .25s ease;
}
.topbar .actions .primary:active { transform: scale(0.97); transition-duration: .1s; background: #FF5A1F; }
@media (hover: hover) and (pointer: fine) {
  .topbar .actions .ghost:hover { background: transparent; color: #FF5A1F; }
  .topbar .actions .primary:hover, [data-theme=dark] .topbar .actions .primary:hover { background: #FF5A1F; color: #0A0A0B; box-shadow: none; }
}
.topbar :focus-visible { outline: 0; box-shadow: var(--shadow-focus); }

/* ── Buttons: white primary that turns key only while hovered; glass ghost */
.primary, .ghost { font-size: 13px; font-weight: 500; padding: 8px 16px; transition: transform .16s var(--ease-out), background-color .2s var(--ease-out), color .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.primary, [data-theme=dark] .primary { background: #fff; color: #0A0A0B; border: 0; }
.ghost { border: 0; background: var(--glass-tint); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); }
@media (hover: hover) and (pointer: fine) {
  .primary:hover, [data-theme=dark] .primary:hover { background: #FF5A1F; color: #0A0A0B; box-shadow: 0 0 0 4px rgba(255,90,31,0.16), 0 0 28px rgba(255,90,31,0.45); }
  .ghost:hover { background: rgba(255,255,255,0.10); }
}

/* ── Toolbar */
.toolbar { top: 84px; border-radius: 18px; padding: 5px; }
.tb-sep { background: rgba(255,255,255,0.09); }
.tb-btn { color: var(--ink); border-radius: 13px; }
@media (hover: hover) and (pointer: fine) { .tb-btn:hover, .tb-item:hover { background: rgba(255,255,255,0.07); } }
.tb-btn.open { background: rgba(255,255,255,0.07); }
.tb-btn.active, .tb-btn.active:hover { background: #fff; color: #0A0A0B; box-shadow: 0 6px 18px -8px rgba(255,255,255,0.45); }
.tb-btn.toggle.on, .tb-item.on { background: var(--key-wash); box-shadow: var(--shadow-lit); }
.tb-btn:focus-visible, .tb-item:focus-visible, .insp-icon:focus-visible, .chip:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
.tb-pop { border-radius: 20px; padding: 6px; top: calc(100% + 12px); }
.tb-pop-head { color: var(--ink-subtle); }
.tb-item { border-radius: 12px; color: var(--ink); }
.tb-pop-foot { color: var(--ink-subtle); }

/* ── Inspector */
.inspector { top: 152px; right: 16px; border-radius: 24px; padding: 16px 18px 18px; max-height: calc(100% - 232px); scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.14) transparent; }
.insp-kicker, .field > span, .tb-pop-head { font-size: 11px; letter-spacing: 0.1em; color: var(--ink-subtle); }
.insp-icon { color: var(--ink-subtle); border-radius: 10px; }
.insp-icon:hover { background: rgba(255,255,255,0.07); color: var(--ink); }
.field input, .field select {
  border: 0; border-radius: var(--radius-md); background: var(--glass-field);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.09); color: var(--ink); padding: 9px 12px;
  transition: box-shadow .16s var(--ease-out);
}
.field input::placeholder { color: var(--ink-faint); }
.field input:focus, .field select:focus { outline: 0; box-shadow: var(--shadow-focus); }
.field select option { background: #131315; color: #fff; }
.chip { border: 0; background: var(--glass-tint); color: var(--ink); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); padding: 5px 11px; }
.chip:hover { border: 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.32); }
.chip.on, [data-theme=dark] .chip.on { background: var(--key-wash); color: #fff; box-shadow: var(--shadow-lit); }
.readout { background: var(--glass-field); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.09); border-radius: var(--radius-md); color: var(--ink-subtle); }
.readout .mono { color: #fff; }
.note { color: var(--ink-subtle); }
.cam-icon { border: 0; background: var(--glass-field); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.09); border-radius: var(--radius-md); color: var(--ink); }
.cam-icon:hover { background: rgba(255,255,255,0.08); }
.cam-icon.on { background: var(--key-wash); box-shadow: var(--shadow-lit); }

/* ── Hints, readouts, notices */
.hint { background: #fff; color: #0A0A0B; box-shadow: 0 12px 30px -12px rgba(0,0,0,0.9); }
.hint.quiet { color: var(--ink-subtle); }
.angle-readout { background: #fff; color: #0A0A0B; border-radius: 8px; }
.notice { border-radius: var(--radius-pill); padding: 8px 8px 8px 18px; color: var(--ink); }
.guide { stroke: rgba(255,255,255,0.4); }
.guide-end { fill: #0A0A0B; stroke: #fff; }

/* ── Scale bar stays functional ink, label in mono subtle */
.scalebar span { color: var(--ink-subtle); }

/* ── Sheets (Gear list, confirm) */
.modal { background: rgba(5,5,6,0.62); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.sheet { border-radius: var(--radius-2xl); position: relative; overflow: hidden auto; }
.sheet::before { /* Kelvin hairline: every white balance a fixture can take */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--kelvin); opacity: 0.9; pointer-events: none;
}
.sheet h2 { font-weight: 600; letter-spacing: -0.02em; }
.sheet h3 { color: var(--ink-subtle); }
.sheet li { border-bottom-color: rgba(255,255,255,0.07); }
.sheet.confirm p { color: var(--ink-subtle); }

/* ── Excalidraw chrome, in the same glass */
.canvas .excalidraw .layer-ui__wrapper { top: 76px; height: calc(100% - 76px); }
.canvas .excalidraw,
.canvas .excalidraw.theme--dark {
  --island-bg-color: transparent;
  --popup-bg-color: rgba(19,19,21,0.92);
  --input-bg-color: var(--glass-field);
  --input-border-color: rgba(255,255,255,0.09);
  --button-hover-bg: rgba(255,255,255,0.07);
  --color-surface-mid: rgba(255,255,255,0.07);
  --color-surface-high: rgba(255,255,255,0.07);
  --color-primary-light: rgba(255,255,255,0.07);
  --keybinding-color: var(--ink-subtle);
  --focus-highlight-color: #FF5A1F;
  --overlay-bg-color: rgba(5,5,6,0.62);
  --color-selection: #a1a1aa;
}
.canvas .excalidraw .zoom-actions, .canvas .excalidraw .undo-redo-buttons { border-radius: 14px; overflow: hidden; }
.canvas .excalidraw .main-menu-trigger { border-radius: 14px; }
.canvas .excalidraw .zoom-actions button, .canvas .excalidraw .undo-redo-buttons button, .canvas .excalidraw .main-menu-trigger { background: transparent !important; }
.canvas .excalidraw .zoom-actions button:hover, .canvas .excalidraw .undo-redo-buttons button:hover, .canvas .excalidraw .main-menu-trigger:hover { background: rgba(255,255,255,0.07) !important; }
.canvas .excalidraw .dropdown-menu-container { border-radius: 20px; padding: 6px; }
.canvas .excalidraw .dropdown-menu-item, .canvas .excalidraw .context-menu-item { border-radius: 10px; }
.canvas .excalidraw .dropdown-menu-item:hover, .canvas .excalidraw .context-menu-item:hover { background: rgba(255,255,255,0.07); }
.canvas .excalidraw .dropdown-menu-group-title { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px; color: var(--ink-subtle); }
.canvas .excalidraw .context-menu { border-radius: 16px; padding: 6px; }

/* ── Small screens: header bar keeps its shape */
@media (width <= 760px) {
  .topbar { width: calc(100% - 24px); padding-left: 16px; gap: 8px; }
  .title { min-width: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  .toolbar, .inspector, .tb-pop, .sheet, .notice { transition: none; }
}

/* Popovers and menus sit over the plan: denser glass so labels never fight the diagram */
.tb-pop, .inspector,
.canvas .excalidraw .dropdown-menu-container,
.canvas .excalidraw .context-menu {
  background: var(--glow), var(--glass-fill), rgba(10,10,11,0.86) !important;
}

/* ── White balance (lights) */
.wb { margin-bottom: var(--space-4); }
.wb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wb-label { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; font-size: 11px; color: var(--ink-subtle); }
.wb-switch { position: relative; width: 38px; height: 22px; border: 0; padding: 0; border-radius: 999px; background: var(--glass-field); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); flex: none; transition: background-color .2s var(--ease-out), box-shadow .2s var(--ease-out); }
.wb-switch i { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #a1a1aa; transition: transform .2s var(--ease-out), background-color .2s var(--ease-out); }
.wb-switch.on { background: var(--key-wash); box-shadow: var(--shadow-lit); }
.wb-switch.on i { transform: translateX(16px); background: #fff; }
.wb-switch:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
.wb-body { margin-top: 12px; }
.wb-range { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; margin: 0; background: transparent; cursor: pointer; }
.wb-range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: var(--kelvin-track); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10); }
.wb-range::-moz-range-track { height: 6px; border-radius: 999px; background: var(--kelvin-track); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10); }
.wb-range::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(10,10,11,0.85), 0 2px 10px rgba(0,0,0,0.6); }
.wb-range::-moz-range-thumb { width: 18px; height: 18px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(10,10,11,0.85), 0 2px 10px rgba(0,0,0,0.6); }
.wb-range:focus-visible { outline: 0; }
.wb-range:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 3px #0A0A0B, 0 0 0 6px rgba(255,90,31,0.5); }
.wb-read { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.wb-swatch { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2); flex: none; }
.wb-read .mono { font-size: 15px; letter-spacing: 0.04em; color: #fff; text-transform: none; font-variant-numeric: tabular-nums; }
.wb-scale { margin-left: auto; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; color: var(--ink-faint); }
:root {
  /* the editor's 1,500–10,000 K range on the Kelvin colours */
  --kelvin-track: linear-gradient(90deg, #E2351C 0%, #FF5A1F 5.9%, #FF961F 12.9%, #FFD64A 20%, #FFECBE 32.9%, #FFFFFF 48.2%, #7FE6FF 58.8%, #2BB4FF 76.5%, #2A45D0 100%);
}
.field input.wb-range, .field input.wb-range:focus { padding: 0; border-radius: 0; background: transparent; box-shadow: none; }

/* ── Resizable: the editor fills any window, from desktop to phone */
html, body { overflow: hidden; overscroll-behavior: none; }
.app { width: 100vw; height: 100dvh; min-width: 0; }
.topbar { min-width: 0; }
.title { min-width: 0; flex: 1 1 auto; text-overflow: ellipsis; }
.toolbar { max-width: calc(100% - 24px); }
.tb-pop { max-width: calc(100vw - 24px); }
.inspector { max-width: calc(100% - 32px); }
.notice { max-width: calc(100% - 24px); }

@media (width <= 860px) {
  .tb-btn.labelled span { display: none; }
  .tb-btn.labelled { padding: 0 8px; }
  .hint { max-width: calc(100% - 32px); bottom: 76px; }
}

/* tablets: the inspector keeps to the right edge but never covers the toolbar */
@media (width <= 1024px) and (width > 640px) {
  .inspector { width: 300px; }
}

/* phones: compact header, scrolling toolbar, inspector as a bottom sheet */
@media (width <= 640px) {
  .app { grid-template: "top" 68px "canvas" 1fr / 1fr; }
  .topbar { width: calc(100% - 32px); min-height: 56px; padding: 6px 6px 6px 14px; gap: 8px; }
  .wordmark { font-size: 24px; }
  .topbar .actions { gap: 6px; }
  .topbar .actions .primary { padding: 0 16px; font-size: 14px; }
  .tag { display: none; }
  .title { font-size: 14px; padding: 5px 8px; }
  .actions { gap: 6px; }
  .title { display: none; }
  .topbar .brand { margin-right: auto; }
  .toolbar { top: 80px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 16px); justify-content: center; }
  .tb-pop { position: fixed; top: 136px; left: 8px; right: 8px; width: auto; transform: none; animation: none; }
  .tb-pop-grid { grid-template-columns: 1fr 1fr; }
  .canvas .excalidraw .layer-ui__wrapper { top: 132px; height: calc(100% - 132px); }
  .inspector {
    top: auto; right: 8px; left: 8px; bottom: 76px; width: auto; max-width: none;
    max-height: min(52dvh, calc(100dvh - 220px)); border-radius: 24px; z-index: 7;
  }
  .scalebar { bottom: 72px; left: 12px; }
  .notice { bottom: 12px; border-radius: 18px; }
}
/* a tap on the plan must not land on the sheet that opens under the finger */
@keyframes phos-tapguard { from, to { pointer-events: none; } }
@media (width <= 640px) {
  .inspector { animation: rise .22s var(--ease-out), phos-tapguard .4s; }
}

/* ── Mobile pass (v0.09) */
.tb-more { display: none; }
.tb-more .tb-pop { width: 240px; left: auto; right: 0; transform: none; }
.tb-more .tb-pop .tb-pop-head + .tb-pop-grid + .tb-pop-head { margin-top: 4px; border-top: 1px solid rgba(255,255,255,0.07); }

/* the editor's own phone controls that duplicate ours */
.canvas .excalidraw .App-top-bar,
.canvas .excalidraw .App-toolbar--mobile,
.canvas .excalidraw .ToolIcon__lock,
.canvas .excalidraw .App-bottom-bar button[aria-label="Edit"],
.canvas .excalidraw .App-bottom-bar button[aria-label="Duplicate"],
.canvas .excalidraw .App-bottom-bar button[aria-label="Delete"] { display: none !important; }

/* selection bar: actions one tap away on touch screens */
.sel-bar {
  position: absolute; left: 0; top: 0; z-index: 6; display: flex; align-items: center; gap: 2px; padding: 4px;
  border-radius: 16px; opacity: 0; pointer-events: none;
  background: var(--glass-fill), rgba(10,10,11,0.86);
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(170%); backdrop-filter: blur(var(--blur-glass)) saturate(170%);
  box-shadow: var(--shadow-glass);
  transition: opacity .16s var(--ease-out);
}
.sel-bar.on { opacity: 1; pointer-events: auto; }
.sel-btn { width: 44px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: #fff; display: grid; place-items: center; padding: 0; }
.sel-btn[hidden] { display: none; }
.sel-btn svg { width: 20px; height: 20px; }
.sel-btn:active { background: rgba(255,255,255,0.10); }
.sel-btn.lit { color: #FF5A1F; }
.sel-btn.danger { color: #ff8a6a; }
.sel-sep { width: 1px; height: 22px; margin: 0 4px; background: rgba(255,255,255,0.10); }
@media (prefers-reduced-motion: reduce) { .sel-bar { transition: none; } }

@media (width <= 640px) {
  .tb-tail { display: none !important; }
  .tb-more { display: block; }
  .tb-btn { min-width: 40px; height: 40px; }
  .tb-more .tb-pop { position: fixed; left: 8px; right: 8px; width: auto; }
  .context-menu-item { min-height: 40px; }
}

/* phones held sideways: header, tools and inspector move to the edges so the plan keeps the middle */
@media (max-height: 520px) and (orientation: landscape) {
  .app { grid-template: "top" 56px "canvas" 1fr / 1fr; }
  .topbar { width: calc(100% - 16px); margin-top: 6px; min-height: 50px; padding: 3px 3px 3px 14px; }
  .wordmark { font-size: 22px; }
  .brand svg { width: 22px; height: 22px; }
  .tag { display: none; }
  .toolbar { top: 64px; left: 8px; transform: none; flex-direction: column; align-items: stretch; max-height: calc(100% - 128px); overflow-y: auto; overflow-x: visible; scrollbar-width: none; padding: 4px; border-radius: 16px; }
  .toolbar::-webkit-scrollbar { display: none; }
  .toolbar .tb-group { flex-direction: column; }
  .toolbar .tb-sep { width: 22px; height: 1px; margin: 4px auto; }
  .tb-btn.labelled span { display: none; }
  .tb-btn.labelled { padding: 0 8px; }
  .tb-tail { display: none !important; }
  .tb-more { display: block; }
  .tb-pop, .tb-more .tb-pop { position: fixed; top: 60px; left: 68px; right: auto; width: 280px; max-height: calc(100dvh - 72px); overflow-y: auto; transform: none; animation: none; }
  .canvas .excalidraw .layer-ui__wrapper { top: 56px; height: calc(100% - 56px); }
  .inspector { top: 60px; right: 8px; left: auto; bottom: 8px; width: 290px; max-height: none; }
  .scalebar { left: 72px; bottom: 60px; }
  .hint { bottom: 12px; max-width: calc(100% - 180px); }
}
@media (width <= 640px) {
  .toolbar { gap: 1px; padding: 4px; }
  .tb-group { gap: 1px; }
  .tb-btn, .tb-btn.labelled { min-width: 38px; padding: 0 6px; }
  .toolbar .tb-sep { margin: 0 3px; }
}
/* phone inspector: a peek sheet that opens on tap (or "Details" in the selection bar) */
@media (width <= 640px) {
  .inspector { padding-top: 18px; transition: max-height .28s var(--ease-sheet); }
  .inspector::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 4px; background: rgba(255,255,255,0.22); }
  .inspector:not(.open) { max-height: 74px; overflow: hidden; }
  .inspector:not(.open) .insp-head { cursor: pointer; }
  .inspector .insp-head { margin-bottom: 12px; }
}
@media (width > 640px) { .sel-btn[data-k=more] { display: none; } }
.tb-item svg { width: 20px; height: 20px; flex: none; }
@media (width <= 640px) {
  .toolbar { left: 8px; right: 8px; transform: none; max-width: none; }
  .inspector:not(.open) { max-height: 70px; }
  .inspector:not(.open) .insp-head { margin-bottom: 40px; }
  .canvas:has(.inspector) .scalebar { opacity: 0; }
}
.toolbar { z-index: 8; }
.canvas:has(.tb-pop) .sel-bar, .canvas:has(.place-layer) .sel-bar { opacity: 0; pointer-events: none; }
@media (max-height: 520px) and (orientation: landscape) {
  .inspector { bottom: 64px; }
  .toolbar .tb-btn { height: 36px; min-width: 36px; }
  .canvas:has(.inspector) .sel-bar { max-width: calc(100% - 320px); }
}

/* ── Pen sizes (v0.11) */
.pen-sizes { display: flex; flex-wrap: wrap; gap: 4px; }
.pen-size {
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: 12px; display: grid; place-items: center;
  background: var(--glass-field); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.09); color: #fff; cursor: pointer;
  transition: background-color .16s var(--ease-out), box-shadow .16s var(--ease-out), transform .16s var(--ease-out);
}
.pen-size i { display: block; border-radius: 50%; background: currentColor; }
.pen-size:active { transform: scale(0.97); }
.pen-size.on { background: var(--key-wash); box-shadow: var(--shadow-lit); }
.pen-size:focus-visible { outline: 0; box-shadow: var(--shadow-focus); }
@media (hover: hover) and (pointer: fine) { .pen-size:not(.on):hover { background: rgba(255,255,255,0.08); } }
.pen-bar {
  position: absolute; top: 142px; left: 50%; transform: translateX(-50%); z-index: 7;
  display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 18px;
  background: var(--glass-fill), rgba(10,10,11,0.86);
  -webkit-backdrop-filter: blur(var(--blur-glass)) saturate(170%); backdrop-filter: blur(var(--blur-glass)) saturate(170%);
  box-shadow: var(--shadow-glass); animation: rise .22s var(--ease-out);
}
.pen-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-subtle); }
.pen-bar .pen-sizes { flex-wrap: nowrap; }
@media (width <= 640px) {
  .pen-bar { top: 136px; left: 8px; right: 8px; transform: none; justify-content: space-between; padding-left: 12px; }
  .pen-bar .pen-size { width: 34px; height: 40px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .pen-bar { top: auto; bottom: 64px; }
}
.inspector .pen-sizes { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.inspector .pen-size { width: auto; height: 34px; border-radius: 10px; }

/* ── Subject colours (v0.12) */
.sub-colors { display: flex; flex-wrap: wrap; gap: 8px; }
.sub-color {
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; position: relative;
  background: transparent; box-shadow: inset 0 0 0 4px var(--c); transition: transform .16s var(--ease-out), box-shadow .16s var(--ease-out);
}
.sub-color:active { transform: scale(0.94); }
.sub-color.on { box-shadow: inset 0 0 0 4px var(--c), 0 0 0 2px #0A0A0B, 0 0 0 3.5px rgba(255,255,255,0.85); }
.sub-color:focus-visible { outline: 0; box-shadow: inset 0 0 0 4px var(--c), var(--shadow-focus); }
@media (pointer: coarse) { .sub-color { width: 36px; height: 36px; } }
.inspector .sub-colors { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; justify-items: center; }

/* ── Pen bar hides when idle; the pen button brings it back (v0.15) */
.pen-bar { transition: opacity .2s var(--ease-out), translate .2s var(--ease-out); }
.pen-bar.min { opacity: 0; translate: 0 -6px; pointer-events: none; visibility: hidden; transition: opacity .2s var(--ease-out), translate .2s var(--ease-out), visibility 0s .2s; }
@media (prefers-reduced-motion: reduce) { .pen-bar { transition: none; } .pen-bar.min { translate: none; } }
