:root {
  --ink: #18313b;
  --ink-soft: #536970;
  --teal: #0b6f73;
  --teal-dark: #07565a;
  --teal-pale: #d8ebea;
  --navy: #163b4a;
  --sand: #d9b778;
  --paper: #f6f4ee;
  --white: #fff;
  --line: #c9d1cf;
  --line-dark: #8fa09e;
  --active: #087d79;
  --warning: #9b6615;
  --danger: #a13e35;
  --danger-pale: #f3dfdc;
  --unavailable: #717b7c;
  --shadow: 0 10px 30px rgba(20, 44, 52, .15);
  font-family: "Aptos", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: #dde3e1;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; min-width: 320px; min-height: 100%; background: #dde3e1; }
body { min-height: 100vh; overflow: auto; }
button, input { font: inherit; }
button { color: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--sand); outline-offset: 2px; }
.screen-hidden { display: none !important; }
.app-shell { position: relative; width: min(100vw, 1280px); height: min(100vh, 720px); min-width: 960px; min-height: 600px; margin: 0 auto; overflow: hidden; background: var(--paper); box-shadow: var(--shadow); }
.eyebrow, .header-label { color: var(--teal); font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }

/* Startup */
.startup-screen { position: relative; display: grid; grid-template-columns: 42% 58%; width: 100%; height: 100%; background: var(--paper); }
.startup-screen::before { content: ""; position: absolute; inset: 0 58% 0 0; background: var(--navy); }
.startup-brand { position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 70px 66px; color: var(--white); }
.startup-logo { width: 360px; max-width: 100%; filter: brightness(0) invert(1); }
.brand-rule { width: 86px; height: 5px; margin-top: 30px; background: var(--sand); }
.startup-brand p { margin: 18px 0 0; color: #d6e1e3; font-size: 17px; letter-spacing: .18em; text-transform: uppercase; }
.startup-action { position: relative; z-index: 2; align-self: center; max-width: 630px; padding: 60px 70px; }
.startup-action h1 { margin: 12px 0 18px; max-width: 520px; font-family: Georgia, serif; font-size: 55px; font-weight: 500; line-height: 1.03; letter-spacing: -.025em; }
.startup-copy { max-width: 510px; margin: 0 0 36px; color: var(--ink-soft); font-size: 21px; line-height: 1.45; }
.begin-button { min-width: 300px; min-height: 70px; padding: 0 28px; border: 0; border-left: 6px solid var(--sand); background: var(--teal); color: var(--white); font-size: 22px; font-weight: 700; text-align: left; cursor: pointer; }
.begin-button span { float: right; font-size: 30px; line-height: 22px; }
.begin-button:hover { background: var(--teal-dark); }
.simulation-note { margin: 23px 0 0; color: var(--ink-soft); font-size: 14px; }
.zone-watermark { position: absolute; right: 44px; bottom: 24px; display: flex; opacity: .13; font-family: Georgia, serif; font-size: 92px; line-height: 1; }
.zone-watermark span { width: 104px; border-left: 1px solid var(--ink); text-align: center; }

/* Startup layout */
.layout-start { width: 100%; height: 100%; background: var(--paper); }
.start-header { display: flex; align-items: center; gap: 30px; height: 100px; padding: 18px 42px; border-bottom: 1px solid var(--line); background: var(--navy); color: var(--white); }
.start-header img { width: 230px; filter: brightness(0) invert(1); }
.start-header div { display: flex; flex-direction: column; gap: 7px; padding-left: 30px; border-left: 1px solid rgba(255,255,255,.3); }
.start-header .eyebrow { color: var(--sand); }
.start-header strong { font-size: 19px; }
.layout-start-main { height: calc(100% - 100px); padding: 30px 42px 26px; }
.layout-intro { display: flex; align-items: baseline; justify-content: space-between; gap: 30px; }
.layout-intro h1 { margin: 0; font-family: Georgia, serif; font-size: 31px; font-weight: 500; }
.layout-intro p { max-width: 570px; margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.45; }
.layout-choice-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 28px; }
.layout-choice { min-height: 340px; padding: 0; border: 2px solid var(--line); border-radius: 2px; background: var(--white); text-align: left; cursor: pointer; overflow: hidden; }
.layout-choice:hover { border-color: var(--teal); }
.layout-choice.selected { border-color: var(--teal); box-shadow: inset 0 0 0 2px var(--teal); }
.layout-choice-head { display: flex; align-items: center; justify-content: space-between; min-height: 72px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.layout-choice-head strong { font-size: 20px; }
.layout-choice-head span { color: var(--ink-soft); font-size: 13px; }
.layout-choice.selected .layout-choice-head { background: var(--teal); color: var(--white); }
.layout-choice.selected .layout-choice-head span { color: var(--white); }
.mini-plan { display: grid; grid-template-columns: repeat(3, 1fr); height: 142px; margin: 22px 18px 18px; border: 2px solid var(--navy); }
.mini-zone { display: grid; place-items: center; position: relative; border-left: 2px solid var(--navy); font-family: Georgia, serif; font-size: 34px; }
.mini-zone:first-child { border-left: 0; }
.mini-zone.joined { background: var(--teal-pale); }
.mini-zone.joined + .mini-zone.joined { border-left-color: transparent; }
.mini-zone small { position: absolute; bottom: 8px; font-family: "Segoe UI", sans-serif; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.layout-choice-copy { margin: 0; padding: 0 18px; color: var(--ink-soft); font-size: 14px; line-height: 1.45; }
.start-footer { display: grid; grid-template-columns: 110px 1fr 250px; align-items: center; gap: 20px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.text-button { min-height: 50px; border: 0; background: transparent; color: var(--teal); font-weight: 700; cursor: pointer; }
.start-selection-summary { color: var(--ink-soft); font-size: 15px; text-align: center; }
.primary-action { min-height: 54px; padding: 0 22px; border: 0; border-left: 5px solid var(--sand); background: var(--teal); color: var(--white); font-weight: 800; cursor: pointer; }
.primary-action:disabled { border-left-color: var(--line-dark); background: #9aa6a4; cursor: default; }

/* Main control */
.control-shell { display: grid; grid-template-columns: 190px 1fr; grid-template-rows: 74px 1fr; width: 100%; height: 100%; }
.control-header { grid-column: 1 / -1; display: grid; grid-template-columns: 270px 240px 1fr 150px; align-items: center; height: 74px; background: var(--navy); color: var(--white); }
.header-brand { display: flex; flex-direction: column; justify-content: center; height: 100%; padding: 6px 24px; border-right: 1px solid rgba(255,255,255,.25); overflow: hidden; }
.header-brand img { width: 120px; filter: brightness(0) invert(1); }
.header-brand span { margin-top: 3px; color: var(--sand); font-size: 9px; font-weight: 800; letter-spacing: .18em; }
.header-layout { display: flex; flex-direction: column; gap: 3px; padding-left: 24px; }
.header-layout .header-label { color: #97c7c8; font-size: 9px; }
.header-layout strong { font-size: 18px; }
.header-status { justify-self: end; display: flex; align-items: center; gap: 9px; margin-right: 22px; color: #d8e3e3; font-size: 13px; }
.status-dot { width: 10px; height: 10px; border: 2px solid #b7e2da; background: var(--teal); }
.shutdown-button { height: 74px; border: 0; border-left: 1px solid rgba(255,255,255,.25); background: #244c5a; color: var(--white); font-weight: 800; cursor: pointer; }
.shutdown-button:hover { background: var(--danger); }
.side-nav { grid-row: 2; display: flex; flex-direction: column; padding: 10px 0; background: #e8ece9; border-right: 1px solid var(--line); }
.nav-button { display: grid; grid-template-columns: 38px 1fr; align-items: center; min-height: 68px; padding: 0 15px; border: 0; border-left: 5px solid transparent; border-bottom: 1px solid #d2d9d6; background: transparent; color: #38515a; font-size: 15px; font-weight: 700; text-align: left; cursor: pointer; }
.nav-button:hover { background: #dde5e2; }
.nav-button.active { border-left-color: var(--sand); background: var(--white); color: var(--navy); }
.nav-index { color: var(--teal); font-size: 10px; letter-spacing: .08em; }
.workspace { grid-column: 2; grid-row: 2; min-width: 0; overflow: hidden; background: var(--paper); }
.room-strip { display: grid; grid-template-columns: 190px 1fr 150px; align-items: center; height: 94px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: var(--white); }
.room-strip-copy { display: flex; flex-direction: column; gap: 5px; }
.room-strip-copy strong { font-size: 20px; }
.zone-diagram { display: grid; grid-template-columns: repeat(3, 1fr); height: 58px; margin: 0 30px; border: 2px solid var(--navy); }
.zone-cell { position: relative; display: flex; align-items: center; justify-content: center; gap: 7px; border-left: 2px solid var(--navy); background: var(--white); cursor: default; }
.zone-cell:first-child { border-left: 0; }
.zone-cell.in-group { background: var(--teal-pale); }
.zone-cell.join-left { border-left-color: transparent; }
.zone-cell.selectable { cursor: pointer; }
.zone-cell.selectable:hover { background: #edf6f4; }
.zone-cell.focus-zone { box-shadow: inset 0 -5px 0 var(--teal); }
.zone-letter { font-family: Georgia, serif; font-size: 25px; }
.zone-name { font-size: 12px; font-weight: 800; text-transform: uppercase; }
.zone-divider { position: absolute; top: -2px; left: -2px; padding: 2px 4px; background: var(--navy); color: var(--white); font-size: 8px; font-weight: 800; letter-spacing: .05em; }
.change-layout-button { min-height: 50px; border: 2px solid var(--teal); background: transparent; color: var(--teal); font-weight: 800; cursor: pointer; }
.change-layout-button:hover { background: var(--teal-pale); }
.page-content { height: calc(100% - 94px); padding: 20px 26px 22px; overflow: hidden; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
.page-head h1 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 30px; font-weight: 500; }
.page-head p { max-width: 540px; margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.4; text-align: right; }
.section-title { margin: 0 0 10px; color: var(--ink); font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }

/* Room */
.room-overview { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; }
.room-plan-large { min-height: 320px; padding: 20px; border: 1px solid var(--line); background: var(--white); }
.large-plan { display: grid; grid-template-columns: repeat(3, 1fr); height: 190px; border: 3px solid var(--navy); }
.large-zone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; border-left: 3px solid var(--navy); }
.large-zone:first-child { border-left: 0; }
.large-zone.in-group { background: var(--teal-pale); }
.large-zone.join-left { border-left-color: transparent; }
.large-zone strong { font-family: Georgia, serif; font-size: 44px; font-weight: 500; }
.large-zone span { font-size: 13px; font-weight: 800; text-transform: uppercase; }
.large-zone small { margin-top: 7px; color: var(--ink-soft); font-size: 11px; }
.layout-summary { margin: 17px 0 0; color: var(--ink-soft); font-size: 14px; line-height: 1.45; }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quick-action { min-height: 87px; padding: 13px; border: 1px solid var(--line); border-top: 4px solid var(--teal); background: var(--white); font-weight: 800; text-align: left; cursor: pointer; }
.quick-action small { display: block; margin-top: 7px; color: var(--ink-soft); font-size: 11px; font-weight: 500; line-height: 1.3; }
.quick-action:hover { border-color: var(--teal); }

/* Sources */
.source-layout { display: grid; grid-template-columns: 1.28fr .72fr; gap: 18px; }
.source-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.source-button { position: relative; min-height: 76px; padding: 13px 15px 13px 18px; border: 1px solid var(--line); border-left: 5px solid var(--line-dark); background: var(--white); text-align: left; cursor: pointer; }
.source-button strong { display: block; font-size: 16px; }
.source-button span { display: block; margin-top: 5px; color: var(--ink-soft); font-size: 12px; }
.source-button:hover { border-color: var(--teal); }
.source-button.selected { border-color: var(--teal); border-left-color: var(--sand); background: var(--teal-pale); }
.source-button.active-source::after { content: "ACTIVE"; position: absolute; top: 9px; right: 9px; color: var(--teal); font-size: 9px; font-weight: 900; letter-spacing: .08em; }
.route-panel { min-height: 322px; padding: 18px; border: 1px solid var(--line); background: #edf1ee; }
.route-panel h2 { margin: 0 0 14px; font-size: 18px; }
.route-target { padding: 13px 0; border-top: 1px solid var(--line); }
.route-target strong { display: block; font-size: 15px; }
.route-target span { color: var(--ink-soft); font-size: 12px; }
.impact-zones { display: flex; gap: 7px; margin: 15px 0; }
.impact-zone { display: grid; place-items: center; width: 48px; height: 48px; border: 2px solid var(--line-dark); background: var(--white); font-family: Georgia, serif; font-size: 21px; }
.impact-zone.on { border-color: var(--teal); background: var(--teal-pale); }
.apply-source { width: 100%; min-height: 56px; margin-top: 12px; border: 0; border-left: 5px solid var(--sand); background: var(--teal); color: var(--white); font-weight: 800; cursor: pointer; }
.apply-source:disabled { background: #94a09e; border-left-color: #bac1bf; cursor: default; }
.plain-status { margin: 12px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.4; }

/* Audio */
.audio-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.volume-panel, .mic-panel { min-height: 355px; padding: 18px; border: 1px solid var(--line); background: var(--white); }
.volume-readout { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; }
.volume-readout strong { font-family: Georgia, serif; font-size: 46px; font-weight: 500; }
.volume-readout span { color: var(--ink-soft); font-size: 13px; }
.fader-row { display: grid; grid-template-columns: 58px 1fr 58px; align-items: center; gap: 12px; }
.step-button { min-height: 58px; border: 2px solid var(--teal); background: var(--white); color: var(--teal); font-size: 27px; font-weight: 800; cursor: pointer; }
.step-button:active { background: var(--teal-pale); }
input[type="range"] { width: 100%; height: 58px; accent-color: var(--teal); cursor: pointer; }
.mute-button { width: 100%; min-height: 58px; margin-top: 15px; border: 2px solid var(--navy); background: var(--white); color: var(--navy); font-weight: 900; cursor: pointer; }
.mute-button.muted { border-color: var(--danger); background: var(--danger-pale); color: var(--danger); }
.step-note { margin: 13px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.4; }
.mic-list { display: grid; gap: 9px; }
.mic-row { display: grid; grid-template-columns: 1fr 90px; align-items: center; min-height: 63px; padding: 8px 10px 8px 14px; border-left: 4px solid var(--teal); background: #edf1ee; }
.mic-row strong { display: block; font-size: 14px; }
.mic-row span { display: block; margin-top: 3px; color: var(--ink-soft); font-size: 11px; }
.mic-mute { min-height: 44px; border: 1px solid var(--navy); background: var(--white); font-size: 12px; font-weight: 800; cursor: pointer; }
.mic-mute.muted { border-color: var(--danger); background: var(--danger-pale); color: var(--danger); }

/* Shades and lighting */
.zone-control-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.zone-control-grid.count-1 { grid-template-columns: minmax(420px, 680px); justify-content: center; }
.zone-control-grid.count-2 { grid-template-columns: repeat(2, minmax(320px, 1fr)); }
.zone-control { min-height: 340px; border: 1px solid var(--line); background: var(--white); }
.zone-control-head { display: flex; align-items: baseline; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); background: #edf1ee; }
.zone-control-head strong { font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.zone-control-head span { color: var(--teal); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.shade-visual { position: relative; height: 130px; margin: 16px; border: 8px solid var(--navy); background: linear-gradient(#b7d1d1 0 58%, #a4b688 58%); overflow: hidden; }
.shade-panel { position: absolute; inset: 0 0 auto; height: var(--shade-height, 50%); background: repeating-linear-gradient(0deg, #d8d4c7 0 12px, #c8c3b5 12px 13px); border-bottom: 4px solid #6d706d; transition: height .25s ease; }
.shade-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; padding: 0 16px; }
.shade-button { min-height: 54px; border: 1px solid var(--teal); background: var(--white); color: var(--teal); font-weight: 800; cursor: pointer; }
.shade-button.selected { background: var(--teal); color: var(--white); }
.scene-list { display: grid; gap: 8px; padding: 16px; }
.scene-button { min-height: 53px; padding: 0 16px; border: 1px solid var(--line-dark); border-left: 5px solid var(--line-dark); background: var(--white); font-weight: 800; text-align: left; cursor: pointer; }
.scene-button:hover { border-color: var(--teal); }
.scene-button.selected { border-color: var(--teal); border-left-color: var(--sand); background: var(--teal-pale); }

/* Wall and status */
.wall-layout { display: grid; grid-template-columns: 1.1fr .9fr; gap: 20px; }
.wall-preview { min-height: 360px; padding: 16px; background: var(--navy); color: var(--white); }
.wall-preview-head { display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; border-bottom: 1px solid rgba(255,255,255,.3); }
.wall-preview-head strong { font-size: 18px; }
.wall-preview-head span { color: var(--sand); font-size: 11px; font-weight: 800; }
.wall-control-list { display: grid; gap: 9px; padding-top: 14px; }
.wall-control-row { display: grid; grid-template-columns: 1fr 52px 52px; align-items: center; min-height: 58px; padding-left: 13px; border-left: 4px solid var(--sand); background: #244d5b; }
.wall-control-row strong { font-size: 14px; }
.wall-mini-button { height: 44px; margin-right: 7px; border: 1px solid #8eabb3; background: #173d4b; color: var(--white); font-weight: 800; }
.wall-notes { padding: 18px; border: 1px solid var(--line); background: var(--white); }
.wall-notes h2 { margin: 0 0 13px; font-size: 20px; }
.wall-notes ul { margin: 0; padding-left: 20px; color: var(--ink-soft); font-size: 14px; line-height: 1.6; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.status-card { min-height: 140px; padding: 16px; border: 1px solid var(--line); background: var(--white); }
.status-card h2 { margin: 0 0 11px; font-size: 16px; }
.status-line { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 12px; }
.status-line:first-of-type { border-top: 0; }
.status-value { font-weight: 800; }
.status-value.ok { color: var(--teal); }
.status-value.unavailable { color: var(--unavailable); }
.matrix-summary { grid-column: 1 / -1; min-height: 130px; border-left: 6px solid var(--sand); }
.matrix-summary p { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.state-guide { display: flex; gap: 8px; margin-top: 13px; }
.state-chip { padding: 8px 10px; border: 1px solid var(--line); background: #edf1ee; font-size: 11px; font-weight: 800; }
.state-chip.selected { border-color: var(--teal); background: var(--teal-pale); color: var(--teal-dark); }
.state-chip.applying { border-color: var(--warning); color: var(--warning); }
.state-chip.unavailable { border-color: var(--unavailable); color: var(--unavailable); }
.state-chip.error { border-color: var(--danger); background: var(--danger-pale); color: var(--danger); }

/* Modal, overlay, toast */
.modal-backdrop { position: absolute; z-index: 30; inset: 0; display: grid; place-items: center; background: rgba(10, 28, 34, .68); }
.modal { width: min(720px, calc(100% - 60px)); max-height: calc(100% - 60px); padding: 26px; overflow: auto; border-top: 7px solid var(--sand); background: var(--white); box-shadow: var(--shadow); }
.modal h2 { margin: 0; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.modal p { margin: 10px 0 18px; color: var(--ink-soft); line-height: 1.5; }
.modal .layout-choice-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.modal .layout-choice { min-height: 190px; }
.modal .layout-choice-head { min-height: 54px; padding: 9px; }
.modal .layout-choice-head strong { font-size: 14px; }
.modal .layout-choice-head span, .modal .layout-choice-copy { display: none; }
.modal .mini-plan { height: 94px; margin: 12px 9px; }
.modal .mini-zone { font-size: 23px; }
.modal .mini-zone small { font-size: 7px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--line); }
.secondary-action { min-height: 50px; padding: 0 22px; border: 2px solid var(--teal); background: var(--white); color: var(--teal); font-weight: 800; cursor: pointer; }
.danger-action { min-height: 50px; padding: 0 22px; border: 0; border-left: 5px solid #ef9c91; background: var(--danger); color: var(--white); font-weight: 800; cursor: pointer; }
.applying-overlay { position: absolute; z-index: 40; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(246,244,238,.94); }
.applying-overlay strong { margin-top: 18px; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.applying-overlay span { margin-top: 8px; color: var(--ink-soft); }
.spinner { width: 54px; height: 54px; border: 6px solid var(--teal-pale); border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: absolute; z-index: 50; right: 22px; bottom: 20px; max-width: 450px; padding: 14px 18px; border-left: 5px solid var(--sand); background: var(--navy); color: var(--white); font-size: 14px; box-shadow: var(--shadow); }
.toast.error { border-left-color: #ef9c91; background: var(--danger); }

@media (max-width: 1000px), (max-height: 620px) {
  .app-shell { width: 1280px; height: 720px; transform-origin: top left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
