/* Inhabited art direction: physical frames, readable type, foreground people.
   Presentation only: identities, bonds, team, statements and orders are canonical. */
.lw-command-scene, .lw-command-dialog {
  --lw-metal-frame: url('../../assets/living-world/ui-v2/metal-frame.webp');
  --lw-ivory: #eee9dc;
  font-family: 'Exo 2', sans-serif;
}
/* A raster nine-slice decorates the controls without baking in live text. */
.lw-colony-heading, .lw-proposal-copy, .lw-scene-tile, .lw-scene-action,
.lw-command-dialog, .lw-command-dock, .lw-live-project { position: relative; isolation: isolate; }
.lw-colony-heading::before, .lw-proposal-copy::before, .lw-scene-tile::before,
.lw-scene-action::before, .lw-command-dialog::before, .lw-command-dock::before,
.lw-live-project::before {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  border: 14px solid transparent; border-image: var(--lw-metal-frame) 115 fill / 14px / 0 stretch;
}
.lw-command-scene::before, .lw-command-scene::after { display: none; }
.lw-command-scene .lw-scene-art { object-position: center 48%; }
.lw-command-scene .lw-scene-shade { background: linear-gradient(180deg, #04090e55, transparent 22%, transparent 68%, #04090e99); }
.lw-command-header { border: 0; padding-bottom: 0; align-items: start; z-index: 4; }
.lw-colony-heading { display: flex; align-items: center; flex-basis: 290px; gap: 6px; padding: 9px 18px 10px 10px; min-height: 58px; }
.lw-location-emblem { width: 42px; height: 42px; object-fit: contain; flex-shrink: 0; }
.lw-location-copy { min-width: 0; }
.lw-colony-heading h1 { font: 650 clamp(17px, 2vw, 27px)/1.12 'Exo 2', sans-serif; text-transform: uppercase; letter-spacing: .015em; color: var(--lw-ivory); }
.lw-colony-heading .lw-coordinate { color: #91d6db; font: 500 12px/1.4 'Exo 2', sans-serif; }
.lw-economy-hud { padding: 8px 12px 6px; background: linear-gradient(180deg, #071018ed, #0c161ca6); border-top: 1px solid #a8a29280; border-bottom: 1px solid #9da4a74d; box-shadow: 0 3px 15px #0005; }
.lw-command-stage { justify-content: stretch; }
.lw-inhabited-card { width: min(1240px, 100%); height: 100%; flex: 1; max-height: 100%; min-height: 0; display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.3fr); grid-template-rows: minmax(0, 1fr) auto auto; column-gap: 0; row-gap: 10px; background: none; border: 0; box-shadow: none; border-radius: 0; }
.lw-inhabited-card::before { display: none; }
.lw-scene-context { grid-column: 2; grid-row: 1; align-self: center; justify-self: end; display: flex; gap: 12px; align-items: center; min-height: 0; max-height: 100%; padding: 4px 8px; }
.lw-scene-tile { width: clamp(115px, 15vw, 205px); height: clamp(95px, 18vh, 175px); border: 0; background: none; padding: 9px; text-align: left; display: flex; align-items: end; box-shadow: 0 12px 24px #0008; transition: transform .2s, filter .2s; }
.lw-scene-tile::before { z-index: 2; border-image-slice: 115; }
.lw-scene-tile-art { position: absolute; inset: 7px; width: calc(100% - 14px); height: calc(100% - 14px); object-fit: cover; object-position: center 25%; z-index: -1; }
.lw-scene-tile > span:not(.lw-character) { width: 100%; background: linear-gradient(transparent, #071017e8 28%); padding: 20px 7px 5px; position: relative; z-index: 1; }
.lw-scene-tile strong { display: block; font-size: clamp(13px, 1.45vw, 20px); font-weight: 600; line-height: 1.15; color: var(--lw-ivory); }
.lw-scene-tile small { display: block; font-size: 10px; line-height: 1.25; color: #aed8da; margin-top: 4px; }
.lw-scene-tile:hover { transform: translateY(-3px); filter: brightness(1.12); }
.lw-scene-companion { align-self: end; transform: translateY(10px); }
.lw-scene-companion:hover { transform: translateY(7px); }
.lw-inhabited-card .lw-proposal-visual { grid-row: 1 / 4; grid-column: 1; align-self: end; height: min(100%, 570px); width: 115%; overflow: visible; z-index: 2; pointer-events: none; }
.lw-inhabited-card .lw-proposal-visual::after { display: none; }
.lw-inhabited-card .lw-proposal-image { width: 100%; height: 100%; object-fit: cover; object-position: center 22%; border: 0; border-radius: 0; mask-image: linear-gradient(0deg, transparent, #000 15%, #000 84%, transparent), linear-gradient(90deg, transparent, #000 12%, #000 74%, transparent); mask-composite: intersect; filter: drop-shadow(0 8px 22px #0009); }
.lw-inhabited-card .lw-proposal-copy { grid-column: 2; grid-row: 2; align-self: end; padding: 23px 27px 25px 44px; gap: 8px; z-index: 1; }
.lw-proposal-copy::before { inset: 0 0 0 -10%; border-image-width: 22px; }
.lw-inhabited-card .lw-proposal-speaker { gap: 2px; }
.lw-inhabited-card .lw-proposal-speaker strong { color: var(--lw-ivory); font: 600 clamp(24px, 2.8vw, 38px)/1.1 'Exo 2', sans-serif; }
.lw-inhabited-card .lw-proposal-speaker span { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: #8ed3d6; }
.lw-inhabited-card .lw-proposal-bond { color: #d8c5a7; font-size: 12px; line-height: 1.25; }
.lw-inhabited-card .lw-proposal-copy h2 { color: #edd8ac; font: 550 clamp(16px, 1.7vw, 23px)/1.2 'Exo 2', sans-serif; letter-spacing: 0; margin-top: 8px; }
.lw-inhabited-card .lw-proposal-summary { font: 400 clamp(15px, 1.65vw, 23px)/1.4 'Exo 2', sans-serif; color: #eeece4; text-wrap: pretty; }
.lw-inhabited-card .lw-proposal-controls { grid-column: 2; grid-row: 3; display: flex; flex-direction: column; padding: 0; gap: 4px; z-index: 3; }
.lw-proposal-pager { display: flex; align-items: center; justify-content: end; width: 100%; gap: 4px; }
.lw-proposal-pager .lw-page-button { width: 44px; height: 44px; border: 0; background: #071017cf; font-size: 27px; line-height: 1; color: #d4c29d; }
.lw-proposal-pager .lw-proposal-position { padding: 3px 10px; background: #071017c9; font: 400 12px 'Share Tech Mono', monospace; color: #e3d7bc; }
.lw-proposal-pager button:disabled { opacity: .35; }
.lw-scene-actions { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 10px; width: 100%; }
.lw-inhabited-card .lw-scene-action { display: flex; align-items: center; gap: 8px; justify-content: center; padding: 10px 17px 10px 7px; min-height: 66px; background: none; border: 0; border-radius: 0; color: var(--lw-ivory) !important; font: 550 clamp(14px, 1.65vw, 22px)/1.15 'Exo 2', sans-serif; box-shadow: 0 8px 24px #0007; }
.lw-scene-action::before { border-image-width: 12px; }
.lw-scene-action.lw-button-primary::after { content: ''; position: absolute; inset: 8px; background: linear-gradient(115deg, #ae783939, #b57c3020); z-index: -1; pointer-events: none; }
.lw-action-emblem { width: 49px; height: 49px; object-fit: contain; filter: drop-shadow(0 4px 4px #0009); flex-shrink: 0; }
.lw-inhabited-card .lw-listen-link { margin: 0; }
.lw-scene-action:hover { filter: brightness(1.2); }
.lw-scene-action:active { transform: translateY(1px); }
.lw-command-dock { width: min(750px, 100%); padding: 9px 12px 7px; border: 0; gap: 5px; }
.lw-command-dock::before { border-image-width: 10px; }
.lw-dock-button { background: none; }
.lw-dock-button img { width: 42px; height: 42px; }
.lw-dock-button span { font-size: 11px; color: #d5d4c7; }
.lw-live-project { border: 0; background: none; padding: 10px 16px; width: min(860px, 100%); }
.lw-live-project::before { border-image-width: 9px; }
.lw-command-dialog { position: fixed; border: 0; border-radius: 0; background: #08121a; box-shadow: 0 22px 90px #000c; }
.lw-command-dialog::before { inset: 0; z-index: 3; border-image-slice: 115; border-image-width: 12px; }
.lw-command-dialog .lw-panel-header h2 { font-family: 'Exo 2', sans-serif; font-weight: 600; color: #eee8d9; }
.lw-command-dialog .lw-dialog-frame { padding: 5px; }
.lw-command-dialog .lw-panel-header { border-bottom-color: #b2a18a66; }
.lw-command-dialog .lw-page-heading { color: #88cdd1 !important; letter-spacing: .08em; text-transform: uppercase; }
.lw-command-dialog .lw-panel-footer { background: linear-gradient(90deg, #a77d3021, #203e4e2b); }
.lw-command-dialog .lw-panel-actions .lw-button { border-color: #b6a88999; background: linear-gradient(135deg, #4c463980, #192830); border-radius: 0; box-shadow: inset 0 0 0 2px #050b1180, inset 0 3px 0 #f8e5b421; }
@keyframes lw-art-arrival { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.lw-proposal-copy, .lw-scene-context { animation: lw-art-arrival .35s ease-out both; }
@media (orientation: landscape) and (max-height: 520px) {
  .lw-command-header { gap: 10px; min-height: 42px; }
  .lw-colony-heading { flex-basis: 200px; padding: 6px 10px; gap: 3px; min-height: 42px; }
  .lw-colony-heading::before { border-image-width: 8px; }
  .lw-location-emblem { width: 27px; height: 27px; }
  .lw-colony-heading h1 { font-size: 15px; }
  .lw-colony-heading .lw-coordinate { font-size: 10px; }
  .lw-economy-hud { padding: 3px 8px; gap: 1px 7px; }
  .lw-inhabited-card { grid-template-columns: minmax(0, .7fr) minmax(0, 1.3fr); grid-template-rows: minmax(0, 1fr) auto; row-gap: 5px; }
  .lw-inhabited-card .lw-proposal-visual { grid-row: 1 / 3; height: 100%; width: 115%; }
  .lw-inhabited-card .lw-proposal-image { object-position: center 20%; }
  .lw-scene-context { grid-area: auto; position: absolute; bottom: 4px; left: 0; width: 32%; padding: 0; gap: 5px; z-index: 3; }
  .lw-scene-tile { flex: 1; min-width: 0; width: auto; height: 64px; padding: 5px; }
  .lw-scene-tile::before { border-image-width: 7px; }
  .lw-scene-tile-art { inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); }
  .lw-scene-tile > span:not(.lw-character) { padding: 12px 3px 2px; }
  .lw-scene-tile strong { font-size: 10px; }
  .lw-scene-tile small { font-size: 8px; margin-top: 1px; }
  .lw-scene-companion, .lw-scene-companion:hover { transform: none; }
  .lw-inhabited-card .lw-proposal-copy { grid-row: 1; padding: 13px 15px 12px 30px; gap: 4px; align-self: stretch; justify-content: center; }
  .lw-proposal-copy::before { border-image-width: 12px; inset: 0 0 0 -5%; }
  .lw-inhabited-card .lw-proposal-speaker strong { font-size: 23px; }
  .lw-inhabited-card .lw-proposal-speaker span { font-size: 9px; }
  .lw-inhabited-card .lw-proposal-bond { font-size: 10px; }
  .lw-inhabited-card .lw-proposal-copy h2 { font-size: 15px; margin-top: 3px; }
  .lw-inhabited-card .lw-proposal-summary { font-size: 12px; line-height: 1.35; }
  .lw-inhabited-card .lw-proposal-controls { grid-row: 2; flex-direction: row; gap: 7px; }
  .lw-proposal-pager { width: auto; gap: 1px; flex: 0 0 auto; }
  .lw-proposal-pager .lw-page-button { width: 44px; height: 44px; }
  .lw-proposal-pager .lw-proposal-position { padding: 2px; font-size: 9px; }
  .lw-scene-actions { gap: 5px; }
  .lw-inhabited-card .lw-scene-action { min-height: 48px; padding: 6px 9px 6px 5px; gap: 4px; font-size: 12px !important; }
  .lw-action-emblem { width: 28px; height: 32px; }
  .lw-command-dock { min-height: 51px; padding: 4px 10px; width: min(630px, 100%); }
  .lw-dock-button { min-height: 44px; padding: 1px; }
  .lw-dock-button img { width: 28px; height: 28px; }
  .lw-dock-button span { font-size: 9px; }
  .lw-live-project { padding: 5px 12px; }
  .lw-command-dialog .lw-dialog-frame { padding: 3px; }
}
@media (orientation: portrait) {
  .lw-command-header { gap: 6px; }
  .lw-colony-heading { flex-basis: 100%; min-height: 50px; padding: 7px 12px; }
  .lw-location-emblem { width: 34px; height: 34px; }
  .lw-colony-heading h1 { font-size: 22px; }
  .lw-economy-hud { padding: 4px 6px; }
  .lw-inhabited-card { grid-template-columns: minmax(0, .65fr) minmax(0, 1.35fr); grid-template-rows: minmax(60px, 1fr) auto auto; gap: 7px 0; }
  .lw-scene-context { grid-column: 1 / 3; align-self: end; justify-self: end; gap: 9px; padding: 3px 0; }
  .lw-scene-tile { width: 132px; height: clamp(95px, 15vh, 135px); }
  .lw-scene-tile strong { font-size: 14px; }
  .lw-scene-tile small { font-size: 9px; }
  .lw-scene-companion { width: 102px; transform: none; }
  .lw-inhabited-card .lw-proposal-visual { grid-column: 1; grid-row: 2; align-self: stretch; height: auto; width: 153%; margin-top: -35px; }
  .lw-inhabited-card .lw-proposal-image { object-position: 46% top; }
  .lw-inhabited-card .lw-proposal-copy { grid-column: 2; grid-row: 2; padding: 18px 14px 20px 27px; gap: 5px; }
  .lw-proposal-copy::before { inset: 0 0 0 -55%; border-image-width: 15px; }
  .lw-inhabited-card .lw-proposal-speaker strong { font-size: 26px; }
  .lw-inhabited-card .lw-proposal-speaker span { font-size: 9px; }
  .lw-inhabited-card .lw-proposal-bond { font-size: 10px; }
  .lw-inhabited-card .lw-proposal-copy h2 { font-size: 16px; margin-top: 5px; }
  .lw-inhabited-card .lw-proposal-summary { font-size: 14px; line-height: 1.35; }
  .lw-inhabited-card .lw-proposal-controls { grid-column: 1 / 3; grid-row: 3; flex-direction: column; }
  .lw-proposal-pager { justify-content: center; }
  .lw-proposal-pager .lw-page-button { height: 44px; }
  .lw-scene-actions { gap: 7px; }
  .lw-inhabited-card .lw-scene-action { min-height: 57px; padding: 7px 10px 7px 5px; font-size: 15px !important; gap: 4px; }
  .lw-action-emblem { width: 36px; height: 36px; }
  .lw-command-dock { padding: 6px 8px; gap: 1px; }
  .lw-dock-button img { width: 29px; height: 29px; }
  .lw-dock-button span { font-size: 8px; }
  .lw-live-project { padding: 7px 11px; }
  .lw-command-dialog .lw-dialog-frame { padding: 3px; }
}
@media (prefers-reduced-motion: reduce) {
  .lw-proposal-copy, .lw-scene-context { animation: none; }
  .lw-scene-tile, .lw-scene-action { transition: none; }
}

@media (orientation: portrait) {
  .lw-command-dialog { top: calc(140px + var(--lw-safe-top)); height: calc(100dvh - var(--lw-safe-top) - var(--lw-safe-bottom) - 228px); }
  .lw-command-dialog .lw-dialog-hero { flex-basis: 70px; }
}

/* Stable presentation variants for the 20 persisted portrait identities.
   The original portrait path remains authoritative and unknown art falls back. */
.lw-character { display: block; position: relative; overflow: hidden; }
.lw-character-cell { position: absolute; inset: 0; overflow: hidden; }
.lw-character-cell > img { position: absolute; top: 0; width: 500%; max-width: none; height: auto; object-fit: initial; }
.lw-inhabited-card .lw-proposal-visual .lw-character-cell { inset: 0 auto 0 50%; height: 100%; width: auto; aspect-ratio: .65; transform: translateX(-50%); }
.lw-command-dialog .lw-dialog-hero-person .lw-character { position: absolute; inset: 0; width: 100%; height: 100%; }
.lw-command-dialog .lw-dialog-hero-person .lw-character-cell { inset: 0 auto 0 50%; height: 100%; width: auto; aspect-ratio: .65; transform: translateX(-50%); }
@media (orientation: portrait) {
  .lw-command-dialog .lw-dialog-hero-person .lw-character-cell { width: 130px; height: 260px; aspect-ratio: auto; top: -10px; }
}
.lw-scene-tile .lw-character { position: absolute; }
.lw-inhabited-card .lw-proposal-visual .lw-character-cell {
  mask-image: linear-gradient(0deg, transparent, #000 12%, #000 92%, transparent), linear-gradient(90deg, transparent, #000 14%, #000 84%, transparent);
  mask-composite: intersect;
}
@media (orientation: landscape) and (max-height: 520px) {
  .lw-inhabited-card .lw-proposal-summary { font-size: 14px; line-height: 1.35; }
}

.lw-command-dialog .lw-panel-actions .lw-button { color: var(--lw-ivory) !important; }
.lw-command-dialog h2, .lw-command-dialog h3 { font-family: 'Exo 2', sans-serif; }
.lw-instrument { display: block; position: relative; flex-shrink: 0; overflow: hidden; aspect-ratio: 1; mask-image: radial-gradient(ellipse, #000 46%, transparent 73%); }
.lw-instrument > img { position: absolute; width: 300%; height: 200%; max-width: none; object-fit: fill; filter: none; transform: none !important; }
.lw-dock-button .lw-instrument { width: 44px; height: 44px; transition: filter .2s; }
.lw-dock-button .lw-instrument > img { width: 300%; height: 200%; }
.lw-dock-button:hover .lw-instrument { filter: brightness(1.3); }
@media (orientation: landscape) and (max-height: 520px) {
  .lw-dock-button .lw-instrument { width: 30px; height: 30px; }
  .lw-action-emblem.lw-instrument { width: 32px; height: 32px; }
}
@media (orientation: portrait) {
  .lw-dock-button .lw-instrument { width: 32px; height: 32px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .lw-scene-companion .lw-character { width: 44%; }
  .lw-scene-companion > span:not(.lw-character) { margin-left: 40%; padding-top: 3px; background: #08121aaa; }
}

.lw-hud-more { display: none; }

/* Phone legibility: secondary text at least 12-13px, body 16px, three resources up front, bigger dock */
@media (orientation: portrait) {
  .lw-economy-hud { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; justify-content: stretch; gap: 2px 8px; padding: 3px 10px; background: linear-gradient(180deg, #050b12f2, #08121af0); }
  .lw-hud-metric { grid-template-columns: 24px minmax(0, auto); column-gap: 4px; }
  .lw-hud-metric img { width: 24px; height: 28px; }
  .lw-hud-metric span, .lw-hud-metric small { font-size: 12px; color: #d9e2e8; }
  .lw-hud-metric b, .lw-hud-metric strong { font-size: 16px; }
  .lw-hud-metric[data-lw-hud-resource="plasma"], .lw-hud-metric[data-lw-hud-resource="alloy"], .lw-hud-metric[data-lw-hud-resource="energy"], .lw-hud-scope { display: none; }
  .lw-hud-more { display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 48px; min-height: 44px; padding: 2px 6px; border: 1px solid #a8a29280; border-radius: 8px; }
  .lw-hud-more strong { font-size: 15px; }
  .lw-scene-tile strong { font-size: 14px; }
  .lw-scene-tile small { font-size: 12px; color: #cfe9ea; }
  .lw-scene-tile .lw-tile-extra { display: none; }
  .lw-scene-tile > span:not(.lw-character) { background: linear-gradient(180deg, transparent, #050b12e6 45%); }
  .lw-inhabited-card .lw-proposal-copy { text-shadow: 0 1px 3px #000, 0 0 14px #000c; }
  .lw-inhabited-card .lw-proposal-copy::after { content: ''; position: absolute; inset: 6px 6px 6px -8%; z-index: -1; background: linear-gradient(90deg, #050a1000, #050a10d9 22%, #050a10e6); border-radius: 6px; pointer-events: none; }
  .lw-inhabited-card .lw-proposal-speaker strong { font-size: 24px; }
  .lw-inhabited-card .lw-proposal-speaker span { font-size: 12px; letter-spacing: .02em; color: #9fe2e4; }
  .lw-inhabited-card .lw-proposal-bond { display: none; }
  .lw-inhabited-card .lw-proposal-copy h2 { font-size: 17px; }
  .lw-inhabited-card .lw-proposal-summary { font-size: 15px; line-height: 1.36; color: #f6f3ea; }
  .lw-inhabited-card .lw-proposal-copy { padding-top: 12px; padding-bottom: 12px; }
  .lw-proposal-pager .lw-proposal-position { padding: 6px 14px; font-size: 16px; }
  .lw-proposal-pager .lw-page-button { width: 52px; height: 48px; font-size: 30px; }
  .lw-command-dock { padding: 6px 6px calc(6px + var(--lw-safe-bottom, 0px)); }
  .lw-dock-button { min-height: 60px; }
  .lw-dock-button .lw-instrument { width: 40px; height: 40px; }
  .lw-dock-button span { font-size: 12px; color: #ece8da; }
  .lw-orientation-note { display: none !important; }
}
