:root {
  color-scheme: light;
  --ink: #10213a; --muted: #66758b; --canvas: #edf2f8;
  --surface: rgba(255, 255, 255, .88); --line: #dce4ee; --line-strong: #cbd6e4;
  --navy: #071627; --brand: #16a883; --brand-dark: #08775f;
  --blue: #3468ee; --amber: #df8a2b; --danger: #c23c4c;
  --shadow: 0 18px 42px rgba(24, 45, 72, .10);
  --shadow-soft: 0 8px 24px rgba(24, 45, 72, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html { min-width: 320px; }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  background: radial-gradient(circle at 76% -10%, rgba(52,104,238,.14), transparent 30rem), radial-gradient(circle at 42% 18%, rgba(22,168,131,.10), transparent 26rem), var(--canvas);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(52,104,238,.24); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 3.3vw, 3.25rem); line-height: 1; letter-spacing: -.045em; }
h2 { font-size: 1.08rem; letter-spacing: -.01em; }
h3 { font-size: 1rem; }

.app-shell { display: grid; grid-template-columns: 258px minmax(0,1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; z-index: 20; display: flex; flex-direction: column; gap: 26px;
  height: 100vh; padding: 24px 18px; color: #fff; overflow: hidden;
  background: radial-gradient(circle at 20% 0, rgba(37,212,164,.21), transparent 16rem), linear-gradient(165deg, #0d2437 0%, var(--navy) 52%, #081320 100%);
  border-right: 1px solid rgba(255,255,255,.08);
}
.sidebar::after { content: ""; position: absolute; right: -90px; bottom: 8%; width: 210px; height: 210px; border: 1px solid rgba(103,232,197,.10); border-radius: 50%; box-shadow: 0 0 0 32px rgba(103,232,197,.025), 0 0 0 64px rgba(103,232,197,.02); pointer-events: none; }
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 5px; position: relative; z-index: 1; }
.brand-mark { display: grid; place-items: center; flex: 0 0 auto; width: 44px; height: 44px; border-radius: 14px; overflow: hidden; box-shadow: 0 14px 34px rgba(22,168,131,.28), 0 0 0 1px rgba(143,248,216,.13); }
.brand-mark img { display: block; width: 100%; height: 100%; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 1rem; letter-spacing: -.01em; }
.brand span { margin-top: 3px; color: #91a8bb; font-size: .76rem; }
.mobile-auth-button { display: none; }
.nav-list, .provider-list { display: grid; gap: 7px; position: relative; z-index: 1; }
.nav-item, .provider-pill { width: 100%; min-height: 46px; border: 1px solid transparent; border-radius: 13px; padding: 0 12px; color: #aebdca; background: transparent; text-align: left; font-weight: 750; transition: color .16s, background .16s, border-color .16s, transform .16s; }
.nav-item { display: flex; align-items: center; gap: 12px; }
.nav-item::before { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; color: #83a0b5; background: rgba(255,255,255,.055); font-size: .9rem; line-height: 1; }
.nav-item[data-view="dashboard"]::before { content: "⌂"; }
.nav-item[data-view="devices"]::before { content: "▦"; }
.nav-item[data-view="scenes"]::before { content: "✦"; }
.nav-item[data-view="schedules"]::before { content: "◷"; }
.nav-item[data-view="accounts"]::before { content: "◎"; }
.nav-item[data-view="security"]::before { content: "⌾"; }
.nav-item:hover, .provider-pill:hover { color: #fff; background: rgba(255,255,255,.065); transform: translateX(2px); }
.nav-item.is-active { color: #fff; border-color: rgba(118,240,207,.16); background: linear-gradient(100deg, rgba(41,202,159,.20), rgba(255,255,255,.06)); box-shadow: inset 3px 0 #64edc7; }
.nav-item.is-active::before { color: #06251d; background: #69e9c5; }
.provider-strip { margin-top: auto; min-width: 0; position: relative; z-index: 1; }
.section-title { margin: 0 6px 9px; color: #70879a; font-size: .7rem; font-weight: 850; text-transform: uppercase; letter-spacing: .14em; }
.provider-pill { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-block: 7px; }
.provider-pill.is-active { color: #fff; border-color: rgba(255,255,255,.1); background: rgba(255,255,255,.09); }
.provider-pill strong { display: grid; place-items: center; min-width: 25px; height: 24px; padding: 0 6px; border-radius: 99px; color: #bdd0dc; background: rgba(255,255,255,.08); font-size: .7rem; }
.all-provider-label { display: inline-flex; align-items: center; gap: 10px; }
.provider-dot { width: 9px; height: 9px; border: 2px solid rgba(255,255,255,.28); border-radius: 50%; background: #62e9c3; box-shadow: 0 0 0 4px rgba(98,233,195,.09); }

.provider-logo { display: inline-flex; align-items: center; gap: 9px; min-width: 0; min-height: 30px; }
.provider-mark { display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 32px; padding: 6px; overflow: hidden; border: 1px solid rgba(16,33,58,.08); border-radius: 10px; color: var(--ink); background: #fff; box-shadow: 0 4px 10px rgba(9,28,48,.08); font-size: .68rem; font-weight: 900; }
.provider-mark img { display: block; width: 100%; height: 100%; object-fit: contain; }
.provider-logo.ezviz .provider-mark, .provider-logo.ewelink .provider-mark, .provider-logo.tapo .provider-mark { width: 46px; }
.provider-word { min-width: 0; overflow: hidden; color: inherit; font-size: .77rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }

.workspace { min-width: 0; width: 100%; max-width: 1540px; margin: 0 auto; padding: 28px 32px 48px; }
.topbar, .toolbar, .panel-head, .device-card-head, .scene-card-head, .dialog-head, .scene-row, .device-row, .account-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar { min-height: 94px; margin-bottom: 14px; }
.eyebrow { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; color: var(--brand-dark); font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .13em; }
.eyebrow-dot { width: 7px; height: 7px; border-radius: 50%; background: #18b488; box-shadow: 0 0 0 5px rgba(24,180,136,.12); }
.view-summary { margin-top: 8px; color: var(--muted); font-size: .86rem; }
.topbar-actions, .toolbar-actions, .row-actions, .dialog-actions, .account-actions { display: flex; align-items: center; gap: 9px; }
.primary-button, .secondary-button, .ghost-button, .icon-button, .toggle, .segmented button { min-height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 0 15px; color: var(--ink); background: #fff; font-weight: 800; transition: transform .15s, box-shadow .15s, border-color .15s, background .15s; }
.primary-button:hover, .secondary-button:hover, .ghost-button:hover, .icon-button:hover, .toggle:hover, .segmented button:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.primary-button { border-color: transparent; color: #fff; background: linear-gradient(135deg, #168f72, #3471eb); box-shadow: 0 10px 24px rgba(24,115,145,.22); }
.secondary-button { border-color: #cddbf4; color: #2456bc; background: #eff4ff; }
.ghost-button { background: rgba(255,255,255,.7); }
.danger-button { color: var(--danger); }
.icon-button { display: grid; place-items: center; width: 44px; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .46; transform: none !important; box-shadow: none !important; }

.status-banner { position: relative; min-height: 48px; margin-bottom: 16px; padding: 13px 16px 13px 44px; overflow: hidden; border: 1px solid rgba(16,148,112,.18); border-radius: 14px; color: #146249; background: linear-gradient(100deg, rgba(232,250,244,.96), rgba(239,245,255,.9)); box-shadow: 0 6px 20px rgba(30,79,72,.055); font-size: .82rem; font-weight: 760; line-height: 1.55; }
.status-banner::before { content: ""; position: absolute; left: 18px; top: 18px; width: 10px; height: 10px; border-radius: 50%; background: #20bf8e; box-shadow: 0 0 0 5px rgba(32,191,142,.13); }
.view { display: none; }
.view.is-visible { display: block; animation: enter .24s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.metric-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 12px; margin-bottom: 15px; }
.metric, .panel, .device-card, .scene-card, .account-card, .scene-editor, .security-card { border: 1px solid rgba(255,255,255,.82); border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.metric { position: relative; min-height: 126px; padding: 20px; overflow: hidden; }
.metric::before { content: ""; position: absolute; inset: auto -34px -56px auto; width: 112px; height: 112px; border-radius: 50%; background: linear-gradient(145deg, rgba(37,211,163,.20), rgba(52,104,238,.10)); }
.metric::after { content: ""; position: absolute; right: 18px; top: 18px; width: 32px; height: 4px; border-radius: 99px; background: linear-gradient(90deg,#30d1a4,#4478ef); }
.metric span { display: block; color: var(--muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.metric strong { display: block; margin-top: 17px; font-size: 2.35rem; line-height: .9; letter-spacing: -.05em; }
.panel-grid { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(300px,.75fr); gap: 15px; }
.panel { padding: 18px; }
.panel-head { min-height: 40px; }
.device-list, .scene-list, .channel-list, .account-list, .scene-grid { display: grid; gap: 9px; margin-top: 14px; }

.device-row, .scene-row { position: relative; min-height: 70px; padding: 11px 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.74); }
.device-row::before, .device-card::before { content: ""; position: absolute; inset: 12px auto 12px 0; width: 4px; border-radius: 0 6px 6px 0; background: var(--brand); }
.device-row.motor::before, .device-card.motor::before { background: var(--blue); }
.device-row.plug::before, .device-card.plug::before { background: var(--amber); }
.device-title, .scene-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.device-title > div { min-width: 0; }
.device-title strong, .device-title h3 { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-title > div > span { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-glyph, .scene-glyph { display: grid; place-items: center; flex: 0 0 auto; width: 42px; height: 42px; border: 1px solid rgba(22,168,131,.13); border-radius: 13px; color: var(--brand-dark); background: #e8f8f3; font-weight: 950; box-shadow: inset 0 1px #fff; }
.device-card.motor .device-glyph, .device-row.motor .device-glyph { border-color: rgba(52,104,238,.12); color: #2858c8; background: #edf2ff; }
.device-card.plug .device-glyph, .device-row.plug .device-glyph { border-color: rgba(223,138,43,.14); color: #a55b0e; background: #fff4e5; }
.scene-glyph { width: 38px; height: 38px; color: #5c44c9; background: #f1edff; }
.device-row span, .scene-row span, .device-card p, .account-card p, .channel-row span { color: var(--muted); font-size: .78rem; }
.state-chip, .provider-tag, .adapter-stage { display: inline-flex; align-items: center; justify-content: center; min-height: 28px; padding: 0 10px; border-radius: 99px; font-size: .7rem; font-weight: 900; white-space: nowrap; }
.state-chip::before { content: ""; width: 6px; height: 6px; margin-right: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.state-chip.online { color: #087154; background: #e5f8f1; }
.state-chip.offline { color: #66758b; background: #edf1f5; }
.provider-tag { margin-bottom: 8px; color: #344054; background: #edf2f7; }
.adapter-stage { color: #2858bd; background: #edf3ff; }
.quick-row-actions { flex-wrap: wrap; justify-content: flex-end; }
.quick-channel-control { display: inline-flex; align-items: center; gap: 7px; }
.quick-channel-control > span { color: var(--muted); font-size: .7rem; font-weight: 850; }
.control-cluster { display: inline-flex; align-items: center; justify-content: flex-end; gap: 7px; }
.automation-trigger { min-height: 40px; border: 1px solid #ccd9ed; border-radius: 11px; padding: 0 11px; color: #315aa8; background: #f2f6ff; font-weight: 850; }
.automation-trigger:hover { border-color: #9db4dd; background: #eaf1ff; }
.toggle { min-width: 72px; background: #f2f5f8; }
.toggle.is-on { border-color: transparent; color: #fff; background: linear-gradient(135deg,#128264,#20b887); }
.toggle.is-pending, .segmented.is-pending button { cursor: progress; opacity: .68; }
.segmented { display: inline-grid; grid-template-columns: repeat(3,minmax(56px,1fr)); overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.segmented button { min-width: 58px; border: 0; border-radius: 0; padding: 0 10px; background: transparent; }
.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.is-active { color: #2254bb; background: #edf3ff; }

.toolbar { min-height: 70px; margin-bottom: 15px; padding: 12px 14px 12px 18px; border: 1px solid rgba(255,255,255,.82); border-radius: 17px; background: rgba(255,255,255,.72); box-shadow: var(--shadow-soft); backdrop-filter: blur(16px); }
.toolbar input, select, input { min-height: 44px; border: 1px solid var(--line-strong); border-radius: 12px; padding: 0 13px; color: var(--ink); background: rgba(255,255,255,.95); outline: 0; }
.toolbar input:focus, select:focus, input:focus { border-color: rgba(52,104,238,.58); box-shadow: 0 0 0 4px rgba(52,104,238,.10); }
.toolbar input { width: min(380px,44vw); }
.device-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.device-card, .scene-card, .account-card { position: relative; overflow: hidden; padding: 16px; transition: transform .16s, box-shadow .16s; }
.device-card { padding-left: 19px; }
.device-card:hover, .scene-card:hover, .account-card:hover { transform: translateY(-2px); box-shadow: 0 24px 54px rgba(24,45,72,.14); }
.device-card .provider-logo { margin-bottom: 5px; }
.device-card .provider-mark { width: 31px; height: 27px; padding: 5px; border-radius: 8px; }
.device-card .provider-logo.ezviz .provider-mark, .device-card .provider-logo.ewelink .provider-mark, .device-card .provider-logo.tapo .provider-mark { width: 40px; }
.device-meta { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 4px; }
.device-meta span { padding: 5px 9px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: rgba(255,255,255,.68); font-size: .68rem; font-weight: 800; }
.channel-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 64px; padding: 10px 0; border-top: 1px solid var(--line); }
.channel-row strong, .channel-row span { display: block; }
.channel-row span { margin-top: 3px; }
.scene-grid { grid-template-columns: repeat(auto-fit,minmax(280px,1fr)); }
.scene-card ul { margin: 14px 0 0; padding-left: 18px; color: var(--muted); font-size: .84rem; line-height: 1.55; }
.scene-card li + li { margin-top: 7px; }
.scene-editor { margin-bottom: 15px; padding: 16px; }
.scene-form { display: grid; grid-template-columns: repeat(auto-fit,minmax(155px,1fr)); gap: 11px; align-items: end; }
.scene-workspace { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(310px,.8fr); gap: 14px; align-items: start; }
.scene-workspace .scene-grid { margin-top: 0; }
.automation-panel { padding: 16px; }
.automation-list { display: grid; gap: 9px; margin-top: 14px; }
.automation-row { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.72); }
.automation-status { display: inline-block; margin-left: 8px; color: var(--brand-dark); font-size: .7rem; font-style: normal; font-weight: 850; }
.toolbar-note { margin-top: 5px; color: var(--muted); font-size: .8rem; }
.automation-time { min-width: 76px; padding-right: 11px; border-right: 1px solid var(--line); }
.automation-time strong, .automation-time span, .automation-copy strong, .automation-copy span { display: block; }
.automation-time strong { font-size: .74rem; }
.automation-time span, .automation-copy span { margin-top: 3px; color: var(--muted); font-size: .69rem; }
.automation-copy { min-width: 0; }
.automation-copy strong { overflow: hidden; font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.label-note { color: var(--muted); font-size: .68rem; font-weight: 700; }
.account-card { min-height: 118px; }
.account-card > div:first-child { min-width: 260px; }
.account-card h3 { margin-top: 7px; }
.account-card p { margin-top: 4px; line-height: 1.45; }
.account-status-text { max-width: 520px; }
.account-actions { flex-wrap: wrap; justify-content: flex-end; }
.inline-code-field { display: grid; gap: 4px; color: var(--muted); font-size: .7rem; font-weight: 850; }
.inline-code-field input { width: 118px; min-height: 38px; }
.security-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(230px,1fr)); gap: 14px; }
.security-card { min-height: 164px; padding: 20px; }
.security-card span, .security-card p { color: var(--muted); }
.security-card strong { display: block; margin: 12px 0 8px; font-size: 1.08rem; }
.security-card p { font-size: .82rem; line-height: 1.5; }
label { display: grid; gap: 6px; color: #344054; font-size: .78rem; font-weight: 850; }
.dialog { width: min(570px,calc(100vw - 28px)); max-height: calc(100dvh - 28px); border: 0; border-radius: 20px; padding: 0; box-shadow: 0 34px 90px rgba(7,22,39,.32); }
.dialog::backdrop { background: rgba(3,12,22,.56); backdrop-filter: blur(7px); }
.dialog form { display: grid; min-width: 0; gap: 14px; padding: 20px; background: #fff; }
.dialog input, .dialog select, .dialog button { min-width: 0; }
.instructions { padding: 12px 13px; border: 1px solid #cbdaf6; border-radius: 13px; color: #2853a6; background: #eff4ff; font-size: .78rem; line-height: 1.5; }
.empty-state { padding: 32px 20px; border: 1px dashed var(--line-strong); border-radius: 15px; color: var(--muted); background: rgba(255,255,255,.48); text-align: center; font-size: .86rem; line-height: 1.5; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 224px minmax(0,1fr); }
  .workspace { padding-inline: 22px; }
  .panel-grid, .device-grid, .scene-workspace { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  body { background: linear-gradient(180deg,#f8fafc,#edf2f8); }
  .app-shell { display: block; min-height: 100dvh; }
  .sidebar { position: sticky; top: 0; z-index: 30; display: block; height: auto; padding: 10px 12px 9px; overflow: visible; border: 0; background: #071627; }
  .sidebar::after { display: none; }
  .brand { padding: 0 2px 8px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; font-size: 1rem; }
  .brand span { display: none; }
  .brand strong { font-size: .95rem; }
  .mobile-auth-button { display: inline-flex; align-items: center; justify-content: center; margin-left: auto; min-height: 38px; border: 1px solid rgba(111,241,204,.34); border-radius: 11px; padding: 0 13px; color: #071627; background: #6ff1cc; font-size: .78rem; font-weight: 900; box-shadow: 0 8px 20px rgba(22,168,131,.22); }
  .provider-strip { margin: 0; }
  .provider-strip .section-title { display: none; }
  .provider-list { display: flex; gap: 7px; overflow-x: auto; padding: 0 0 2px; scrollbar-width: none; scroll-snap-type: x proximity; }
  .provider-list::-webkit-scrollbar { display: none; }
  .provider-pill { flex: 0 0 auto; width: auto; min-height: 39px; padding: 3px 8px; border-radius: 11px; scroll-snap-align: start; }
  .provider-pill:hover { transform: none; }
  .provider-pill strong { min-width: 22px; height: 21px; }
  .provider-pill .provider-word { display: none; }
  .provider-pill .provider-logo { min-height: 28px; }
  .provider-pill .provider-mark { width: 32px; height: 28px; border-radius: 8px; padding: 5px; }
  .provider-pill .provider-logo.ezviz .provider-mark, .provider-pill .provider-logo.ewelink .provider-mark, .provider-pill .provider-logo.tapo .provider-mark { width: 42px; }
  .all-provider-label { gap: 7px; font-size: .72rem; }
  .nav-list { position: fixed; right: 10px; bottom: 8px; bottom: max(8px,env(safe-area-inset-bottom)); left: 10px; z-index: 50; display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 3px; padding: 7px; border: 1px solid rgba(255,255,255,.12); border-radius: 20px; background: rgba(7,22,39,.94); box-shadow: 0 18px 48px rgba(3,12,22,.34); backdrop-filter: blur(18px); }
  .nav-item { flex-direction: column; justify-content: center; gap: 3px; min-width: 0; min-height: 50px; padding: 3px; border-radius: 14px; text-align: center; }
  .nav-item::before { width: 25px; height: 22px; background: transparent; font-size: 1rem; }
  .nav-item span { max-width: 100%; overflow: hidden; font-size: .62rem; text-overflow: ellipsis; }
  .nav-item:hover { transform: none; }
  .nav-item.is-active { box-shadow: none; background: rgba(41,202,159,.16); }
  .nav-item.is-active::before { color: #6ff1cc; background: transparent; }
  .workspace { padding: 14px 12px 96px; }
  .topbar { min-height: auto; margin-bottom: 12px; align-items: flex-start; }
  .view-summary { display: none; }
  h1 { font-size: 1.75rem; }
  .topbar-actions { justify-content: flex-end; }
  .topbar-actions .secondary-button { display: none; }
  .topbar-actions .primary-button { min-height: 44px; padding-inline: 13px; font-size: .75rem; }
  .status-banner { max-height: 72px; overflow: auto; margin-bottom: 12px; padding: 11px 12px 11px 38px; border-radius: 13px; font-size: .73rem; }
  .status-banner::before { left: 15px; top: 17px; }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .metric { min-height: 102px; padding: 15px; border-radius: 15px; }
  .metric strong { margin-top: 13px; font-size: 2rem; }
  .metric::after { right: 14px; top: 15px; width: 24px; }
  .panel-grid, .device-grid, .scene-grid, .security-grid, .scene-form { grid-template-columns: 1fr; }
  .panel { padding: 14px; border-radius: 16px; }
  .toolbar { align-items: stretch; flex-direction: column; min-height: 0; padding: 13px; }
  .toolbar-actions { width: 100%; }
  .toolbar input { width: 100%; }
  .toolbar-actions > * { flex: 1 1 auto; }
  .device-row, .scene-row, .channel-row, .account-card { align-items: stretch; flex-direction: column; }
  .device-row, .scene-row { gap: 11px; }
  .quick-row-actions, .row-actions, .account-actions { width: 100%; justify-content: stretch; }
  .quick-channel-control { flex: 1 1 100%; justify-content: space-between; }
  .quick-channel-control .toggle, .quick-channel-control .segmented { flex: 1 1 auto; }
  .control-cluster { width: 100%; }
  .control-cluster .toggle, .control-cluster .segmented { flex: 1 1 auto; }
  .toggle, .segmented { width: 100%; }
  .segmented { grid-template-columns: repeat(3,1fr); }
  .segmented button { min-height: 46px; }
  .device-card, .scene-card, .account-card, .security-card { border-radius: 16px; }
  .device-card-head, .scene-card-head { align-items: flex-start; }
  .account-card > div:first-child { min-width: 0; }
  .account-actions > button, .account-actions > .adapter-stage, .account-actions > .state-chip { flex: 1 1 120px; }
  .inline-code-field, .inline-code-field input { width: 100%; }
  .dialog { width: calc(100vw - 20px); max-width: none; max-height: calc(100dvh - 20px); margin: auto 10px; border-radius: 18px; }
  .dialog form { max-height: calc(100dvh - 20px); overflow-y: auto; padding: 16px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .dialog-head { align-items: flex-start; gap: 10px; }
  .dialog-head h2 { max-width: calc(100% - 44px); font-size: 1.15rem; line-height: 1.2; }
  .dialog .field-pair { grid-template-columns: minmax(0, 1fr) minmax(112px, .8fr); gap: 8px; }
  .dialog-actions { width: 100%; flex-wrap: wrap; }
  .dialog-actions > button { flex: 1 1 120px; min-height: 44px; }
  .automation-row { grid-template-columns: 1fr auto; }
  .automation-time { grid-column: 1 / -1; padding: 0 0 8px; border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 420px) {
  .workspace, .sidebar { padding-inline: 9px; }
  .topbar { gap: 8px; }
  .topbar-actions { gap: 6px; }
  .primary-button, .secondary-button, .ghost-button, .icon-button, .toggle { min-height: 46px; }
  .topbar-actions .primary-button { max-width: 132px; }
  .panel-head, .device-card-head { align-items: stretch; flex-direction: column; }
  .panel-head select, .device-card-head > .ghost-button { width: 100%; }
  .dialog .field-pair { grid-template-columns: 1fr; }
  .dialog-actions > button { flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
