/* Invention studio: generous controls, quiet chrome, and a real 3D object at center. */
:root { --studio-green: #83d8bf; --studio-ink: #1f3532; }
:root[data-theme="light"] {
  --bg: #eeefec; --panel: #fafbf8; --panel-2: #ffffff; --panel-3: #eef2ed;
  --border: #dce1d9; --text: #23332d; --text-dim: #54645b; --text-faint: #67776e;
  --accent: #267967; --accent-hover: #1e6656; --accent-text: #226e5c;
  --accent-soft: #e4f3ec; --accent-dim: #b8d9c8;
}
button { font-family: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#topbar { height: 64px; padding: 0 22px; background: var(--panel); border-bottom: 1px solid var(--border); }
.tb-brand { gap: 10px; align-items: center; }
.tb-mark { width: 34px; height: 34px; border-radius: 10px; color: var(--panel); background: var(--accent); border: none; }
.tb-mark .lucide { width: 21px; height: 21px; }
.tb-name { font-family: 'Space Grotesk', sans-serif; font-size: 20px; letter-spacing: -1px; }
.tb-sub { font-size: 10px; letter-spacing: 1.4px; }
.tb-robot { font-family: inherit; font-size: 13px; padding: 9px 14px; border-radius: 24px; }
.tb-btn { width: 36px; height: 36px; }
#starter-shelf { padding: 22px 14px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.shelf-heading { display: flex; justify-content: space-between; color: var(--text-dim); font-size: 12px; margin-bottom: 12px; font-weight: 600; }
.shelf-heading > span { opacity: .65; font-size: 10px; font-family: var(--mono); }
#starter-shelf button { display: flex; align-items: center; width: 100%; gap: 10px; padding: 12px 10px; margin-top: 5px; text-align: left; border: 1px solid transparent; border-radius: 12px; color: var(--text); background: transparent; }
#starter-shelf button:hover { background: var(--panel-3); }
#starter-shelf button.selected { background: var(--accent-soft); border-color: var(--accent-dim); }
#starter-shelf button > .lucide { width: 25px; height: 25px; color: var(--accent-text); stroke-width: 1.5; }
#starter-shelf b { display: block; font-size: 13px; font-weight: 600; }
#starter-shelf small { display: block; font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.starter-arrow { margin-left: auto; font-size: 18px; color: var(--text-dim); }
.panel-header { padding: 17px 16px 13px; gap: 10px; border: none; }
.panel-title { font-size: 15px; font-weight: 650; line-height: 1.4; }
.panel-kicker { font-size: 9px; letter-spacing: 1.3px; margin-bottom: 3px; }
.panel-icon { display: none; }
.panel-min { color: var(--text-faint); }
#clear-btn { margin: 0 14px 10px; width: calc(100% - 28px); min-height: 32px; font-size: 12px; border-radius: 7px; }
#tray-search, .tray-search { font-size: 13px; min-height: 35px; }
.part-card { min-height: 58px; padding: 9px 13px; border-bottom: 1px solid var(--border); }
.part-visual { width: 34px; height: 34px; border-radius: 9px; }
.part-card .part-name { font-size: 13px; }
.part-card .part-desc { font-size: 11px; line-height: 1.4; }
#left-panel > #checklist { max-height: 80px; }
#left-panel > .panel-header:has(+ #checklist) { padding: 10px 16px 4px; }
#left-panel > .panel-header:has(+ #checklist) .panel-kicker { display: none; }
#invention-heading { position: absolute; top: 28px; left: 30px; z-index: 3; pointer-events: none; color: #233932; }
.studio-eyebrow { display: flex; align-items: center; gap: 7px; font-size: 10px; font-weight: 600; letter-spacing: 1.6px; }
.studio-eyebrow span { width: 6px; height: 6px; background: #278770; border-radius: 50%; }
#invention-heading h1 { font-family: 'Space Grotesk', sans-serif; font-size: clamp(24px, 2.6vw, 38px); letter-spacing: -1.8px; margin: 8px 0 6px; line-height: 1.12; max-width: 380px; overflow-wrap: anywhere; }
#invention-heading p { font-size: 12px; color: #4b6359; }
#workspace::after { box-shadow: none; pointer-events: none; }
#examples-btn { top: 26px; right: 22px; padding: 9px 11px; font-size: 12px; border-radius: 9px; color: #233932; background: #fffffff0; border: 1px solid #d1d9ce; }
#examples-btn .lucide { color: #267967; }
#bench-tools { position: absolute; z-index: 4; right: 22px; top: 78px; display: flex; gap: 2px; padding: 4px; background: #ffffffed; border: 1px solid #d1d9ce; border-radius: 9px; }
#bench-tools button { width: 30px; height: 31px; color: #35483e; display: grid; place-items: center; background: transparent; border: none; border-radius: 5px; }
#bench-tools button:hover { background: #e4f3ec; }
#bench-tools > span { border-left: 1px solid #d1d9ce; margin: 5px 3px; }
#experiment { position: absolute; left: 50%; bottom: 52px; transform: translateX(-50%); width: min(360px, calc(100% - 48px)); z-index: 5; background: #fffffff5; border: 1px solid #dce3d9; border-radius: 17px; padding: 17px 20px 15px; box-shadow: 0 12px 35px #21393218; color: #233932; }
.experiment-top { display: flex; align-items: center; gap: 7px; }
.experiment-top b { font-size: 12px; font-weight: 600; }
.live-dot { width: 7px; height: 7px; background: #9baba4; border-radius: 50%; flex-shrink: 0; }
[data-live="true"] .live-dot { background: #269675; box-shadow: 0 0 0 3px #26967514; }
#experiment-current { margin-left: auto; font-size: 11px; font-family: var(--mono); color: #607469; }
.experiment-controls { display: flex; gap: 18px; align-items: center; margin-top: 15px; }
#experiment-switch { display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid #d0dbd2; color: #355044; background: #f0f4ef; border-radius: 9px; padding: 11px 13px; min-width: 77px; font-size: 13px; }
#experiment-switch[aria-pressed="true"] { background: #def4e9; color: #21785f; border-color: #a6d7bf; }
#power-control { flex: 1; display: flex; flex-direction: column; gap: 9px; }
#power-control > span { display: flex; justify-content: space-between; font-size: 9px; font-weight: 600; letter-spacing: 1.3px; }
#power-value { letter-spacing: 0; font-family: var(--mono); font-size: 11px; }
#invention-power { width: 100%; height: 15px; accent-color: #287d69; cursor: pointer; }
#experiment-tip { margin-top: 13px; font-size: 11px; color: #64766b; }
[hidden] { display: none !important; }
#workspace-hud { bottom: 16px; left: 50%; transform: translateX(-50%); padding: 0; max-width: none; background: transparent; border: none; box-shadow: none; color: #405b50; font-size: 11px; white-space: nowrap; }
#workspace-hud > .lucide { display: none; }
#controls-legend { display: none; }
#help-btn, #sound-btn, #share-btn, #ambient-btn { bottom: 14px; width: 29px; height: 29px; border-radius: 8px; background: #fffffff0; border: 1px solid #d1d9ce; color: #355244; }
#help-btn { left: 16px; } #sound-btn { left: 50px; } #share-btn { left: 84px; } #ambient-btn { display: grid; left: 118px; }
#right-panel > .panel-header { padding: 24px 22px 18px; border-bottom: 1px solid var(--border); }
#right-panel > .panel-header .panel-title { font-family: 'Space Grotesk', sans-serif; font-size: 20px; letter-spacing: -.5px; }
#right-panel .hp-head { padding: 22px 22px 10px; gap: 10px; border: none; background: transparent; }
.hp-avatar { width: 37px; height: 37px; border-radius: 12px; background: var(--accent-soft); border: none; }
#right-panel .hp-head b { font-size: 14px; line-height: 1.5; }
#right-panel .hp-head small { font-size: 12px; line-height: 1.5; }
#right-panel #hephaestus-log { padding: 12px 20px; gap: 13px; }
.hp-msg { font-size: 14px; line-height: 1.7; padding: 12px 14px; border-radius: 12px; box-shadow: none; max-width: 100%; }
.hp-bot { border: none; background: var(--panel-3); }
.hp-user { background: var(--accent-soft); color: var(--text); }
.hp-chips { display: flex; flex-direction: column; align-items: stretch; gap: 7px; }
.hp-chip { font-size: 12px; text-align: left; border-radius: 9px; padding: 10px 12px; background: var(--panel-2); border-color: var(--border); color: var(--text-dim); }
.hp-chip:hover { border-color: var(--accent); color: var(--accent-text); }
.hp-tool { font-family: inherit; font-size: 12px; line-height: 1.5; }
#right-panel #hephaestus-form { padding: 14px 18px 18px; background: transparent; border: none; gap: 7px; }
#right-panel #hephaestus-input { min-height: 46px; font-size: 13px; padding: 10px 12px; border-radius: 10px; background: var(--panel-2); }
#right-panel #hephaestus-form button { min-height: 46px; width: 42px; border-radius: 10px; }
#run-tools { padding: 18px 20px; gap: 10px; border-top: 1px solid var(--border); grid-template-columns: 1fr 84px; }
#run-hint { flex-direction: column; align-items: flex-start; }
#run-hint b { font-size: 13px; display: block; margin-bottom: 4px; }
#run-hint span { font-size: 11px; line-height: 1.4; }
#upload-btn { width: 84px; min-height: 43px; border-radius: 10px; color: white; background: #267967; border: none; font-size: 13px; }
#upload-btn .run-icon { color: white; }
#inspector-block { min-height: 0; flex: 0 0 auto; max-height: 38%; overflow: auto; }
#circuit-details-toggle { padding: 15px 20px; width: 100%; text-align: left; font-size: 12px; color: var(--text-dim); background: transparent; border: none; border-top: 1px solid var(--border); }
#circuit-details-toggle::after { content: '+'; float: right; }
.details-open #circuit-details-toggle::after { content: '−'; }
#inspector-block:not(.details-open) > :not(#circuit-details-toggle) { display: none; }
#sim-hud { top: auto; bottom: 222px; left: 50%; transform: translateX(-50%); width: 310px; padding: 10px; background: #fffffff2; border: 1px solid #d1d9ce; color: #233932; border-radius: 12px; }
#sim-hud .sim-kicker, #sim-hud .sim-title, #sim-hud p { display: none; }
#sim-hud .sim-buttons { display: flex; gap: 8px; margin: 0; }
#sim-hud button { flex: 1; min-height: 34px; color: #233932; background: #edf4ee; border: none; }
@media (min-width: 821px) {
  #app, body.mode-sim #app { grid-template-columns: 228px minmax(0, 1fr) 330px; }
  body.mode-sim #left-panel { display: flex; }
  #right-panel #hephaestus { flex: 1 1 auto; min-height: 120px; }
}
@media (min-width: 821px) and (max-width: 1100px) {
  #app, body.mode-sim #app { grid-template-columns: 190px minmax(0, 1fr) 290px; }
  #invention-heading { left: 18px; top: 24px; }
  #invention-heading h1 { font-size: 26px; max-width: 180px; }
  #invention-heading p { display: none; }
  #examples-btn { top: 115px; right: 15px; }
  #bench-tools { top: 160px; right: 15px; }
  #workspace-hud { display: none; }
}
@media (max-width: 820px) {
  body.is-phone #topbar { height: 52px; padding: 0 12px; }
  body.is-phone .tb-name { font-size: 17px; }
  body.is-phone #invention-heading { top: 22px; left: 20px; }
  body.is-phone #invention-heading h1 { font-size: 28px; }
  body.is-phone #invention-heading p { font-size: 11px; }
  body.is-phone #examples-btn { top: 22px; right: 12px; }
  body.is-phone #bench-tools { top: 67px; right: 12px; }
  body.is-phone #experiment { bottom: 74px; width: calc(100% - 32px); padding: 13px 16px; }
  body.is-phone #experiment-tip { margin-top: 9px; }
  body.is-phone #workspace-hud { display: none; }
  body.is-phone.sheet-open #experiment { display: none; }
  body.is-phone #inspector-block > :not(#circuit-details-toggle) { display: block; }
  body.is-phone #circuit-details-toggle { display: none; }
  body.is-phone #sim-hud { bottom: 239px; }
  body.is-phone #starter-shelf { padding-top: 10px; }
  body.is-phone #upload-btn { color: white; }
}
@media (max-height: 520px) and (max-width: 900px) {
  body.is-phone #experiment { left: 16px; bottom: 70px; transform: none; width: 275px; }
  body.is-phone #experiment-tip { display: none; }
  body.is-phone #invention-heading p { display: none; }
  body.is-phone #sim-hud { left: auto; right: 16px; transform: none; bottom: 80px; width: 220px; }
}

#workspace::before { content: ''; position: absolute; inset: 0 0 auto; height: 170px; background: linear-gradient(#f4f5eff2, #f4f5ef00); pointer-events: none; z-index: 2; }
@media (min-width: 821px) {
  #starter-shelf { padding: 16px 13px 12px; }
  #starter-shelf button { padding: 9px 8px; }
  #starter-shelf small { font-size: 10px; margin-top: 2px; }
  #left-panel > #checklist { flex: 0 0 56px; }
  #parts-tray { min-height: 115px; }
  #right-panel #hephaestus-panel { flex: 1; height: auto; }
  #inspector-block:not(.details-open) { max-height: 47px; }
  #right-panel .hp-msg, #right-panel .hp-chips { flex-shrink: 0; }
}
@media (max-height: 700px) and (min-width: 821px) {
  #starter-shelf { padding-top: 12px; padding-bottom: 8px; }
  #starter-shelf button { padding: 7px; }
  .panel-header { padding-top: 10px; padding-bottom: 8px; }
  #left-panel > #checklist { flex-basis: 38px; }
  #left-panel > .panel-header:has(+ #checklist) { padding-top: 6px; }
  #right-panel .hp-head { padding-top: 14px; }
  #right-panel .hp-head small { display: none; }
  #right-panel .hp-msg { padding: 10px 12px; font-size: 13px; line-height: 1.6; }
  #right-panel .hp-chip { padding: 8px 10px; }
}

/* During a physics test, return to building before changing the part inventory. */
@media (min-width: 821px) {
  body.mode-sim #left-panel > :not(#starter-shelf) { visibility: hidden; }
  body.mode-sim #left-panel::after { content: 'Choose Keep building to add or move parts.'; padding: 20px; font-size: 13px; color: var(--text-dim); line-height: 1.6; position: absolute; top: 300px; width: 220px; }
}

#upload-btn:not(:disabled), #upload-btn span { color: #fff; }
@media (max-width: 820px) {
  body.is-phone #topbar { gap: 7px; padding-inline: 10px; }
  body.is-phone .tb-actions { gap: 4px; flex-shrink: 0; }
  body.is-phone .tb-actions #help-btn, body.is-phone .tb-actions #sound-btn,
  body.is-phone .tb-actions #share-btn, body.is-phone .tb-actions #ambient-btn {
    position: static; inset: auto; width: 28px; height: 32px; min-width: 28px;
  }
  body.is-phone .tb-robot { min-width: 0; max-width: 76px; flex-shrink: 1; }
}
