/* The iPad workbench's colours and proportions (ipad/CADictate/WorkbenchStyle.swift). */
:root {
  --canvas: #0e131c;
  --chrome: #11161d;
  --panel: #151b24;
  --tile: #1c222c;
  --line: #293342;
  --primary: #ebf2fa;
  --secondary: #a1b3c7;
  --accent: #75d4f5;
  --relation: #5ccc75;
  --free: #ffd638;
  --selected: #ffb84d;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--chrome); color: var(--primary); font: 14px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; overflow: hidden; -webkit-font-smoothing: antialiased; user-select: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: .35; cursor: default; }
input { font: inherit; color: var(--primary); }

#workbench { display: flex; flex-direction: column; height: 100%; }
main { flex: 1; display: flex; min-height: 0; }

/* Header */
#header { display: flex; align-items: center; gap: 8px; min-height: 58px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.logo { display: block; flex: none; width: 26px; height: 26px; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--accent); }
.brand b { display: block; color: var(--primary); font: 700 16px ui-rounded, -apple-system, system-ui, sans-serif; }
.brand small { display: block; color: var(--secondary); font-size: 11px; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grow { flex: 1; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; }
.icon-btn:hover:not(:disabled) { background: var(--tile); }
.bench { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 13px; background: var(--tile); border: 1px solid var(--line); border-radius: 9px; font-weight: 600; font-size: 14px; }
.bench:hover:not(:disabled) { border-color: var(--secondary); }
.bench.primary { background: var(--accent); color: var(--canvas); border-color: transparent; }
.bench.primary:hover:not(:disabled) { filter: brightness(1.08); }
.bench.wide { width: 100%; }
.bench.danger { color: #ff8a8a; }

#brand, #header-tools { display: flex; align-items: center; gap: 8px; }
#brand { color: var(--accent); }
#voice-bar { display: flex; align-items: center; gap: 8px; margin-left: 18px; padding: 0 12px; height: 36px; width: min(380px, 30vw); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; color: var(--accent); }
#voice-bar:focus-within { border-color: var(--accent); }
#voice-bar input { flex: 1; min-width: 0; background: none; border: 0; outline: none; font-size: 13px; user-select: text; }
#voice-bar input::placeholder { color: var(--secondary); }
.voice-icon { display: grid; }

/* Menus */
.menu-wrap { position: relative; }
.menu { position: absolute; top: 44px; right: 0; z-index: 30; min-width: 212px; padding: 5px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 34px rgba(0,0,0,.5); }
.menu button { display: flex; gap: 10px; align-items: center; width: 100%; padding: 9px 10px; border-radius: 6px; text-align: left; white-space: nowrap; }
.menu button:hover:not(:disabled) { background: var(--tile); }
.menu button.danger { color: #ff8a8a; }

/* Panels */
.panel { width: 232px; flex: none; background: var(--panel); overflow-y: auto; padding: 10px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
#left { border-right: 1px solid var(--line); }
#right { border-left: 1px solid var(--line); width: 244px; padding: 14px; }
.caption { font: 600 11px var(--mono); letter-spacing: 1.7px; color: var(--secondary); padding: 4px; display: flex; align-items: center; gap: 8px; }
.caption .count { letter-spacing: 0; font-weight: 400; }
.caption .icon-btn { margin-left: auto; width: 28px; height: 28px; color: var(--secondary); }
.muted { color: var(--secondary); font-size: 12px; line-height: 1.4; }
.hr { height: 1px; background: var(--line); margin: 8px 0; }
h3 { font-size: 16px; font-weight: 600; margin: 4px 0 2px; }

.rail-exit { width: 100%; min-height: 40px; display: flex; align-items: center; justify-content: center; gap: 7px; background: var(--tile); border: 1px solid var(--line); border-radius: 8px; font-weight: 600; }
.rail-over { width: 100%; min-height: 32px; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--secondary); font-size: 12px; font-weight: 500; }
.sketch-id { padding: 8px 4px; }
.sketch-id b { display: block; font-weight: 500; }
.sketch-id small { font: 11px var(--mono); color: var(--secondary); }
.badge { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; margin-top: 3px; }
.badge.defined { color: var(--relation); }
.badge.free { color: var(--free); }

.tool { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 38px; padding: 0 9px; border-radius: 8px; font-weight: 500; }
.tool:hover { background: var(--tile); }
.tool.on { background: var(--accent); color: var(--canvas); }
.tool kbd { margin-left: auto; font: 11px var(--mono); opacity: .55; text-transform: uppercase; }

.relations { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 4px 0; }
.relation { display: flex; align-items: center; gap: 5px; min-height: 36px; padding: 0 5px; background: var(--tile); border: 2px solid transparent; border-radius: 8px; font-size: 11px; font-weight: 500; white-space: nowrap; overflow: hidden; }
.relation i { width: 18px; height: 18px; flex: none; display: grid; place-items: center; background: var(--relation); color: var(--canvas); border-radius: 5px; font: 700 11px -apple-system, system-ui, sans-serif; }
.relation.on { background: var(--accent); color: var(--canvas); }
.relation.fits { border-color: var(--relation); }
.relation.dim { opacity: .45; }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 4px; font-size: 12px; font-weight: 500; cursor: pointer; }
.toggle input { accent-color: var(--accent); }

.shape { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px; padding-left: 6px; border-radius: 8px; }
.shape.on { background: var(--tile); }
.shape > button:first-child { flex: 1; display: flex; align-items: center; gap: 9px; min-height: 36px; text-align: left; min-width: 0; }
.shape small { display: block; font: 11px var(--mono); color: var(--secondary); }
.shape span { font-size: 12px; font-weight: 500; }
.shape .icon-btn { width: 28px; height: 28px; color: var(--secondary); }

.rows { padding: 11px; background: var(--chrome); border-radius: 8px; margin: 10px 0; display: grid; gap: 9px; font-size: 12px; }
.row { display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.row span:first-child { color: var(--secondary); }
.row button { font: 12px var(--mono); color: var(--accent); }
.stack { display: grid; gap: 7px; margin-top: 10px; }
/* Where a picked size's number came from (shared/sketchsizes.js), under its name. */
.size-source { margin: 2px 0 8px; font-size: 12px; line-height: 1.4; color: var(--secondary); }
.tie { display: flex; align-items: center; gap: 7px; font-size: 12px; min-height: 28px; }
.tie i { width: 18px; height: 18px; display: grid; place-items: center; background: var(--relation); color: var(--canvas); border-radius: 5px; font: 700 11px -apple-system, system-ui, sans-serif; }
.tie .icon-btn { margin-left: auto; width: 24px; height: 24px; color: var(--secondary); }

.feature { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 2px 7px; border-radius: 8px; width: 100%; text-align: left; }
.feature:hover { background: var(--tile); }
.feature.on { background: var(--tile); box-shadow: inset 0 0 0 1px var(--selected); }
.feature b { display: block; font-size: 13px; font-weight: 500; }
.feature small { display: block; font: 11px var(--mono); color: var(--secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }
.feature .ok { color: var(--relation); margin-left: auto; }
.feature .warn { color: var(--free); margin-left: auto; }
.feature .bad { color: #ff8a8a; margin-left: auto; }

/* Stage */
#stage { position: relative; flex: 1; min-width: 0; background: var(--canvas); touch-action: none; }
#stage canvas#model, #stage canvas#overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#stage canvas#overlay { cursor: default; }
#stage-ui { position: absolute; inset: 0; pointer-events: none; }
#stage-ui > * { pointer-events: auto; }
.space { position: absolute; left: 14px; top: 14px; pointer-events: none !important; font: 12px var(--mono); color: var(--secondary); }
.space .caption { padding: 0; margin-bottom: 5px; }
.nav { position: absolute; right: 14px; top: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#gizmo { display: block; cursor: grab; }
.seg { display: flex; gap: 1px; padding: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.seg button { min-width: 48px; height: 36px; border-radius: 8px; font-weight: 600; font-size: 13px; }
.seg button:hover:not(.on):not(:disabled) { background: var(--tile); }
.seg button.on { background: var(--accent); color: var(--canvas); }
.corner { position: absolute; bottom: 14px; }
.corner.left { left: 14px; }
.corner.right { right: 14px; }
.corner .seg button { min-width: 40px; height: 40px; display: grid; place-items: center; }

.prompt { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 9px 14px; background: rgba(17,22,29,.95); border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 500; white-space: nowrap; }
.planes { position: absolute; top: 58px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }
.plane { display: flex; align-items: center; gap: 7px; padding: 0 12px; height: 40px; background: var(--panel); border: 1px solid var(--plane); border-radius: 10px; font-weight: 600; }
.plane i { width: 10px; height: 10px; border-radius: 50%; background: var(--plane); }
.pill { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); padding: 7px 13px; background: rgba(17,22,29,.95); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; pointer-events: none !important; }
.pill.defined { border-color: rgba(92,204,117,.6); color: var(--relation); }
.pill.free { border-color: rgba(255,214,56,.6); color: var(--free); }
/* The sizes' sources after the definition, while the stage is wide enough to clear its corner buttons. */
#stage-ui { container-type: inline-size; }
@container (max-width: 640px) { .pill-more { display: none; } }
.pill.depth { border-color: var(--accent); color: var(--accent); font-family: var(--mono); }

.empty { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 21px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--accent); max-width: 420px; }
.empty h2 { margin: 0; font-size: 22px; font-weight: 600; color: var(--primary); }
.empty p { margin: 0; color: var(--secondary); }
.empty div { display: flex; gap: 8px; margin-top: 6px; color: var(--primary); }

.seg.wide { display: flex; }
.seg.wide button { flex: 1; min-width: 0; }
.nav .seg.small button { min-width: 40px; height: 36px; display: grid; place-items: center; }
.display-menu { position: absolute; top: 236px; right: 14px; width: 190px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; display: grid; gap: 2px; z-index: 12; }
.display-menu button { padding: 8px 10px; border-radius: 6px; text-align: left; font-size: 13px; }
.display-menu button:hover { background: var(--tile); }
.display-menu button.on { background: var(--accent); color: var(--canvas); }
.nav .seg.small .grid-chip { min-width: 0; width: auto; padding: 0 10px; font: 500 11px var(--mono); display: block; }
.grid-menu { max-height: calc(100% - 300px); overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.grid-menu .caption { padding: 6px 10px 2px; }
.talk { position: absolute; left: 14px; bottom: 72px; width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); color: var(--accent); touch-action: none; }
.talk:hover { border-color: var(--accent); }
.talk.on { background: var(--accent); color: var(--canvas); box-shadow: 0 0 0 7px rgba(117,212,245,.22); }

/* Body tools */
.body-name { padding: 0 4px 6px; font-weight: 600; color: var(--primary); font-size: 13px; }
.solid-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 2px 4px; }
.solid-grid button { display: grid; justify-items: center; gap: 4px; padding: 9px 3px; background: var(--tile); border-radius: 8px; font-size: 11px; font-weight: 500; }
.solid-grid button:hover { outline: 1px solid var(--secondary); }
.solid-grid button.on { background: var(--accent); color: var(--canvas); }
.solid-panel { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: min(430px, calc(100% - 300px)); min-width: 320px; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 10px; z-index: 11; }
.solid-head { display: flex; align-items: center; gap: 8px; }
.solid-head b { font-size: 16px; }
.solid-head .grow { flex: 1; }
.solid-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 32px; height: 30px; background: var(--tile); border-radius: 7px; font-size: 16px; }
.stepper input { width: 62px; height: 30px; padding: 0 6px; background: var(--chrome); border: 1px solid var(--line); border-radius: 6px; font: 13px var(--mono); text-align: right; outline: none; user-select: text; }
.stepper em { font: 11px var(--mono); color: var(--secondary); font-style: normal; min-width: 16px; }
.problem { margin: 0; color: #ff8a8a; font-size: 13px; line-height: 1.35; }
.problem:empty { display: none; }
.solid-panel .muted { margin: 0; }

/* Asking for a value */
.ask { position: absolute; z-index: 20; display: flex; align-items: center; gap: 7px; padding: 7px 9px; background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
.ask label { font-size: 11px; color: var(--secondary); font-weight: 600; }
.ask input { width: 88px; padding: 5px 7px; background: var(--chrome); border: 1px solid var(--line); border-radius: 6px; font: 13px var(--mono); outline: none; user-select: text; }
.ask span { font: 11px var(--mono); color: var(--secondary); }
.ask-switch { display: inline-flex; gap: 2px; }
.ask-switch button { padding: 3px 6px; font-size: 11px; font-weight: 600; background: var(--chrome); border: 1px solid var(--line); border-radius: 6px; color: var(--primary); }
.angle-offer { flex-direction: column; align-items: stretch; gap: 6px; width: 286px; padding: 8px 12px; border-color: var(--line); }
.angle-head, .angle-row { display: flex; align-items: center; gap: 10px; }
.angle-head span, .angle-row span { flex: 1; font: 13px -apple-system, system-ui, sans-serif; color: var(--primary); }
.angle-head span { font-weight: 600; }
.angle-mark { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; background: var(--relation); color: var(--canvas); font-size: 13px; }
.angle-free { padding: 4px 6px; background: none; border: 0; color: var(--accent); font-size: 13px; }
.angle-row .bench { min-height: 28px; padding: 0 12px; font-size: 13px; }
.ask-switch button.on { background: var(--accent); color: var(--canvas); border-color: var(--accent); }

/* Dialogs */
.modal-back { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0,0,0,.45); }
.modal { width: 380px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; display: grid; gap: 12px; }
.modal h2 { margin: 0; font-size: 17px; }
.modal p { margin: 0; color: var(--secondary); line-height: 1.45; }
.modal input { padding: 8px 10px; background: var(--chrome); border: 1px solid var(--line); border-radius: 7px; outline: none; user-select: text; }
.modal .buttons { display: flex; gap: 8px; justify-content: flex-end; }
/* Export STL, as the iPad's sheet: the bodies to tick, then one file or a file each. */
.modal:has(.stl-list) { width: 460px; }
.stl-head { display: flex; justify-content: space-between; align-items: center; color: var(--secondary); font-size: 13px; }
.stl-all { background: none; border: 0; color: var(--accent); font-size: 13px; cursor: pointer; }
.stl-list { display: grid; max-height: 46vh; overflow-y: auto; background: var(--chrome); border: 1px solid var(--line); border-radius: 10px; }
.stl-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.stl-row:last-child { border-bottom: 0; }
.stl-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.modal .stl-note { font-size: 12px; }
.modal .buttons button:disabled { opacity: .45; }
.modal dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.modal dt { color: var(--accent); font: 12px var(--mono); }
.modal dd { margin: 0; color: var(--secondary); }

#toasts { position: fixed; bottom: 42px; left: 50%; transform: translateX(-50%); z-index: 50; display: grid; gap: 6px; pointer-events: none; }
.toast { padding: 9px 15px; background: var(--panel); border: 1px solid var(--free); border-radius: 12px; font-size: 13px; max-width: 460px; text-align: center; }
.toast.info { border-color: var(--accent); }

#footer { display: flex; align-items: center; gap: 8px; min-height: 29px; padding: 0 14px; border-top: 1px solid var(--line); font: 11px var(--mono); color: var(--secondary); }
#footer i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
#footer .hint { margin-left: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1000px) { body:not(.sketching) #left { display: none; } }
@media (max-width: 690px) { #right { display: none; } }
