/* RayMan. A full-bleed bench with a slim tool rail docked on the right. Light by default;
   the dark palette follows the optics.mouse.vision demos. */

:root {
  --bg: #fafbfc;
  --surface: #ffffff;
  --glass: rgba(255, 255, 255, 0.9);
  --text: #1c2230;
  --soft: #3d4555;
  --dim: #6b7487;
  --faint: #9aa2b2;
  --line: rgba(20, 30, 60, 0.09);
  --line-strong: rgba(20, 30, 60, 0.18);
  --field: rgba(20, 30, 60, 0.04);
  --hover: rgba(20, 30, 60, 0.06);
  --accent: #e0782a;
  --accent-soft: rgba(224, 120, 42, 0.13);
  --accent-ink: #b85c16;
  --danger: #cf3a3f;
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.06), 0 10px 30px rgba(20, 30, 60, 0.10);
  --shadow-lg: 0 2px 6px rgba(20, 30, 60, 0.06), 0 22px 60px rgba(20, 30, 60, 0.16);
  --tip-bg: #1c2230;
  --tip-text: #f2f4f8;
  --rail: 50px;                 /* a palette's width: 38 px buttons + padding + border */
  --edge: 10px;                 /* gap between a palette and the window edge */
  --beside: calc(var(--rail) + 2 * var(--edge));   /* where things next to a palette start */
  --radius: 12px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #060913;
  --surface: #0c1122;
  --glass: rgba(14, 20, 40, 0.88);
  --text: #e6ebf7;
  --soft: #c3cbdc;
  --dim: #8f9bb8;
  --faint: #5f6a85;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.17);
  --field: rgba(255, 255, 255, 0.05);
  --hover: rgba(255, 255, 255, 0.07);
  --accent: #ffb454;
  --accent-soft: rgba(255, 180, 84, 0.15);
  --accent-ink: #ffc477;
  --danger: #ff6b6f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 34px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, 0.3), 0 24px 64px rgba(0, 0, 0, 0.55);
  --tip-bg: #e6ebf7;
  --tip-text: #0c1122;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;   /* no text selection under fingers */
  -webkit-tap-highlight-color: transparent;
  background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
#app { display: flex; height: 100%; }

input, textarea { -webkit-user-select: text; user-select: text; }
button {
  touch-action: manipulation;                      /* no double-tap zoom on buttons */
  font: inherit; color: inherit; cursor: pointer;
  background: none; border: 0; padding: 0;
}
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.3; cursor: default; }
svg { fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
svg .fill { fill: currentColor; stroke: none; }
svg .faint { opacity: 0.4; }
svg .knob { fill: var(--surface); }
kbd {
  font: 500 11px/1 ui-monospace, "SF Mono", Menlo, monospace; color: var(--dim);
  padding: 3px 5px; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--field);
}

/* ------------------------------------------------------------ the rail */

/* two floating palettes, only as tall as their buttons, over a full-width bench */
.rail {
  position: fixed; top: var(--edge); z-index: 8;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: 5px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 13px;
  box-shadow: var(--shadow); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  transition: transform .2s ease, box-shadow .2s ease;
}
#tools { left: var(--edge); }
#rail { right: var(--edge); }
.rail .group { display: flex; flex-direction: column; gap: 0; }
.rail .sep { width: 24px; height: 1px; background: var(--line-strong); margin: 5px 0; }

.rail button {
  position: relative; width: 38px; height: 38px; border-radius: 9px;
  display: grid; place-items: center; color: var(--soft);
  transition: background .12s, color .12s;
}
.rail button svg { width: 21px; height: 21px; }
.rail button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.rail button.on { background: var(--accent-soft); color: var(--accent-ink); }

/* a tool with options: a small triangle in the corner opens its flyout (Photoshop-style) */
.rail .corner {
  position: absolute; right: 0; bottom: 0; width: 15px; height: 15px; border-radius: 0 0 10px 0;
  --rc: var(--faint);
}
.rail .corner::after {
  content: ""; position: absolute; right: 4px; bottom: 4px;
  border-left: 6px solid transparent; border-bottom: 6px solid var(--rc);
}
.rail .corner:hover::after { border-bottom-color: var(--accent); }

/* the Ray tool's kind, small in its bottom-left corner: R (ray) or H (helper ray) */
.rail .kind {
  position: absolute; left: 4px; bottom: 2px; font-size: 9px; font-weight: 700; line-height: 1;
  color: var(--dim); pointer-events: none;
}
.rail button.on .kind { color: var(--accent-ink); }

/* tooltips, to the left of the rail: "Thin lens  L" */
.rail button[data-tip]::after {
  content: attr(data-tip); position: absolute; right: calc(100% + 12px); top: 50%;
  transform: translate(4px, -50%); white-space: nowrap; pointer-events: none;
  font-size: 12.5px; font-weight: 550; padding: 5px 9px; border-radius: 7px;
  background: var(--tip-bg); color: var(--tip-text); opacity: 0; transition: opacity .12s, transform .12s;
}
.rail button[data-key]::after { content: attr(data-tip) "\2003" attr(data-key); }
.rail button:hover::after { opacity: 1; transform: translate(0, -50%); transition-delay: .35s; }
#tools button[data-tip]::after { right: auto; left: calc(100% + 12px); transform: translate(-4px, -50%); }
#tools button:hover::after { transform: translate(0, -50%); }
/* the Ray tool's tooltip names its two kinds, one above the other */
#tools button[data-tool=ray]::after { white-space: pre; text-align: left; line-height: 1.55; }

/* ------------------------------------------------------------ the stage */

#stage { flex: 1; position: relative; min-width: 0; order: 1; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#brand {
  position: absolute; left: calc(var(--beside) + 6px); top: 16px; z-index: 1; pointer-events: none;
  display: flex; align-items: baseline; gap: 10px;
}
#brand b { font-size: 16px; font-weight: 680; letter-spacing: -0.01em; }
#brand span { font: italic 14px Georgia, "Times New Roman", serif; color: var(--dim); }


#toast {
  position: absolute; left: 50%; top: 18px; transform: translateX(-50%); z-index: 6;
  background: var(--tip-bg); color: var(--tip-text); border-radius: 9px;
  padding: 8px 14px; font-size: 13px; box-shadow: var(--shadow-lg);
}
#toast.bad { background: var(--danger); color: #fff; }

/* ------------------------------------------------------------ panels */

.panel {
  position: absolute; z-index: 4;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.panel h2 { font-size: 11.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); margin: 0; }
.ph { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ph b { font-size: 11.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--dim); }
.close, .icon-btn {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  font-size: 18px; line-height: 1; color: var(--dim);
}
.close:hover, .icon-btn:hover { background: var(--hover); color: var(--text); }

/* properties of the selection */
#props { top: var(--edge); right: var(--beside); width: 272px; padding: 12px 14px 14px; }
#props .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 9px 0; }
#props .row > span:first-child { color: var(--soft); font-size: 13px; }
#props .num { display: flex; align-items: center; gap: 6px; }
#props .num i { font-style: normal; color: var(--faint); font-size: 12px; width: 22px; }
#props input[type=number], #props input[type=text] {
  width: 84px; font: inherit; font-size: 13.5px; font-variant-numeric: tabular-nums; color: var(--text);
  background: var(--field); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px;
  transition: border-color .12s, background .12s;
}
#props input[type=text] { width: 118px; }
#props input:hover { border-color: var(--line-strong); }
#props input:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
#props input.bad { border-color: var(--danger); }
#props .check { justify-content: flex-start; cursor: pointer; gap: 9px; }
#props .check span { color: var(--soft) !important; }
#props input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
/* a quiet slider: thin track filled up to the thumb (--p is set from JS) */
#props .slider { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; margin: 0 0 4px; background: transparent; cursor: pointer; --p: 0%; }
#props .slider::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--p), var(--line-strong) var(--p));
}
#props .slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}
#props .slider::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-strong); }
#props .slider::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
#props .slider::-moz-range-thumb {
  width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent);
}
#props .slider:focus-visible { outline: none; }
#props .slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px var(--accent-soft); }
#props .sign {
  width: 26px; height: 27px; border-radius: 7px; font-weight: 700; color: var(--soft);
  background: var(--field); border: 1px solid var(--line);
}
#props .sign:hover { border-color: var(--line-strong); color: var(--text); }
#props .hint { color: var(--dim); font-size: 12.5px; margin: 12px 0 10px; line-height: 1.4; }
#props .hint:empty { display: none; }
#props .wide {
  width: 100%; height: 32px; margin-top: 6px; border-radius: 8px; font-size: 13px; font-weight: 550;
  color: var(--soft); background: var(--field); border: 1px solid var(--line);
}
#props .wide:hover:not(:disabled) { border-color: var(--line-strong); color: var(--text); }
#props .danger { color: var(--danger); }
#props .scan.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
#props .danger:hover { background: rgba(207, 58, 63, 0.08); border-color: rgba(207, 58, 63, 0.3); color: var(--danger) !important; }

/* colour swatches */
.swatches { display: flex; align-items: center; gap: 5px; }
.sw { width: 19px; height: 19px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12); }
.sw.auto { box-shadow: inset 0 0 0 1.5px var(--line-strong); font-size: 9.5px; font-weight: 700; color: var(--dim); }
.sw.on { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatches input[type=color] {
  width: 21px; height: 21px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%;
}
.swatches input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
.swatches input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }

/* popovers opened from the bottom of the rail */
.popover { right: var(--beside); top: var(--edge); }
#menu { width: 220px; padding: 6px; }
#menu .item {
  width: 100%; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px;
  font-size: 13.5px; color: var(--text); text-align: left;
}
#menu .item:hover { background: var(--hover); }
#menu .item svg { width: 18px; height: 18px; color: var(--soft); flex: none; }
#menu .item kbd { margin-left: auto; }
#menu .rule { display: block; height: 1px; background: var(--line); margin: 5px 8px; }
#menu .item.danger, #menu .item.danger svg { color: var(--danger); }

/* a tool's flyout, beside its rail button (top is set from JS) */
.flyout { right: var(--beside); width: 268px; padding: 12px 14px 12px; z-index: 6; }
.flyout.left { right: auto; left: var(--beside); }
.flyout h2 { margin-bottom: 10px; }
.flyout h2 + .swatches, .flyout .kinds + h2 { margin-top: 0; }
.flyout .kinds { display: grid; gap: 4px; margin-bottom: 14px; }
.flyout .kinds button {
  display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 8px;
  font-size: 13.5px; color: var(--text); text-align: left; border: 1px solid transparent;
}
.flyout .kinds button:hover { background: var(--hover); }
.flyout .kinds button.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.flyout .kinds svg { width: 28px; height: 10px; stroke-width: 2; flex: none; }
.flyout .kinds kbd { margin-left: auto; }
.rail button.helper svg path:first-child { stroke-dasharray: 2.6 2.2; }
.swatches.big { gap: 7px; flex-wrap: wrap; }
.swatches.big .sw { width: 22px; height: 22px; }
.swatches.big input[type=color] { width: 24px; height: 24px; }
.flyout .dim { color: var(--dim); font-size: 12px; margin: 10px 0 0; }

/* a small confirmation dialog */
.modal {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 24px;
  background: rgba(20, 26, 40, 0.28); animation: fade .15s ease-out;
}
.dialog {
  width: min(360px, 100%); padding: 20px 22px 16px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-lg);
  animation: rise .2s cubic-bezier(.2, .8, .3, 1);
}
.dialog h3 { margin: 0 0 6px; font-size: 15.5px; font-weight: 650; }
.dialog p { margin: 0 0 18px; color: var(--dim); font-size: 13.5px; }
.dialog .buttons { display: flex; justify-content: flex-end; gap: 8px; }
.dialog .buttons button {
  height: 32px; padding: 0 16px; border-radius: 8px; font-weight: 550; font-size: 13.5px;
  background: var(--field); border: 1px solid var(--line); color: var(--soft);
}
.dialog .buttons button:hover { border-color: var(--line-strong); color: var(--text); }
.dialog .buttons .danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.dialog .buttons .danger:hover { filter: brightness(1.08); color: #fff; }
#settings { width: 290px; padding: 14px 16px; }

/* the object explorer */
#objects { width: 268px; padding: 12px 10px 10px 14px; max-height: calc(100vh - 2 * var(--edge)); overflow: auto; }
#objects .ph { margin-bottom: 6px; }
#objects h3 { margin: 10px 0 4px; font-size: 11.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--dim); }
#objects h3:first-child { margin-top: 0; }
#objects .orow { display: flex; align-items: center; gap: 8px; padding: 3px 4px 3px 2px; border-radius: 7px; font-size: 13.5px; }
#objects .orow:hover { background: var(--hover); }
#objects .orow.sel { background: var(--accent-soft); }
#objects .orow.off .nm { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line-strong); }
#objects .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; color: var(--text); }
#objects .orow.off .nm { cursor: default; }
#objects .orow small { color: var(--dim); font-size: 12px; white-space: nowrap; }
#objects .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
#objects .eye { width: 26px; height: 22px; display: grid; place-items: center; border-radius: 6px; color: var(--soft); flex: none; }
#objects .eye:hover { background: var(--hover); color: var(--text); }
#objects .eye svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
#objects .orow.off .eye { color: var(--faint); }
#objects .noeye { width: 26px; flex: none; }
#objects .all { font-size: 12.5px; color: var(--accent-ink); padding: 2px 4px; border-radius: 6px; margin: 2px 0 0 auto; display: block; }
#objects .all:hover { background: var(--hover); }
#objects .empty { color: var(--dim); font-size: 13px; margin: 4px 2px; }
#settings h2 { margin-bottom: 12px; }

/* an iOS-style switch */
.switch { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch i {
  flex: none; width: 34px; height: 20px; border-radius: 10px; background: var(--line-strong);
  position: relative; transition: background .15s; margin-top: 1px;
}
.switch i::after {
  content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform .15s;
}
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch span { font-size: 13.5px; font-weight: 550; }
.switch small { display: block; font-weight: 400; color: var(--dim); font-size: 12.5px; margin-top: 2px; }
.switch + .switch { margin-top: 14px; }
.legend b { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin: 0 4px 0 6px; }
.legend b:first-child { margin-left: 0; }
.legend .par { background: #1f6fd6; } .legend .foc { background: #d9422b; } .legend .cen { background: #2e9e3a; }
:root[data-theme="dark"] .legend .par { background: #5aa7ff; }
:root[data-theme="dark"] .legend .foc { background: #ff6b57; }
:root[data-theme="dark"] .legend .cen { background: #7ee06b; }

/* help */
#help { top: 50px; left: var(--beside); width: 420px; max-height: calc(100% - 110px); overflow: auto; padding: 16px 20px 18px; font-size: 13.5px; color: var(--soft); }
#help .ph { margin-bottom: 4px; }
#help p { margin: 6px 0 10px; }
#help b { color: var(--text); font-weight: 600; }
#help h3 { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); margin: 16px 0 8px; }
#help dl { display: grid; grid-template-columns: max-content 1fr; gap: 7px 14px; margin: 0; align-items: baseline; }
#help dt { white-space: nowrap; }
#help dd { margin: 0; }
#help .dim { color: var(--dim); font-size: 12.5px; }
/* small pictures in the help pane: a sentence's illustration, kept small so the text stays the point */
#help .help-pic { margin: 4px 0 12px; }
#help .help-pic img { display: block; width: 260px; max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); background: #fafbfc; }
#help .help-pic.wide img { width: 100%; }

#help .about-link { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
#help .about-link button { color: var(--accent-ink); font-weight: 600; font-size: 13px; }
#help .about-link button:hover { text-decoration: underline; }
#help .about-link { display: flex; align-items: center; gap: 12px; }
#help .gh { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; color: var(--soft); }
#help .gh svg { width: 17px; height: 17px; }
#help .gh:hover { background: var(--hover); color: var(--text); }
#help .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--soft); opacity: 0.5; flex: none; }
#help .install { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-ink); font-weight: 600; font-size: 13px; }
#help .install img { width: 20px; height: 20px; border-radius: 5px; }
#help .install:hover { text-decoration: underline; }
#help .ios-share { display: none; width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
html.ios #help .ios-share { display: inline-block; }

/* about: the logo on a white card, floating over a dimmed bench; any click closes it */
#about {
  position: fixed; inset: 0; z-index: 20; cursor: pointer;
  display: grid; place-items: center; padding: 24px;
  background: rgba(20, 26, 40, 0.28);
  animation: fade .18s ease-out;
}
#about figure {
  margin: 0; width: min(520px, 100%); padding: 22px 22px 20px; border-radius: 20px;
  background: #fff; text-align: center;
  box-shadow: 0 2px 4px rgba(10, 15, 30, 0.06), 0 18px 36px -8px rgba(10, 15, 30, 0.28), 0 44px 80px -24px rgba(10, 15, 30, 0.45);
  animation: rise .22s cubic-bezier(.2, .8, .3, 1);
}
#about img { display: block; width: 100%; aspect-ratio: 3 / 2; height: auto; border-radius: 10px; }
#about figcaption { margin-top: 14px; font-size: 12.5px; line-height: 1.65; color: #5b6475; }
#about figcaption i { color: #8a92a3; }
#about .site {
  display: inline-block; margin-top: 8px; color: #5b6475; text-decoration: none;
  border-bottom: 1px solid #d3d7df; padding-bottom: 1px; transition: border-color .15s, color .15s;
}
#about .site:hover { border-bottom-color: transparent; color: #1c2230; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.98); } }

@media (max-width: 760px) {
  #brand span { display: none; }
}

/* ------------------------------------------------------------ hints: the three rules */

:root { --ray-par: #1f6fd6; --ray-foc: #d9422b; --ray-cen: #2e9e3a; --g-axis: rgba(28, 34, 48, 0.5);
  --g-glass: rgba(150, 195, 240, 0.55); --g-edge: rgba(45, 95, 165, 0.85); }
:root[data-theme="dark"] { --ray-par: #5aa7ff; --ray-foc: #ff6b57; --ray-cen: #7ee06b; --g-axis: rgba(255, 255, 255, 0.5);
  --g-glass: rgba(110, 150, 230, 0.25); --g-edge: rgba(175, 205, 255, 0.85); }
#guide {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 1;
  display: flex; gap: 12px; pointer-events: none; opacity: 0.92;
}
#guide .rule {
  margin: 0; width: 180px; padding: 4px 6px 2px; border-radius: 12px;
  background: var(--glass); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
#guide svg { display: block; width: 100%; height: auto; stroke-linecap: round; stroke-linejoin: round; }
#guide .axis { stroke: var(--g-axis); stroke-width: 1.2; }
#guide .glass { fill: var(--g-glass); stroke: var(--g-edge); stroke-width: 1.2; }
#guide .plane { stroke: var(--g-edge); stroke-width: 0.7; opacity: 0.5; }
#guide .fpt { fill: var(--text); stroke: none; }
#guide text { fill: var(--text); stroke: none; font: italic 13px "Times New Roman", Times, Georgia, serif; text-anchor: middle; }
#guide .ray { fill: none; stroke-width: 2.2; }
#guide .head { stroke: none; }
#guide .ray.par { stroke: var(--ray-par); } #guide .head.par { fill: var(--ray-par); }
#guide .ray.foc { stroke: var(--ray-foc); } #guide .head.foc { fill: var(--ray-foc); }
#guide .ray.cen { stroke: var(--ray-cen); } #guide .head.cen { fill: var(--ray-cen); }
#guide figcaption { font-size: 12px; color: var(--dim); text-align: center; line-height: 1.35; }
#guide figcaption b { display: block; font-weight: 650; font-size: 12.5px; }
#guide b.par { color: var(--ray-par); } #guide b.foc { color: var(--ray-foc); } #guide b.cen { color: var(--ray-cen); }
@media (max-width: 1250px) { #guide .rule { width: 160px; } #guide { gap: 8px; } }
/* narrow screens (an iPad upright): still a row, below the name and between the two toolbars,
   the three rules shrinking to fit */
@media (max-width: 900px) {
  #guide { left: var(--beside); right: var(--beside); top: 46px; transform: none; justify-content: center; }
  #guide .rule { flex: 0 1 165px; min-width: 0; width: auto; }
}

/* segmented buttons (fill-in in the Ray flyout) */
.flyout h2.gap { margin-top: 14px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; height: 28px; font-size: 12.5px; color: var(--soft); border-left: 1px solid var(--line); }
.seg button:first-child { border-left: 0; }
.seg button:hover { background: var(--hover); }
.seg button.on { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }

/* auto-hide (desktop): the rails float over the bench, tucked off the edges until the mouse
   comes near (the "peek" class is set from JS) */
body.autohide #tools { transform: translateX(calc(-100% - var(--edge) - 4px)); }
body.autohide #rail { transform: translateX(calc(100% + var(--edge) + 4px)); }
body.autohide #tools.peek, body.autohide #rail.peek { transform: none; box-shadow: var(--shadow-lg); }

/* short screens: tighter rails */
@media (max-height: 640px) {
  .rail { padding: 4px; gap: 0; }
  .rail .group { gap: 0; }
  .rail .sep { margin: 4px 0; }
  .rail button { width: 36px; height: 34px; }
}

/* naming a ray: a small text box by it */
.raylabel {
  position: fixed; z-index: 15; width: 64px; height: 28px; padding: 0 8px; border-radius: 7px;
  border: 1px solid var(--accent); background: var(--surface); color: var(--text);
  font: italic 15px Georgia, "Times New Roman", serif; box-shadow: var(--shadow); outline: none;
}

/* the link to the illustrated guide, at the foot of the help */
.guide-link { margin: 16px 0 6px; }
.guide-link a { font-weight: 600; color: var(--accent-ink); text-decoration: none; }
.guide-link a:hover { text-decoration: underline; }
.guide-link .dim { font-size: 12.5px; }

/* features under development: hidden unless switched on in Settings */
body:not(.dev-on) .dev { display: none !important; }

/* touch devices: a slider for every number (the boxes are fiddly with a finger), with a bigger thumb */
body:not(.touch) #props .touch-only { display: none; }
body.touch #props .slider { height: 30px; margin-bottom: 6px; }
body.touch #props .slider::-webkit-slider-thumb { width: 26px; height: 26px; margin-top: -11px; }
body.touch #props .slider::-moz-range-thumb { width: 22px; height: 22px; }

/* Keyboard-only help is hidden on touch screens (iPad) */
@media (pointer: coarse) { .desk-only { display: none !important; } }
