:root {
  color-scheme: light;
  --bg: #edf5fb;
  --ink: #15223a;
  --muted: #66748a;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: #ffffff;
  --line: rgba(92, 123, 153, 0.2);
  --blue: #0a84ff;
  --blue-soft: rgba(10, 132, 255, 0.1);
  --green: #30b866;
  --green-soft: rgba(48, 184, 102, 0.11);
  --orange: #e58a00;
  --orange-soft: rgba(229, 138, 0, 0.11);
  --red: #e5484d;
  --red-soft: rgba(229, 72, 77, 0.1);
  --purple: #7656d8;
  --shadow: 0 12px 32px rgba(48, 78, 112, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

button:hover:not(:disabled) {
  border-color: rgba(10, 132, 255, 0.45);
  box-shadow: 0 6px 16px rgba(48, 78, 112, 0.1);
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(10, 132, 255, 0.28);
  outline-offset: 2px;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

h1,
h2,
p {
  margin: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: min(1480px, calc(100% - 32px));
  min-height: 104px;
  margin: 16px auto 0;
  padding: 18px 20px;
  gap: 24px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(135%);
  -webkit-backdrop-filter: blur(16px) saturate(135%);
}

.brand-lockup {
  min-width: 0;
}

h1 {
  max-width: 760px;
  overflow-wrap: anywhere;
  font-size: 30px;
  font-weight: 850;
  line-height: 1.08;
}

h2 {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
}

.status-pill,
.small-tag,
.mode-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  line-height: 1.2;
  white-space: nowrap;
}

.status-pill[data-status="ok"],
.small-tag[data-status="ok"] {
  border-color: rgba(48, 184, 102, 0.28);
  background: var(--green-soft);
  color: #17743e;
}

.status-pill[data-status="offline"],
.small-tag[data-status="offline"] {
  border-color: rgba(229, 72, 77, 0.28);
  background: var(--red-soft);
  color: #a5282d;
}

.status-pill[data-status="idle"] {
  border-color: rgba(229, 138, 0, 0.28);
  background: var(--orange-soft);
  color: #8a5300;
}

.mode-chip[data-status="active"] {
  border-color: rgba(10, 132, 255, 0.28);
  background: var(--blue-soft);
  color: #075fac;
}

.console-grid {
  width: min(1480px, calc(100% - 32px));
  margin: 12px auto 0;
  padding-bottom: 28px;
}

.dashboard-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.85fr);
  gap: 12px;
  align-items: start;
}

.dashboard-left,
.student-console {
  display: grid;
  gap: 12px;
  min-width: 0;
  align-content: start;
}

.student-console-title {
  padding: 4px 2px 0;
  color: #075fac;
}

.student-console-title p {
  font-size: 21px;
  font-weight: 850;
  line-height: 1.1;
}

.student-console-title strong {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  letter-spacing: 0;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(130%);
  -webkit-backdrop-filter: blur(14px) saturate(130%);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head > div {
  min-width: 0;
}

.connection-panel,
.controls-panel,
.voice-panel,
.sensor-panel,
.display-panel,
.actuator-panel,
.event-panel {
  padding-bottom: 14px;
}

.event-panel {
  margin-top: 12px;
}

.button-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  gap: 8px;
  padding: 14px 16px;
}

.primary-action {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  font-weight: 800;
}

.primary-action:hover:not(:disabled) {
  border-color: #0075e6;
  background: #0075e6;
}

.secondary-action {
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-weight: 740;
}

.secondary-action.compact {
  min-height: 32px;
  padding: 4px 10px;
}

.mini-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0 16px;
}

.mini-list div {
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.mini-list dt,
.energy-summary dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 730;
}

.mini-list dd {
  margin: 0;
  overflow: hidden;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notice {
  margin: 14px 16px 0;
  padding: 10px;
  border: 1px solid rgba(10, 132, 255, 0.2);
  border-radius: 8px;
  background: var(--blue-soft);
  color: #075fac;
  font-size: 12px;
  line-height: 1.45;
}

.notice[data-status="offline"] {
  border-color: rgba(229, 72, 77, 0.24);
  background: var(--red-soft);
  color: #a5282d;
}

.house-map {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  grid-template-rows: 190px 122px;
  gap: 8px;
  padding: 16px;
  background: rgba(227, 240, 250, 0.62);
}

.room {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.room span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.room strong {
  overflow-wrap: anywhere;
  font-size: 20px;
  font-weight: 820;
  line-height: 1.15;
}

.room-study {
  border-left-color: var(--blue);
}

.room-living {
  border-left-color: var(--orange);
}

.room-entry {
  grid-column: 1 / -1;
  border-left-color: var(--green);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  padding: 14px 16px;
}

.mode-grid button {
  min-width: 0;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.mode-grid button[data-active="true"] {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
  box-shadow: 0 6px 16px rgba(10, 132, 255, 0.2);
}

.mode-grid button[data-mode="energy"][data-active="true"] {
  border-color: var(--green);
  background: var(--green);
  box-shadow: 0 6px 16px rgba(48, 184, 102, 0.2);
}

.threshold-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px;
}

.threshold-form label,
.voice-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.threshold-form input,
.voice-form input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
}

.threshold-form button {
  grid-column: 1 / -1;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 8px;
  padding: 16px;
}

.metric {
  min-width: 0;
  min-height: 106px;
  padding: 12px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--blue);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.metric-temperature {
  border-top-color: var(--orange);
}

.metric-humidity,
.metric-pir,
.metric-lamp {
  border-top-color: var(--green);
}

.metric-sound,
.metric-buzzer {
  border-top-color: var(--purple);
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 730;
}

.metric strong {
  display: block;
  min-height: 31px;
  margin: 10px 0 8px;
  overflow-wrap: anywhere;
  font-size: 28px;
  font-weight: 850;
  line-height: 1.05;
}

.actuator-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.actuator-grid .metric strong {
  font-size: 24px;
}

.energy-summary {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0 16px 14px;
}

.energy-summary div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
}

.energy-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: #17743e;
  font-size: 14px;
  font-weight: 780;
  line-height: 1.45;
}

.actuator-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 16px;
}

.voice-quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 14px 16px 0;
}

.voice-quick-grid button {
  min-width: 0;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
}

.voice-form {
  display: grid;
  gap: 9px;
  padding: 12px 16px 0;
}

.voice-result {
  min-height: 42px;
  margin: 12px 16px 0;
  padding: 10px;
  border: 1px solid rgba(10, 132, 255, 0.2);
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.oled-screen {
  display: grid;
  gap: 4px;
  min-height: 162px;
  margin: 12px 16px 0;
  padding: 14px;
  border: 1px solid #1b2830;
  border-radius: 8px;
  background: #071116;
  color: #b8f7d4;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.25;
  box-shadow: inset 0 0 0 1px rgba(184, 247, 212, 0.08);
}

.oled-screen span {
  min-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-log {
  display: grid;
  gap: 7px;
  max-height: 360px;
  margin: 0;
  padding: 14px 16px 0;
  overflow: auto;
  list-style: none;
}

.event-log li {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 36px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}

.event-log time {
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.event-log span {
  overflow-wrap: anywhere;
}

.log-error {
  border-color: rgba(229, 72, 77, 0.25) !important;
  background: var(--red-soft) !important;
}

.log-ack {
  border-color: rgba(48, 184, 102, 0.25) !important;
  background: var(--green-soft) !important;
}

.log-command {
  border-color: rgba(10, 132, 255, 0.22) !important;
  background: var(--blue-soft) !important;
}

.muted-log {
  color: var(--muted);
}

.alert-notice {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  margin: 12px 16px 0;
  padding: 12px;
  border: 1px solid rgba(10, 132, 255, 0.2);
  border-radius: 8px;
  background: rgba(10, 132, 255, 0.06);
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.alert-notice.is-normal {
  border-color: rgba(48, 184, 102, 0.24);
  background: var(--green-soft);
}

.alert-notice.is-reminder {
  border-color: rgba(229, 138, 0, 0.32);
  background: var(--orange-soft);
  box-shadow: 0 10px 24px rgba(229, 138, 0, 0.08);
}

.alert-notice.is-alarm {
  border-color: rgba(229, 72, 77, 0.4);
  background: var(--red-soft);
  box-shadow: 0 12px 28px rgba(229, 72, 77, 0.12);
}

.alert-notice-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(10, 132, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--blue);
}

.alert-notice.is-normal .alert-notice-icon {
  border-color: rgba(48, 184, 102, 0.25);
  color: #18804a;
}

.alert-notice.is-reminder .alert-notice-icon {
  border-color: rgba(229, 138, 0, 0.3);
  color: var(--orange);
}

.alert-notice.is-alarm .alert-notice-icon {
  border-color: rgba(229, 72, 77, 0.32);
  color: var(--red);
  animation: alertIconPulse 1.2s ease-in-out infinite;
}

.alert-notice-icon svg,
.sensor-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.alert-notice-copy {
  min-width: 0;
}

.alert-notice-copy > span,
.alert-notice-copy > strong,
.alert-notice-copy > p {
  display: block;
}

.alert-notice-copy > span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
}

.alert-notice-copy > strong {
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 17px;
  line-height: 1.2;
}

.alert-notice.is-reminder .alert-notice-copy > strong {
  color: #8a5300;
}

.alert-notice.is-alarm .alert-notice-copy > strong {
  color: #a5282d;
}

.alert-notice-copy > p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.alert-notice-items {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 9px;
}

.alert-reason-item {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(229, 138, 0, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
}

.alert-reason-item.is-alarm {
  border-color: rgba(229, 72, 77, 0.24);
}

.alert-reason-dot {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(229, 138, 0, 0.1);
}

.alert-reason-item.is-alarm .alert-reason-dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.1);
}

.alert-reason-item strong,
.alert-reason-item p,
.alert-reason-item small {
  display: block;
  overflow-wrap: anywhere;
}

.alert-reason-item strong {
  color: #8a5300;
  font-size: 12px;
  line-height: 1.25;
}

.alert-reason-item.is-alarm strong {
  color: #a5282d;
}

.alert-reason-item p {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 11px;
  line-height: 1.45;
}

.alert-reason-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
}

.alert-notice-actions {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.alert-notice-actions p {
  margin: 0;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--ink);
  font-size: 11px;
  font-weight: 760;
  line-height: 1.4;
}

.sensor-card {
  position: relative;
  min-height: 150px;
  transition:
    border-color 180ms ease,
    background-color 180ms ease,
    box-shadow 180ms ease;
}

.sensor-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 7px;
}

.sensor-card .sensor-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border: 1px solid rgba(92, 123, 153, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  color: #55748f;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.sensor-card .sensor-state-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  max-width: 92px;
  padding: 4px 7px;
  border-radius: 8px;
  background: rgba(102, 116, 138, 0.09);
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  line-height: 1.15;
  text-align: center;
}

.sensor-card .sensor-card-label {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.sensor-card.is-mode-active {
  border-color: rgba(10, 132, 255, 0.38);
  border-top-color: var(--blue);
  background: rgba(10, 132, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(10, 132, 255, 0.08), 0 10px 22px rgba(10, 132, 255, 0.08);
}

.sensor-card.is-mode-active .sensor-icon {
  border-color: rgba(10, 132, 255, 0.3);
  background: rgba(10, 132, 255, 0.13);
  color: #0876df;
  box-shadow: 0 0 0 5px rgba(10, 132, 255, 0.06);
}

.sensor-card.is-mode-active .sensor-state-badge {
  background: rgba(10, 132, 255, 0.12);
  color: #075fac;
}

.sensor-card.is-mode-flash .sensor-icon {
  animation: modeSensorFlash 680ms ease-in-out infinite;
}

.sensor-card.is-reminder {
  border-color: rgba(229, 138, 0, 0.45);
  border-top-color: var(--orange);
  background: rgba(229, 138, 0, 0.09);
  box-shadow: inset 0 0 0 1px rgba(229, 138, 0, 0.08), 0 12px 24px rgba(229, 138, 0, 0.1);
}

.sensor-card.is-reminder .sensor-icon {
  border-color: rgba(229, 138, 0, 0.34);
  background: rgba(229, 138, 0, 0.14);
  color: var(--orange);
}

.sensor-card.is-reminder .sensor-state-badge {
  background: rgba(229, 138, 0, 0.14);
  color: #8a5300;
}

.sensor-card.is-reminder > strong {
  color: #8a5300;
}

.sensor-card.is-alarm {
  border-color: rgba(229, 72, 77, 0.5);
  border-top-color: var(--red);
  background: rgba(229, 72, 77, 0.09);
  box-shadow: inset 0 0 0 1px rgba(229, 72, 77, 0.1), 0 14px 28px rgba(229, 72, 77, 0.12);
}

.sensor-card.is-alarm .sensor-icon {
  border-color: rgba(229, 72, 77, 0.36);
  background: rgba(229, 72, 77, 0.14);
  color: var(--red);
  animation: sensorAlarmPulse 1.1s ease-in-out infinite;
}

.sensor-card.is-alarm .sensor-state-badge {
  background: rgba(229, 72, 77, 0.14);
  color: #a5282d;
}

.sensor-card.is-alarm > strong {
  color: #a5282d;
}

@keyframes modeSensorFlash {
  0%,
  100% {
    opacity: 0.76;
    transform: scale(0.96);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.05);
  }
  50% {
    opacity: 1;
    transform: scale(1.07);
    box-shadow: 0 0 0 9px rgba(10, 132, 255, 0.13), 0 10px 20px rgba(10, 132, 255, 0.18);
  }
}

@keyframes sensorAlarmPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.07);
  }
  50% {
    transform: scale(1.07);
    box-shadow: 0 0 0 9px rgba(229, 72, 77, 0.14);
  }
}

@keyframes alertIconPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

@media (max-width: 1080px) {
  .dashboard-columns {
    grid-template-columns: minmax(0, 1.3fr) minmax(310px, 0.9fr);
  }

  .threshold-form {
    grid-template-columns: 1fr;
  }

  .threshold-form button {
    grid-column: auto;
  }

  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    width: min(100% - 20px, 1480px);
    min-height: 0;
    margin-top: 10px;
    padding: 16px;
    gap: 14px;
  }

  h1 {
    font-size: 25px;
  }

  .status-row {
    justify-content: flex-start;
    width: 100%;
  }

  .status-pill,
  .mode-chip {
    flex: 1 1 128px;
    white-space: normal;
    text-align: center;
  }

  .console-grid {
    display: flex;
    flex-direction: column;
    width: min(100% - 20px, 1480px);
    margin-top: 10px;
  }

  .dashboard-columns,
  .dashboard-left,
  .student-console {
    display: contents;
  }

  .student-console-title {
    order: 0;
    padding: 4px 2px 0;
  }

  .connection-panel {
    order: 1;
  }

  .controls-panel {
    order: 2;
  }

  .sensor-panel {
    order: 3;
  }

  .actuator-panel {
    order: 4;
  }

  .house-panel {
    order: 5;
  }

  .voice-panel {
    order: 6;
  }

  .display-panel {
    order: 7;
  }

  .event-panel {
    order: 8;
  }

  .panel,
  .event-panel {
    margin-top: 10px;
  }

  .student-console-title + .panel {
    margin-top: 0;
  }

  .house-map {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(3, minmax(116px, auto));
  }

  .room-entry {
    grid-column: auto;
  }

  .room strong {
    font-size: 18px;
  }

  .sensor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-pir {
    grid-column: 1 / -1;
  }

  .metric strong,
  .actuator-grid .metric strong {
    font-size: 23px;
  }

  .button-row {
    grid-template-columns: minmax(0, 1fr) 84px;
  }

  .mode-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .threshold-form {
    grid-template-columns: 1fr;
  }

  .event-log li {
    grid-template-columns: 1fr;
  }

  .alert-notice-items {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 400px) {
  .sensor-grid,
  .actuator-grid,
  .voice-quick-grid,
  .actuator-actions {
    grid-template-columns: 1fr;
  }

  .metric-pir {
    grid-column: auto;
  }

  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .button-row {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  button,
  .alert-notice,
  .sensor-card {
    transition: none;
  }

  .alert-notice.is-alarm .alert-notice-icon,
  .sensor-card.is-mode-flash .sensor-icon,
  .sensor-card.is-alarm .sensor-icon {
    animation: none;
  }
}
