:root {
  --paper: #0b1116;
  --ink: #d7d9d2;
  --muted: #99a5a5;
  --line: #334047;
  --green: #c1ae86;
  --cell-w: 96px;
  --cell-h: 96px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
a { color: inherit; text-decoration: none; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid #d4bf91;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.sr-only, .skip {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip:focus { position: fixed; top: 8px; left: 8px; width: auto; height: auto; padding: 12px; clip-path: none; background: #172127; z-index: 99; }
.site-head { height: 64px; padding: 0 28px; display: flex; align-items: center; justify-content: space-between; }
.wordmark h1 { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 23px; font-weight: 500; letter-spacing: 3px; text-transform: uppercase; margin: 0; }
.menu-button { border: 0; border-radius: 2px; background: transparent; width: 38px; height: 38px; font-size: 17px; letter-spacing: 2px; }
.menu-button:hover { background: #1c272d; }
main { height: calc(100dvh - 64px); padding: 0 24px 24px; }
.workspace { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 28px; height: 100%; }
.control-panel { padding: 20px 8px; align-self: center; max-height: 100%; overflow-y: auto; scrollbar-width: thin; }
h2 { font-size: 18px; margin: 0 0 20px; font-weight: 600; line-height: 1.6; }
h3 { font-size: 15px; }
label { font-size: 11px; display: block; margin: 16px 0 8px; }
input, select, textarea { border: 1px solid #3a474d; background: #121b21; border-radius: 2px; padding: 10px 11px; width: 100%; min-width: 0; font-size: 12px; }
select { padding-right: 20px; }
.activity-row { display: flex; gap: 6px; }
.activity-row select { background: transparent; }
.square { height: 37px; min-width: 37px; background: transparent; border: 1px solid var(--line); border-radius: 2px; font-size: 22px; }
.timer { font-variant-numeric: tabular-nums; font-size: 65px; font-weight: 300; letter-spacing: -3px; text-align: center; margin: 25px -6px 0; line-height: 1.3; }
.timer span { color: #607075; }
.timer-status { text-align: center; font-size: 10px; color: var(--muted); margin: 6px 0 14px; min-height: 16px; }
.presets, .mode-switch { display: flex; gap: 6px; }
.presets button, .mode-switch button { background: transparent; border: 1px solid var(--line); padding: 9px 5px; border-radius: 2px; flex: 1; font-size: 11px; }
.presets .selected, .mode-switch .selected { background: #2b302c; border-color: #af9b71; color: #dfcfab; }
.custom-duration { display: flex; align-items: center; gap: 9px; margin-top: 15px; color: var(--muted); }
.custom-duration input { margin-left: auto; width: 66px; text-align: center; padding: 7px; }
.muted { color: var(--muted); }
.small { font-size: 10px; line-height: 1.9; }
.button { border: 1px solid var(--line); border-radius: 2px; background: transparent; padding: 10px 14px; font-size: 11px; line-height: 1.4; }
.button:hover:not(:disabled) { background: #243037; }
.primary { background: var(--green); color: #10171c; border-color: var(--green); font-weight: 600; padding: 14px 16px; }
.primary:hover:not(:disabled) { background: #d9c49c; }
.full { width: 100%; margin-top: 10px; }
.quiet { border-color: transparent; }
.area-hint { text-align: center; font-size: 9px; margin: 14px 0 0; color: var(--muted); }
.timer-actions { display: flex; gap: 6px; }
.timer-actions .button { flex: 1; padding: 13px 6px; }
.city-panel { border-radius: 2px; overflow: hidden; min-width: 0; min-height: 0; position: relative; }
.city-toolbar { position: absolute; top: 12px; right: 12px; left: 12px; z-index: 8; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.city-tools { display: flex; gap: 7px; align-items: center; margin-left: auto; pointer-events: auto; background: #10191dcf; border: 1px solid #53606350; border-radius: 2px; padding: 2px 5px; backdrop-filter: blur(6px); }
.badge { font-size: 9px; padding: 6px 8px; border-radius: 2px; color: #a0aaa9; background: #10191dcc; }
.zoom-label { display: block; margin: 0; }
.zoom-label select { font-size: 10px; padding: 6px; width: 65px; background: transparent; border: 0; }
.city-viewport { height: 100%; overflow-x: hidden; overflow-y: auto; scrollbar-gutter: stable; overscroll-behavior: contain; position: relative; background: #0c1319; scrollbar-width: thin; scrollbar-color: #4e5b5d #10171c; touch-action: pan-y; }
.city-world { position: relative; isolation: isolate; overflow: hidden; }
.sky { position: absolute; inset: 0; }
.soil { position: absolute; top: var(--ground); bottom: 0; width: 100%; }
.city-grid { position: absolute; inset: 0; opacity: 0; pointer-events: none; background-image: linear-gradient(to right, #c8d5c71c 1px, transparent 1px), linear-gradient(to bottom, #c8d5c71c 1px, transparent 1px); background-size: var(--cell-w) var(--cell-h); background-position: var(--grid-left, 0px) var(--sky-pad, 0px); }
.is-building .city-grid { opacity: 1; }
.city-room { position: absolute; background: transparent; border: 0; padding: 0; border-radius: 0; cursor: pointer; z-index: 2; clip-path: var(--room-clip); }
.city-room:hover, .city-room:focus-visible { z-index: 4; filter: brightness(1.08); outline: 2px solid #45624e; outline-offset: -2px; }
.city-room svg { width: 100%; height: 100%; display: block; }
.floor-label { display: none; position: absolute; left: 6px; font-family: monospace; font-size: 9px; color: #c6c4ae; background: #10171cc9; border-radius: 2px; padding: 2px 4px; z-index: 5; pointer-events: none; }
.street-detail { position: absolute; width: 100%; top: var(--ground); height: 1px; background: #bec6b41a; pointer-events: none; z-index: 1; }
.city-empty { position: absolute; top: calc(var(--ground) - 145px); left: 50%; transform: translateX(-50%); width: min(250px, calc(100% - 24px)); pointer-events: none; color: #acb7b4; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.city-empty > span { font-size: 35px; opacity: .4; }
.city-empty strong { font-size: 13px; }
.city-empty p { font-size: 10px; margin: 0; }
#preview { position: absolute; z-index: 6; background: #c8b27a25; outline: 2px dashed #cfb786; pointer-events: none; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #ecd9b1; }
#preview.invalid { background: #b8564344; outline-color: #c77e65; color: #e8b6a6; }
.notice { position: fixed; z-index: 15; bottom: 18px; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); background: #1c292c; border: 1px solid #455759; border-radius: 2px; padding: 11px 16px; font-size: 11px; line-height: 1.8; box-shadow: 0 4px 18px #33452f12; }
.notice.error { background: #372522; border-color: #81594a; color: #e9bba9; }
dialog { border: 1px solid var(--line); border-radius: 2px; padding: 28px; width: 420px; max-width: calc(100vw - 32px); max-height: 90dvh; background: #131d23; color: var(--ink); box-shadow: 0 20px 100px #273c3230; }
dialog::backdrop { background: #03080baa; backdrop-filter: blur(3px); }
dialog h2 { margin: 12px 0 20px; }
dialog input, dialog textarea { font-size: 14px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; }
.eyebrow { font-size: 9px; letter-spacing: 2px; color: var(--muted); }
.dialog-close { border: 0; }
.account { display: flex; justify-content: space-between; gap: 12px; align-items: center; font-size: 12px; margin: 20px 0 12px; overflow-wrap: anywhere; }
.connection { color: var(--muted); font-size: 10px; flex-shrink: 0; }
.menu-dialog { width: 320px; }
.menu-home { display: block; font-size: 11px; color: var(--muted); margin-top: 24px; }
.error { color: #e4a78e; font-size: 11px; line-height: 1.8; }
.auth-links { display: flex; flex-wrap: wrap; gap: 13px; justify-content: center; margin-top: 22px; }
.auth-links button { padding: 0; border: 0; background: transparent; text-decoration: underline; font-size: 10px; }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.confirm-actions .primary { padding: 10px 16px; }
.mode-switch { margin: 18px 0; }
.field-caption { font-size: 11px; margin: 20px 0 10px; }
.field-caption span { color: var(--muted); font-size: 9px; margin-left: 8px; }
.room-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 260px; overflow-y: auto; padding: 3px; }
.room-choice { border: 1px solid var(--line); background: #151d21; border-radius: 2px; padding: 4px; overflow: hidden; }
.room-choice svg { width: 100%; height: 56px; display: block; }
.room-choice > span { display: block; font-size: 9px; padding: 5px 0; }
.room-choice.selected { border-color: #c2ad7e; box-shadow: 0 0 0 1px #c2ad7e; }
.coordinate-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.placement-status { font-size: 11px; line-height: 1.8; padding: 10px; background: #202c2d; border-radius: 2px; }
.placement-status.error { background: #372522; }
#build-summary { font-size: 11px; line-height: 1.8; }
#build-panel h2 { font-size: 16px; margin-bottom: 12px; }
#expand-help { min-height: 20px; }
.records-dialog { width: 560px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-top: 15px; }
.stats { display: grid; grid-template-columns: 1.25fr 1fr 1fr; margin: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 22px 0; }
.stats > div { display: flex; flex-direction: column; gap: 9px; border-right: 1px solid var(--line); padding-left: 15px; }
.stats > div:first-child { padding-left: 0; }
.stats > div:last-child { border: 0; }
.stats strong { font-size: 27px; font-weight: 400; font-variant-numeric: tabular-nums; }
.stats strong span { font-size: 10px; margin-left: 4px; }
.stats > div > span { font-size: 9px; color: var(--muted); }
.history { max-height: 320px; overflow: auto; font-size: 11px; }
.history-row { display: grid; grid-template-columns: 65px 1fr auto; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); align-items: center; }
.history-row time { font-size: 10px; color: var(--muted); }
.history-row strong { font-weight: 500; overflow-wrap: anywhere; }
.history-row small { display: block; color: var(--muted); font-size: 9px; margin-top: 5px; }
.history-row > span { font-variant-numeric: tabular-nums; font-size: 12px; }
.history-empty { padding: 20px 0; font-size: 11px; color: var(--muted); }
.room-detail { font-size: 11px; line-height: 1.9; }
.room-detail h3 { margin: 0 0 16px; }
.room-detail p { margin: 8px 0; color: var(--muted); }
.room-detail .room-close { float: right; }
@media (max-width: 950px) {
  .workspace { grid-template-columns: 215px minmax(0, 1fr); gap: 18px; }
  .timer { font-size: 58px; }
}
@media (max-width: 720px) {
  .site-head { height: 52px; padding: 0 20px; }
  .wordmark h1 { font-size: 25px; }
  main { height: calc(100dvh - 52px); padding: 0 12px 12px; }
  .workspace { display: flex; flex-direction: column; gap: 10px; }
  .control-panel { width: 100%; flex-shrink: 0; padding: 4px 8px 10px; max-height: 46dvh; }
  #focus-panel { display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; grid-template-areas: "activity activity" "timer controls" "status duration" "hint hint"; }
  .activity-row { grid-area: activity; }
  .timer { grid-area: timer; font-size: 55px; margin: 8px 0 0; text-align: left; }
  .timer-status { grid-area: status; text-align: left; margin: 0; min-height: 0; }
  #session-controls { grid-area: controls; align-self: center; }
  #duration-controls { grid-area: duration; }
  .custom-duration { flex-wrap: wrap; gap: 5px; }
  .area-hint { grid-area: hint; margin: 8px 0 0; font-size: 9px; }
  .timer-actions { flex-wrap: wrap; gap: 4px; }
  .timer-actions .button { padding: 11px 5px; }
  .city-panel { flex: 1; width: 100%; min-height: 0; }
  .city-toolbar { top: 8px; left: 8px; right: 8px; }
  .city-tools { gap: 1px; }
  .city-tools .button { padding: 8px; font-size: 10px; }
  .room-choices { grid-template-columns: repeat(4, 1fr); max-height: 195px; }
  .room-choice svg { height: 53px; }
  .room-choice > span { font-size: 8px; min-height: 24px; }
  dialog { padding: 22px; }
  .stats strong { font-size: 23px; }
  .stats > div { padding-left: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

.is-building .floor-label { display: block; }
.city-room { filter: none; }
.city-room:hover, .city-room:focus-visible { filter: brightness(1.08); outline: 1px solid #cfba8c; outline-offset: -1px; }

/* Photographic concrete continues from the facade into the supporting frame. */
#support-layer, #preview-supports { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
#preview-supports { z-index: 5; }
.concrete-support, .concrete-girder { position: absolute; pointer-events: none; }
.proposed { opacity: .65; filter: sepia(.5); }
.shape-tools { display: flex; justify-content: flex-end; gap: 2px; margin-top: 4px; }
.shape-tools button { font-size: 10px; padding: 8px; }
.shape-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 2px; max-width: 240px; }
.shape-cell { aspect-ratio: 1; padding: 0; border: 1px solid #3a4c52; background: #121d24; border-radius: 1px; min-width: 0; }
.shape-cell[aria-pressed="true"] { background: #a5b09d; border-color: #c0c7b3; box-shadow: inset -3px -3px 0 #526361; }
.shape-cell:hover { border-color: #e4ce9f; }
.city-world { --section-opacity: 0; --section-depth: 0px; }
.city-world.is-building { --section-reveal: 1; }
#room-layer { position: absolute; inset: 0; z-index: 2; clip-path: inset(0 0 max(0px, calc(100% - var(--ground) - var(--section-depth))) 0); }
.is-building #room-layer { clip-path: none; }
.city-room.is-underground, .room-depth.is-underground, .concrete-joint.is-underground,
.city-room.crosses-ground, .room-depth.crosses-ground, .concrete-joint.crosses-ground { mask-image: linear-gradient(to bottom, #000 max(var(--surface-height), calc(var(--surface-height) + var(--section-depth) - 12px)), transparent calc(var(--surface-height) + var(--section-depth))); }
.room-depth.is-underground { clip-path: inset(max(0px, var(--surface-height)) 0 0 0); }
.is-building .city-room, .is-building .room-depth, .is-building .concrete-joint { mask-image: none; }
.city-world:not(.is-subsoil):not(.is-building) .city-room.is-underground { visibility: hidden; pointer-events: none; }
.drawing-tools { display: flex; gap: 6px; margin-top: 10px; }
.drawing-tools button { flex: 1; border: 1px solid var(--line); background: transparent; padding: 10px 4px; font-size: 11px; border-radius: 2px; }
.drawing-tools [aria-pressed="true"] { background: #30382f; border-color: #b6aa87; color: #e1d4b5; }
.drawing-history { display: flex; flex-wrap: wrap; gap: 2px; }
.drawing-history button { flex: 1; padding: 8px 3px; font-size: 10px; }
#drawing-count { color: #d8c79f; margin: 12px 0 3px; }
.city-viewport.is-drawing { touch-action: none; cursor: crosshair; user-select: none; }
.city-viewport.is-drawing .city-room { cursor: crosshair; }
.city-viewport.is-panning { touch-action: none; cursor: grab; user-select: none; }
.city-viewport.is-panning:active { cursor: grabbing; }
.city-room.is-target { filter: brightness(1.12); outline: 2px solid #b6d3bd; outline-offset: -2px; }

.fit-label { font-size: 9px; color: var(--muted); padding: 4px 3px; }

/* Cast-in-place joints overlap both facades; columns bear into their roof seats. */
#connection-layer { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
#session-note { width: 100%; resize: vertical; min-height: 76px; max-height: 220px; border: 1px solid var(--line); background: #0b141a; padding: 10px; border-radius: 2px; line-height: 1.6; }
textarea:focus-visible { outline: 2px solid #d4bf91; outline-offset: 3px; }
.room-work-list { clear: both; margin-top: 20px; }
.room-work { border-top: 1px solid var(--line); padding: 16px 0 12px; }
.room-work-heading { display: flex; flex-wrap: wrap; gap: 4px 16px; justify-content: space-between; color: #bdc2b8; margin-bottom: 8px; font-variant-numeric: tabular-nums; }
.room-work strong, .room-summary { overflow-wrap: anywhere; }
.room-detail .work-note { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }

/* The night sky continues above the growing tower; terrain stays at ground level. */
.sky { background: linear-gradient(to bottom,#060d17 0,#101d29 max(0px,calc(var(--ground) - var(--scene-height) * .55)),#152129 calc(var(--ground) - var(--scene-height) * .2),#111b1e var(--ground),#0d1416 calc(var(--ground) + var(--scene-height) * .22),#0c151d calc(var(--ground) + var(--scene-height) * .5)); }
.sky::after { content: ''; position: absolute; inset: auto 0; top: calc(var(--ground) - var(--scene-height, 632px) * .78); height: var(--scene-height, 632px); background: url('/images/babylon/night-steppe.webp') center top / auto 100% no-repeat; mask-image: linear-gradient(to bottom,transparent,#000 24%,#000 72%,transparent); }

#cloud-layer { position: absolute; top: 0; left: 0; width: 100%; height: var(--ground); overflow: hidden; pointer-events: none; }
.cloud-bank { position: absolute; left: -12%; width: 124%; background: url('/images/babylon/night-clouds-photographic.webp') center / 100% 100% no-repeat; opacity: .56; animation: cloud-drift 150s ease-in-out infinite alternate; animation-delay: var(--cloud-delay, 0s); }
.cloud-bank.distant { left: -7%; width: 117%; opacity: .32; transform: scaleX(-1); animation-name: cloud-drift-distant; animation-duration: 210s; }
@keyframes cloud-drift { from { transform: translateX(-3%); } to { transform: translateX(4%); } }
@keyframes cloud-drift-distant { from { transform: translateX(3%) scaleX(-1); } to { transform: translateX(-4%) scaleX(-1); } }
@media (prefers-reduced-motion: reduce) { .cloud-bank { animation: none; } }
#depth-layer { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.room-depth { position: absolute; pointer-events: none; }
.room-depth svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* Stable controls and readable secondary information. Time settings live in a dialog. */
:root { --muted: #b0bdbf; }
label { font-size: 13px; }
input, select, textarea { font-size: 13px; }
.button { font-size: 13px; min-height: 44px; }
.square { min-width: 44px; height: 44px; }
.menu-button { width: 44px; height: 44px; }
.small { font-size: 12px; line-height: 1.75; }
.timer-status { font-size: 12px; min-height: 20px; }
#duration-controls { min-height: 44px; margin: 4px 0 14px; }
.duration-open { display: block; margin: 0 auto; color: var(--muted); }
.duration-dialog .presets { margin-top: 24px; }
.duration-dialog .presets button { min-height: 44px; font-size: 14px; }
.duration-dialog .custom-duration { font-size: 14px; margin-top: 24px; }
.duration-dialog .custom-duration input { width: 86px; min-height: 44px; font-size: 16px; }
.duration-dialog .dialog-head h2 { margin: 0; }
.area-hint { font-size: 12px; line-height: 1.7; color: #bac5c4; }
.sample-help { font-size: 12px; line-height: 1.8; color: var(--muted); text-align: center; margin: 12px 0 0; }
.field-caption { font-size: 13px; }
.field-caption span { font-size: 11px; }
.room-choice > span { font-size: 12px; line-height: 1.6; }
.placement-status, #build-summary { font-size: 13px; }
.room-detail { font-size: 13px; }
.room-detail h3 { font-size: 18px; padding-right: 78px; }
.room-work-heading { font-size: 12px; }
#room-dialog { width: 560px; }
.sample-caption { color: #cfba8c !important; }
.sample-growth { border: 1px solid var(--line); background: #0c151c; margin-top: 20px; padding: 14px; }
.sample-stage-label { margin-top: 0 !important; color: #d1d9d6 !important; }
.sample-growth-preview { height: 150px; }
.sample-growth-preview > svg { width: 100%; height: 100%; display: block; }
.sample-stages { display: flex; gap: 6px; margin-top: 12px; }
.sample-stages .button { flex: 1; padding: 8px 5px; font-size: 12px; }
.sample-stages [aria-pressed="true"] { background: #303930; border-color: #b5a77e; color: #e5d7b8; }
.fit-label { font-size: 11px; }
.badge { font-size: 11px; }
.cloud-bank { background-image: url('/images/babylon/night-clouds-photographic.webp'); background-size: 100% auto; opacity: .34; }
.cloud-bank.distant { opacity: .2; transform: none; }
@keyframes cloud-drift-distant { from { transform: translateX(3%); } to { transform: translateX(-4%); } }
@media (max-width: 720px) {
  #focus-panel { grid-template-areas: "activity activity" "timer controls" "status duration" "hint hint" "help help"; }
  .timer-status { font-size: 11px; min-height: 18px; }
  #duration-controls { margin: 0; min-height: 44px; align-self: center; }
  .duration-open { margin: 0 0 0 auto; font-size: 12px; padding: 8px; }
  .area-hint { font-size: 12px; }
  .sample-help { grid-area: help; font-size: 11px; margin-top: 6px; }
  .room-choice > span { font-size: 11px; }
  .room-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .city-tools .button { min-height: 44px; font-size: 12px; }
  .fit-label { display: none; }
  .sample-stages .button { font-size: 11px; }
  .control-panel { max-height: 48dvh; }
}

.sample-stage-note { font-size: 12px; line-height: 1.75; margin: 12px 0 0 !important; }

/* Ground contact shadows follow the actual wall and bearing locations. */
#foundation-layer { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.foundation-contact { position: absolute; display: block; background: radial-gradient(ellipse at 50% 20%, #010508e6 0, #0106099e 28%, #01060955 48%, transparent 72%); }
.foundation-contact.column { background: radial-gradient(ellipse at 50% 28%, #010407ee 0, #010508b3 30%, transparent 73%); }
.terrain-shadow { position: absolute; display: block; background: radial-gradient(ellipse at 68% 12%, #01070bad, #01070b5c 40%, transparent 73%); transform: skewX(-28deg); transform-origin: right top; filter: blur(calc(var(--cell-w) * .025)); opacity: .7; }
/* Reuse the terrain at its exact scene coordinates to soften the plinth edge. */
.street-detail { z-index: 4; top: calc(var(--ground) - var(--cell-h) * .035); height: calc(var(--cell-h) * .1); background: linear-gradient(transparent,#0710158c 45%,#24302766 65%,transparent); opacity: calc(.8 * (1 - var(--section-reveal, var(--section-opacity)))); }

/* Bearings share the same orthographic projection and photographic material. */
.concrete-support > svg, .concrete-girder > svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* Recessed movement joints sit inside the floor slab, with one material phase. */
.concrete-joint { position: absolute; display: block; background-color: #53636b; background-image: linear-gradient(#0a172077, #02080dbb), url('/images/babylon/board-formed-concrete.webp'); background-size: 100% 100%, calc(var(--cell-w) * 4) calc(var(--cell-h) * 4); background-position: 0 0, var(--material-x) var(--material-y); }
.concrete-joint.horizontal { box-shadow: inset 0 1px #a8bac126, inset 0 -1px #01060bb3, -1px 2px 3px #01070b66; }
.concrete-joint.vertical { background: #081219b3; box-shadow: inset 1px 0 #9eafb51c; }

/* Focus flow: a committed duration, one scrolling form and a persistent action. */
.header-actions { display: flex; align-items: center; gap: 8px; }
#records-shortcut { color: #c6c9bc; font-variant-numeric: tabular-nums; }
.duration-preview { color: #d9c797; font-size: 14px; min-height: 24px; }
.auth-links { gap: 8px; }
.auth-links button { font-size: 13px; min-height: 44px; min-width: 70px; padding: 10px 8px; }
.category-preview { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.category-room { min-width: 0; border: 1px solid var(--line); background: #10191f; padding: 8px; text-align: center; }
.category-room svg { width: 100%; height: 64px; display: block; }
.category-room span { display: block; font-size: 12px; line-height: 1.6; }
.is-building .control-panel { height: 100%; align-self: stretch; overflow: hidden; padding: 0 8px; }
#build-panel { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.build-fields { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: thin; padding: 16px 3px 12px; }
.build-fields .room-choices { max-height: none; overflow: visible; }
.build-fields details { margin: 14px 0; border-top: 1px solid var(--line); }
.build-fields summary { min-height: 44px; padding: 12px 0; font-size: 13px; cursor: pointer; }
.build-fields details[open] { padding-bottom: 8px; }
.build-actions { flex-shrink: 0; background: var(--paper); border-top: 1px solid #526064; padding: 8px 0 4px; }
.build-actions .placement-status { font-size: 12px; line-height: 1.6; margin: 0 0 4px; padding: 7px 8px; max-height: 60px; overflow-y: auto; }
.build-actions .full { margin-top: 5px; }
.build-actions #discard { font-size: 12px; padding: 8px 4px; }
.mode-switch button { min-height: 44px; font-size: 12px; }
#preview-model { position: absolute; inset: 0; pointer-events: none; z-index: 6; }
.proposed-room { position: absolute; opacity: .92; }
.proposed-room > svg { width: 100%; height: 100%; display: block; overflow: visible; }
#preview { z-index: 7; background: transparent; outline: 1px dashed #dbc791; }
#preview.invalid { background: #b8564344; }
.room-detail-head { position: sticky; top: -1px; z-index: 2; background: #131d23; display: flex; flex-direction: row-reverse; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.room-detail-head h3 { margin: 0; padding: 0; }
.room-detail-head .room-close { float: none; flex-shrink: 0; }
#room-dialog { padding-top: 0; }
.room-exterior-preview { height: 180px; margin: 8px 0 18px; background: #0d171e; border: 1px solid var(--line); padding: 12px; }
.room-exterior-preview > svg { width: 100%; height: 100%; display: block; }
.room-inspector { position: absolute; left: 12px; bottom: 12px; z-index: 9; max-width: calc(100% - 24px); pointer-events: none; padding: 9px 12px; background: #0c151eee; border: 1px solid #7a827166; font-size: 13px; line-height: 1.6; }
.room-inspector strong, .room-inspector span { display: block; overflow-wrap: anywhere; }
.room-inspector span { font-size: 11px; color: var(--muted); }
#rooms-dialog { width: 560px; }
#rooms-dialog .dialog-head, #records-dialog .dialog-head { position: sticky; top: -28px; background: #131d23; z-index: 2; padding: 8px 0; }
.room-directory { display: grid; gap: 8px; }
.directory-room { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 78px; padding: 10px; text-align: left; border: 1px solid var(--line); border-radius: 2px; background: #10191f; }
.directory-room:hover { background: #202d33; }
.directory-room > div:first-child { width: 78px; flex-shrink: 0; }
.directory-room svg { width: 78px; height: 56px; display: block; }
.directory-room strong, .directory-room span { display: block; overflow-wrap: anywhere; }
.directory-room strong { font-size: 14px; font-weight: 500; }
.directory-room span { font-size: 12px; color: var(--muted); line-height: 1.7; }
button.history-row { width: 100%; text-align: left; background: transparent; color: inherit; border: 0; border-bottom: 1px solid var(--line); }
button.history-row:hover { background: #213038; }
.history-row small { font-size: 11px; }
.soil { border-top: 2px solid #30372e; background: linear-gradient(172deg,#242920 0,#1a2422 120px,#111c20 480px,#0c151d 1100px); }
.soil::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 14% 8%,#65604c25,transparent 46%),radial-gradient(ellipse at 79% 37%,#36504d20,transparent 54%); opacity: .65; }
.soil::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(176deg,transparent 0 113px,#8075550c 119px,#050d141c 131px,transparent 156px 283px); }

.ground-marker { position: absolute; top: calc(var(--ground) - 26px); left: 8px; z-index: 5; color: #c8c7ad; background: #0b131de6; padding: 4px 7px; font-size: 11px; pointer-events: none; }
.ground-marker, .floor-label[data-underground] { display: block; opacity: var(--section-reveal, var(--section-opacity)); }
.city-empty p { font-size: 12px; line-height: 1.8; }
@media (max-width: 720px) {
  .header-actions { gap: 0; }
  #records-shortcut { padding: 8px; font-size: 12px; }
  .is-building .control-panel { height: 48dvh; max-height: 48dvh; }
  .build-fields { padding-top: 6px; }
  .build-actions .placement-status { max-height: 44px; font-size: 11px; }
  .build-actions #discard { min-height: 36px; }
  .city-tools .button { padding: 8px; }
  .room-inspector { font-size: 12px; }
  .category-room svg { height: 58px; }
}
#build-summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 720px) {
  #build-panel h2 { font-size: 14px; margin-bottom: 5px; }
  #build-summary { font-size: 12px; margin: 4px 0 8px; line-height: 1.6; }
  .mode-switch { margin: 8px 0; }
  .field-caption { margin: 12px 0 8px; }
}
.soil { --surface-height: 0px; mask-image: linear-gradient(to bottom, #000 max(0px, calc(var(--section-depth) - 80px)), transparent var(--section-depth)); pointer-events: none; }
.is-building .soil { mask-image: none; }
.category-options { margin: 12px 0; }
.category-options summary { min-height: 44px; padding: 12px 0; font-size: 13px; cursor: pointer; }
.dialog-head { position: sticky; top: -28px; z-index: 2; background: #131d23; padding: 8px 0; }
@media (max-width: 720px) {
  .dialog-head, #rooms-dialog .dialog-head, #records-dialog .dialog-head { top: -22px; }
}

/* WebGL is a progressive enhancement: native buttons/records and SVG remain
   usable when WebGL2 is unavailable or the GPU context is lost. */
.city-canvas { position: absolute; left: 0; z-index: 4; pointer-events: none; display: block; max-width: 100%; }
.has-3d #room-layer { z-index: 5; pointer-events: none; }
.has-3d .city-room { opacity: 0; pointer-events: none; }
.has-3d #depth-layer, .has-3d #support-layer, .has-3d #connection-layer,
.has-3d #preview-model, .has-3d #preview-supports { visibility: hidden; }
.has-3d .city-grid { z-index: 5; }
.has-3d.is-building .city-grid { opacity: .4; }
.has-3d #preview { z-index: 6; background: #ddc99b0c; outline-width: 2px; }
.has-3d .ground-marker, .has-3d #floor-labels { z-index: 5; }
.has-3d .city-room:focus-visible { opacity: .015; }
