:root {
  color-scheme: light;
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface-subtle: #f7f8f9;
  --text: #172026;
  --muted: #69757d;
  --line: #dfe4e7;
  --line-strong: #cbd3d8;
  --accent: #176b70;
  --accent-soft: #e3f0ef;
  --success: #1f7a50;
  --warning: #b86418;
  --warning-soft: #fff2e2;
  --danger: #ba3b3b;
  --shadow: 0 18px 48px rgba(21, 31, 38, .12);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Inter, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #0c6f79; outline-offset: 2px; }
.skip-link { position: fixed; top: -5rem; left: 1rem; z-index: 50; padding: 10px 14px; background: var(--text); color: white; }
.skip-link:focus { top: 1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

.app-header { height: 68px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.84); backdrop-filter: blur(12px); position: sticky; top: 0; z-index: 10; }
.header-inner { width: min(1240px, calc(100% - 40px)); height: 100%; margin: auto; display: flex; align-items: center; justify-content: space-between; }
.home-title { display: flex; align-items: baseline; gap: 11px; color: inherit; text-decoration: none; }
.home-title strong { font-size: 18px; letter-spacing: .12em; }
.home-title span { font-size: 12px; color: var(--muted); }
.header-meta { display: flex; align-items: center; gap: 18px; font-size: 12px; color: var(--muted); }
.live-status { display: flex; align-items: center; gap: 7px; }
.live-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.live-status.disconnected i { background: var(--danger); }
.icon-button { width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.icon-button svg { width: 19px; }

.page { width: min(1240px, calc(100% - 40px)); margin: 0 auto 70px; }
.page-heading { padding: 38px 0 23px; display: flex; align-items: end; justify-content: space-between; }
.page-heading p { margin: 0 0 7px; font-size: 12px; color: var(--muted); }
.page-heading h1 { margin: 0; font-size: 32px; line-height: 1.1; letter-spacing: -.04em; }
.page-heading .sync-label { margin-bottom: 3px; }

.status-grid { display: grid; grid-template-columns: 1.15fr repeat(3, 1fr); border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.status-cell { min-height: 116px; padding: 22px 24px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; }
.status-cell:last-child { border-right: 0; }
.status-cell > span { font-size: 12px; color: var(--muted); }
.status-cell > strong { font-size: 27px; line-height: 1; letter-spacing: -.035em; }
.status-cell > strong b { font-weight: 650; }
.status-cell > strong small { font-size: 14px; font-weight: 500; color: var(--muted); }
.status-cell > small { font-size: 11px; color: var(--muted); }
.system-status > div { display: flex; align-items: center; gap: 9px; }
.system-status > div i { width: 10px; height: 10px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 5px rgba(31,122,80,.1); }
.system-status > div strong { font-size: 27px; }
.system-status.warning > div i { background: var(--warning); box-shadow: 0 0 0 5px rgba(184,100,24,.1); }

.workspace { margin-top: 22px; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; align-items: start; }
.devices-panel { min-width: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.domain-tabs { min-height: 58px; padding: 0 18px; display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.domain-tabs button { min-height: 44px; padding: 0 13px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 13px; white-space: nowrap; cursor: pointer; }
.domain-tabs button span { margin-left: 4px; color: var(--muted); font-weight: 600; }
.domain-tabs button.active { color: var(--text); background: #edf1f2; font-weight: 650; }
.section-title { min-height: 86px; padding: 20px 22px 15px; display: flex; align-items: end; justify-content: space-between; }
.label { margin: 0 0 5px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.section-title h2, .side-heading h2, .drawer-head h2 { margin: 0; font-size: 21px; letter-spacing: -.035em; }
.section-title > span { font-size: 12px; color: var(--muted); }

.room-list { padding: 0 12px 12px; }
.room-group { margin-top: 8px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.room-header { height: 42px; padding: 0 14px; display: flex; align-items: center; justify-content: space-between; background: var(--surface-subtle); border-bottom: 1px solid var(--line); }
.room-header h3 { margin: 0; font-size: 13px; font-weight: 700; }
.room-header span { font-size: 11px; color: var(--muted); }
.device-row { min-height: 82px; padding: 12px 14px; display: grid; grid-template-columns: 42px minmax(150px, 1fr) minmax(125px, .7fr) auto; gap: 13px; align-items: center; border-bottom: 1px solid var(--line); transition: background .15s, opacity .15s; }
.device-row:last-child { border-bottom: 0; }
.device-row:hover { background: #fafbfb; }
.device-row.offline { opacity: .62; }
.device-row.pending { cursor: wait; background: linear-gradient(90deg, var(--surface), #f2f7f7, var(--surface)); background-size: 200% 100%; animation: pending 1.2s linear infinite; }
@keyframes pending { to { background-position: -200% 0; } }
.device-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; background: #eef2f3; color: #41545c; }
.device-icon.on { background: var(--accent-soft); color: var(--accent); }
.device-icon.light.on { background: #fff0d6; color: #a65c08; box-shadow: inset 0 0 0 1px rgba(166,92,8,.08); }
.device-icon.smart_plug.on { background: #e8eef8; color: #345f9b; }
.device-icon svg { width: 21px; }
.device-main { min-width: 0; }
.device-main strong { display: block; margin-bottom: 4px; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-main span { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.state-dot { width: 6px; height: 6px; border-radius: 50%; background: #9da6ab; }
.state-dot.on { background: var(--success); }
.state-dot.offline { background: var(--danger); }
.device-reading { text-align: right; }
.device-reading strong { display: block; margin-bottom: 4px; font-size: 19px; }
.device-reading span { font-size: 11px; color: var(--muted); }
.device-actions { display: flex; align-items: center; gap: 8px; }
.power-toggle { min-width: 62px; height: 44px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; }
.power-toggle[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: white; }
.power-toggle:disabled { opacity: .48; cursor: not-allowed; }
.detail-button { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); cursor: pointer; font-size: 18px; }
.empty-state { padding: 70px 24px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); margin-bottom: 6px; }

.side-column { display: grid; gap: 14px; }
.side-card { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.side-heading { margin-bottom: 15px; }
.side-heading-action { display: flex; align-items: end; justify-content: space-between; }
.side-heading-action > div { min-width: 0; }
.text-button { min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: var(--accent); font-size: 11px; font-weight: 650; cursor: pointer; }
.quick-actions > button { width: 100%; min-height: 66px; padding: 10px 0; display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 11px; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.quick-actions > button:hover { color: var(--accent); }
.quick-actions > button > span:nth-child(2) { display: flex; flex-direction: column; gap: 3px; }
.quick-actions > button strong { font-size: 13px; }
.quick-actions > button small { color: var(--muted); font-size: 10px; }
.quick-actions > button b { font-size: 11px; color: var(--muted); }
.action-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; background: #eef2f3; }
.action-icon svg { width: 18px; }
.automation-card { padding-bottom: 16px; }
.automation-count { min-height: 55px; padding: 0 2px; display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.automation-count > div { display: flex; flex-direction: column; gap: 3px; }
.automation-count > div > span { color: var(--muted); font-size: 11px; }
.automation-count > div > small { color: var(--muted); font-size: 9px; }
.automation-count strong { font-size: 12px; }
.automation-count b { margin-right: 3px; color: var(--accent); font-size: 22px; font-weight: 650; }
.activity-head { min-height: 49px; display: flex; align-items: center; justify-content: space-between; }
.activity-head > span { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .05em; }
.activity-head .text-button { color: var(--muted); font-size: 10px; }
.activity-list { display: grid; gap: 10px; }
.activity-item { min-width: 0; display: grid; grid-template-columns: 7px minmax(0, 1fr) auto; align-items: center; gap: 9px; }
.activity-item > i { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.activity-item.failed > i { background: var(--danger); }
.activity-item > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.activity-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.activity-item span, .activity-item time { color: var(--muted); font-size: 9px; }
.activity-item time { white-space: nowrap; }
.muted-state { margin: 0; padding: 12px 0; color: var(--muted); font-size: 10px; }
.alert-card { border-color: #ecd4b9; background: #fffbf6; }
.alert-card.clear { border-color: var(--line); background: var(--surface); }
.alert-item { display: flex; gap: 11px; align-items: start; }
.alert-item + .alert-item { margin-top: 13px; padding-top: 13px; border-top: 1px solid #efdcc7; }
.alert-icon { width: 24px; height: 24px; flex: 0 0 24px; border-radius: 7px; display: grid; place-items: center; background: var(--warning-soft); color: var(--warning); font-weight: 800; font-size: 12px; }
.alert-item div { display: flex; flex-direction: column; gap: 4px; }
.alert-item strong { font-size: 12px; }
.alert-item small { color: var(--muted); font-size: 10px; }
.connector-summary { padding: 16px 18px; border: 1px solid var(--line); border-radius: 14px; display: flex; flex-wrap: wrap; gap: 10px 13px; background: var(--surface); }
.connector-summary span { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; }
.connector-summary i { width: 6px; height: 6px; border-radius: 50%; background: #a2abb0; }
.connector-summary span.ok i { background: var(--success); }
.connector-summary button { margin-left: auto; padding: 0; border: 0; background: transparent; color: var(--accent); font-size: 10px; cursor: pointer; }

.app-footer { width: min(1240px, calc(100% - 40px)); min-height: 64px; margin: 0 auto; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 10px; }
.app-footer div { display: flex; gap: 10px; }
.app-footer strong { color: var(--text); letter-spacing: .08em; }
.app-footer button { border: 0; background: transparent; color: var(--muted); text-decoration: underline; cursor: pointer; }

.status-panel { position: fixed; z-index: 31; right: 0; top: 0; width: min(420px, 94vw); height: 100vh; padding: 28px; background: var(--surface); box-shadow: var(--shadow); transform: translateX(102%); transition: transform .25s ease; }
.status-panel.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: start; justify-content: space-between; margin-bottom: 36px; }
.close { font-size: 24px; }
.connector { min-height: 70px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); }
.connector > i { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.connector.pending > i { background: #a2abb0; }
.connector div { display: flex; flex-direction: column; gap: 4px; }
.connector strong { font-size: 13px; }
.connector span, .connector b { color: var(--muted); font-size: 10px; font-weight: 500; }
.security-note { margin-top: 24px; padding: 15px; display: flex; gap: 11px; border-radius: 11px; background: var(--surface-subtle); }
.security-note svg { width: 18px; flex: 0 0 18px; color: var(--accent); }
.security-note p { margin: 0; display: flex; flex-direction: column; gap: 5px; }
.security-note strong { font-size: 11px; }
.security-note span { color: var(--muted); font-size: 10px; line-height: 1.55; }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(17,27,33,.35); opacity: 0; visibility: hidden; transition: opacity .25s; }
.scrim.open { opacity: 1; visibility: visible; }

dialog { width: min(520px, calc(100% - 28px)); padding: 28px; border: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(17,27,33,.42); }
.dialog-close { position: absolute; top: 20px; right: 20px; font-size: 22px; }
.dialog-kicker { margin: 0 0 6px; color: var(--muted); font-size: 11px; }
#dialogTitle { margin: 0; font-size: 22px; }
.dialog-value { margin: 34px 0 24px; display: flex; align-items: baseline; justify-content: center; }
.dialog-value strong { font-size: 58px; line-height: 1; letter-spacing: -.055em; }
.dialog-value span { margin-left: 6px; color: var(--muted); }
.range-wrap { display: grid; gap: 8px; }
.range-wrap input { width: 100%; accent-color: var(--accent); }
.range-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.range-labels i { font-style: normal; }
.control-group { margin-top: 23px; }
.control-group > span { display: block; margin-bottom: 9px; color: var(--muted); font-size: 10px; font-weight: 650; }
.control-label { margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; }
.control-label span { color: var(--muted); font-size: 10px; font-weight: 650; }
.control-label output { color: var(--text); font-size: 11px; font-weight: 700; }
.light-control input[type="range"] { width: 100%; accent-color: #b86f19; }
.color-control { min-height: 68px; padding: 12px 14px; display: grid; grid-template-columns: 38px minmax(0, 1fr) 48px; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.color-control > span:nth-child(2) { display: flex; flex-direction: column; gap: 3px; }
.color-control strong { font-size: 12px; }
.color-control small { color: var(--muted); font-size: 9px; }
.color-preview { width: 36px; height: 36px; border: 1px solid rgba(23,32,38,.12); border-radius: 50%; background: var(--selected-light-color); box-shadow: 0 0 18px color-mix(in srgb, var(--selected-light-color) 55%, transparent); }
.color-control input[type="color"] { width: 48px; height: 44px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); cursor: pointer; }
.control-note { margin: 12px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.metric-grid { margin-top: 26px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.metric-grid > div { min-height: 78px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface-subtle); }
.metric-grid > div:nth-child(2n) { border-right: 0; }
.metric-grid > div:nth-last-child(-n+2) { border-bottom: 0; }
.metric-grid span { color: var(--muted); font-size: 9px; }
.metric-grid strong { font-size: 16px; font-weight: 650; }
.metric-grid small { color: var(--muted); font-size: 9px; font-weight: 500; }
.segmented { display: flex; gap: 7px; flex-wrap: wrap; }
.segmented button { min-height: 44px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); font-size: 12px; cursor: pointer; }
.segmented button.selected { border-color: var(--accent); background: var(--accent); color: white; }
.developer { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.developer summary { cursor: pointer; color: var(--muted); font-size: 11px; }
.developer .segmented { margin-top: 12px; }
.dialog-meta { margin-top: 24px; padding-top: 15px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; }
.automation-dialog { width: min(720px, calc(100% - 28px)); max-height: min(820px, calc(100vh - 40px)); overflow-y: auto; }
.dialog-heading h2 { margin: 0; font-size: 24px; letter-spacing: -.04em; }
.dialog-heading > p:last-child { margin: 8px 0 0; color: var(--muted); font-size: 11px; }
.automation-tabs { margin-top: 22px; padding: 4px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border-radius: 11px; background: #edf1f2; }
.automation-tabs button { min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 650; cursor: pointer; }
.automation-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(21,31,38,.1); }
.automation-panel[hidden] { display: none; }
.schedule-form { margin-top: 25px; padding: 19px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-subtle); }
.field-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(110px, .8fr) 110px; gap: 10px; }
.field-row label { min-width: 0; display: grid; gap: 7px; }
.field-row label > span, .weekday-field legend { color: var(--muted); font-size: 10px; font-weight: 650; }
.field-row input, .field-row select { width: 100%; height: 44px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); }
.weekday-field { margin: 17px 0 0; padding: 0; border: 0; }
.weekday-field legend { margin-bottom: 8px; }
.weekday-field > div { display: grid; grid-template-columns: repeat(7, 1fr); gap: 7px; }
.weekday-field label { min-width: 0; cursor: pointer; }
.weekday-field input { position: absolute; opacity: 0; pointer-events: none; }
.weekday-field span { height: 44px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--muted); font-size: 11px; }
.weekday-field input:checked + span { border-color: var(--accent); background: var(--accent); color: white; }
.weekday-field input:focus-visible + span { outline: 3px solid #0c6f79; outline-offset: 2px; }
.schedule-submit-row { margin-top: 17px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-label { min-height: 44px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; cursor: pointer; }
.switch-label input { width: 17px; height: 17px; accent-color: var(--accent); }
.primary-button { min-height: 44px; padding: 0 17px; border: 0; border-radius: 9px; background: var(--accent); color: white; font-size: 11px; font-weight: 700; cursor: pointer; }
.primary-button:disabled { opacity: .5; cursor: wait; }
.form-note { margin: 2px 0 0; color: var(--muted); font-size: 9px; }
.schedule-section { margin-top: 26px; }
.schedule-section-head { min-height: 39px; display: flex; align-items: start; justify-content: space-between; border-bottom: 1px solid var(--line); }
.schedule-section-head h3 { margin: 0; font-size: 14px; }
.schedule-section-head span { color: var(--muted); font-size: 10px; }
.schedule-list { display: grid; }
.schedule-empty { padding: 24px 2px; }
.schedule-item { min-height: 69px; display: grid; grid-template-columns: 88px minmax(0, 1fr) auto auto; align-items: center; gap: 13px; border-bottom: 1px solid var(--line); opacity: .6; }
.schedule-item.enabled { opacity: 1; }
.schedule-time, .schedule-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.schedule-time strong { font-size: 17px; }
.schedule-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.schedule-time span, .schedule-copy span { color: var(--muted); font-size: 9px; }
.schedule-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 9px; }
.schedule-switch { position: relative; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; }
.schedule-switch input { position: absolute; opacity: 0; }
.schedule-switch span { position: relative; width: 42px; height: 24px; border-radius: 999px; background: #cbd3d8; transition: .18s; }
.schedule-switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,.18); transition: .18s; }
.schedule-switch input:checked + span { background: var(--accent); }
.schedule-switch input:checked + span::after { transform: translateX(18px); }
.schedule-switch input:focus-visible + span { outline: 3px solid #0c6f79; outline-offset: 2px; }
.schedule-delete { min-height: 44px; padding: 0 4px; border: 0; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.schedule-delete.confirming { color: var(--danger); font-weight: 700; }
.condition-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 10px; }
.condition-grid > label { min-width: 0; display: grid; gap: 7px; }
.condition-grid > label:first-child { grid-column: span 2; }
.condition-grid label > span:first-child { color: var(--muted); font-size: 10px; font-weight: 650; }
.condition-grid input, .condition-grid select { width: 100%; height: 44px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); color: var(--text); }
.unit-input { position: relative; display: block; }
.unit-input input { padding-right: 38px; }
.unit-input b { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 11px; font-weight: 500; pointer-events: none; }
.condition-explainer { margin-top: 16px; padding: 13px 14px; display: flex; flex-direction: column; gap: 4px; border-left: 3px solid var(--accent); border-radius: 4px 9px 9px 4px; background: var(--accent-soft); }
.condition-explainer strong { font-size: 10px; }
.condition-explainer span { color: var(--muted); font-size: 9px; line-height: 1.5; }
.condition-submit-row .form-note { margin: 0; }
.condition-item { min-height: 82px; grid-template-columns: 92px minmax(0, 1fr) auto auto; }
.condition-state { display: flex; flex-direction: column; gap: 3px; }
.condition-state strong { font-size: 11px; }
.condition-state span { color: var(--muted); font-size: 9px; }
.automation-mode-control { padding: 3px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; border-radius: 9px; background: #edf1f2; }
.automation-mode-control button { min-width: 42px; min-height: 38px; padding: 0 8px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 9px; font-weight: 650; cursor: pointer; }
.automation-mode-control button.selected { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(21,31,38,.1); }
.automation-mode-control button[data-mode="observe"].selected { color: var(--accent); }
.automation-mode-control button[data-mode="active"].selected { background: var(--accent); color: white; }
.automation-mode-control button:disabled { opacity: .45; cursor: wait; }
.enable-confirm { grid-column: 1 / -1; margin: 0 0 12px; padding: 12px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; border-radius: 9px; background: var(--warning-soft); }
.enable-confirm[hidden] { display: none; }
.enable-confirm p { margin: 0; display: flex; flex-direction: column; gap: 3px; }
.enable-confirm p strong { font-size: 10px; }
.enable-confirm p span { color: var(--muted); font-size: 9px; }
.enable-confirm button { min-height: 44px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); font-size: 10px; cursor: pointer; }
.enable-confirm .confirm-button { border-color: var(--accent); background: var(--accent); color: white; font-weight: 700; }
.notification-panel { margin-top: 25px; }
.setup-list { display: grid; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.setup-item { min-height: 92px; padding: 18px; display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 14px; border-bottom: 1px solid var(--line); }
.setup-item:last-child { border-bottom: 0; }
.setup-mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .05em; }
.setup-copy { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.setup-copy strong { font-size: 13px; }
.setup-copy span { color: var(--muted); font-size: 10px; line-height: 1.5; }
.setup-actions { display: flex; align-items: center; gap: 8px; }
.secondary-button { min-height: 44px; padding: 0 15px; border: 1px solid var(--accent); border-radius: 9px; background: var(--surface); color: var(--accent); font-size: 10px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.secondary-button:disabled { border-color: var(--line-strong); color: var(--muted); cursor: not-allowed; }
.notification-note { margin-top: 16px; padding: 16px 18px; border-radius: 11px; background: var(--surface-subtle); }
.notification-note strong { font-size: 10px; }
.notification-note p { margin: 7px 0 0; color: var(--muted); font-size: 9px; line-height: 1.65; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 24px; transform: translate(-50%, 15px); padding: 11px 15px; border-radius: 9px; background: var(--text); color: white; font-size: 12px; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .side-column { grid-template-columns: 1fr 1fr; }
  .connector-summary { grid-column: span 2; }
}

@media (max-width: 640px) {
  .app-header { height: 60px; }
  .header-inner, .page, .app-footer { width: calc(100% - 24px); }
  .home-title span, .live-status, .sync-label { display: none; }
  .header-meta { gap: 12px; }
  .page { margin-bottom: 42px; }
  .page-heading { padding: 26px 2px 18px; }
  .page-heading h1 { font-size: 27px; }
  .status-grid { grid-template-columns: 1fr 1fr; }
  .status-cell { min-height: 104px; padding: 17px; border-bottom: 1px solid var(--line); }
  .status-cell:nth-child(2) { border-right: 0; }
  .status-cell:nth-child(3), .status-cell:nth-child(4) { border-bottom: 0; }
  .status-cell > strong, .system-status > div strong { font-size: 23px; }
  .workspace { margin-top: 14px; gap: 14px; }
  .domain-tabs { padding: 0 10px; }
  .section-title { min-height: 76px; padding: 17px 14px 12px; }
  .room-list { padding: 0 7px 7px; }
  .device-row { min-height: 92px; padding: 11px; grid-template-columns: 38px minmax(0, 1fr) 103px; gap: 9px; }
  .device-icon { width: 38px; height: 38px; }
  .device-main, .device-reading { min-width: 0; }
  .device-reading { grid-column: 2; text-align: left; margin-top: -17px; white-space: nowrap; overflow: hidden; }
  .device-reading strong { display: inline; margin-right: 7px; font-size: 14px; }
  .device-reading span { font-size: 10px; }
  .device-actions { width: 103px; grid-column: 3; grid-row: 1 / 3; align-self: center; gap: 5px; }
  .power-toggle { min-width: 54px; }
  .side-column { grid-template-columns: 1fr; }
  .connector-summary { grid-column: auto; }
  .quick-actions { padding: 17px; }
  .automation-card { padding: 17px; }
  .alert-card { padding: 17px; }
  .app-footer { align-items: start; padding: 18px 0; }
  .app-footer div { flex-direction: column; gap: 4px; }
  dialog { padding: 24px 20px; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row > label:first-child { grid-column: span 2; }
  .schedule-form { padding: 15px; }
  .weekday-field > div { gap: 4px; }
  .weekday-field span { height: 44px; }
  .schedule-item { grid-template-columns: 70px minmax(0, 1fr) auto; gap: 9px; }
  .schedule-delete { grid-column: 3; min-height: 44px; margin-top: -12px; }
  .schedule-switch { grid-row: 1; grid-column: 3; margin-bottom: 18px; }
  .condition-grid { grid-template-columns: 1fr; }
  .condition-grid > label:first-child { grid-column: auto; }
  .condition-item { grid-template-columns: 72px minmax(0, 1fr) auto; }
  .condition-item .schedule-copy { grid-column: 2 / 4; }
  .condition-item .schedule-copy span, .condition-item .schedule-copy small { white-space: normal; }
  .condition-item .automation-mode-control { grid-column: 1 / 3; grid-row: 2; justify-self: start; }
  .condition-item .schedule-delete { grid-column: 3; grid-row: 2; margin: 0; }
  .enable-confirm { grid-template-columns: 1fr 1fr; }
  .enable-confirm p { grid-column: span 2; }
  .setup-item { grid-template-columns: 40px minmax(0, 1fr); }
  .setup-item > .secondary-button, .setup-actions { grid-column: 2; justify-self: start; }
}

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