
/* Layout: sidebar of sections on desktop (top scroller on phone); each section is one working screen; a side drawer edits a single device. */
:root {
  /* day: plaster walls and lamp-amber; night: a dark house with the lamps on */
  --bg: #F0EEE8;
  --panel: #FFFEFB;
  --sunk: #E6E2D9;
  --fg: #211E19;
  --muted: #625B50;
  --line: #D9D3C7;
  --accent: #A86F0B;
  --accent-soft: #F6E6C2;
  --on-accent: #1C1405;
  --ok: #2F6F68;
  --ok-soft: #DCEDEA;
  --warn: #9A5B00;
  --warn-soft: #FBEBD0;
  --bad: #B3362B;
  --bad-soft: #F8DEDA;
  --room: #FBF9F4;
  --room-lit: #FCE7B0;
  --glow: #F5BE4F;
  --wall: #3B352C;
  --sky: #CFE3EC;
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Instrument Sans", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121419; --panel: #1A1D24; --sunk: #0E1014; --fg: #ECE7DD; --muted: #A29C91; --line: #2C3039;
    --accent: #F0B43C; --accent-soft: #3A2E14; --on-accent: #1C1405;
    --ok: #6CC0B5; --ok-soft: #173330; --warn: #F2B15A; --warn-soft: #3A2A12; --bad: #F08A7E; --bad-soft: #3D1D19;
    --room: #1E222A; --room-lit: #4B3B17; --glow: #F0B43C; --wall: #8D877C; --sky: #2A3B52;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121419; --panel: #1A1D24; --sunk: #0E1014; --fg: #ECE7DD; --muted: #A29C91; --line: #2C3039;
    --accent: #F0B43C; --accent-soft: #3A2E14; --on-accent: #1C1405;
    --ok: #6CC0B5; --ok-soft: #173330; --warn: #F2B15A; --warn-soft: #3A2A12; --bad: #F08A7E; --bad-soft: #3D1D19;
    --room: #1E222A; --room-lit: #4B3B17; --glow: #F0B43C; --wall: #8D877C; --sky: #2A3B52;
    color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--display); margin: 0; line-height: 1.1; text-wrap: balance; }
h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.eyebrow { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }

/* shell */
.app { display: grid; grid-template-columns: 228px 1fr; min-height: 100%; }
.side {
  position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 18px; background: var(--bg);
}
.brand { font-family: var(--display); font-weight: 800; font-size: 1.25rem; display: flex; gap: 10px; align-items: center; padding-left: 8px; }
.dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); flex: none; }
nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 9px;
  text-decoration: none; color: var(--muted); font-weight: 500; white-space: nowrap;
}
nav a:hover { background: var(--sunk); color: var(--fg); }
nav a[aria-current="page"] { background: var(--panel); color: var(--fg); box-shadow: 0 0 0 1px var(--line); }
.count { font-family: var(--mono); font-size: 0.72rem; padding: 1px 7px; border-radius: 99px; background: var(--bad-soft); color: var(--bad); }
.count.w { background: var(--warn-soft); color: var(--warn); }
.side-foot { margin-top: auto; font-size: 0.78rem; color: var(--muted); padding-left: 8px; }
main {
  min-width: 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 22px 60px;
}
.inner { max-width: 1060px; margin: 0 auto; display: grid; gap: 22px; }
.demo-note {
  display: flex; gap: 10px; align-items: center; font-size: 0.85rem; padding: 9px 14px; border-radius: 10px;
  background: var(--accent-soft); color: var(--fg);
}
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; }
.head > div { display: grid; gap: 4px; min-width: 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: grid; gap: 14px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > * { min-width: 0; }

/* buttons */
.btn {
  border: 1px solid var(--line); background: var(--panel); padding: 7px 13px; border-radius: 9px; cursor: pointer;
  font-weight: 600; font-size: 0.88rem; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn.amber { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 15px; height: 15px; }

/* pills */
.pill { font-family: var(--mono); font-size: 0.7rem; padding: 2px 8px; border-radius: 99px; white-space: nowrap; background: var(--sunk); color: var(--muted); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.on { background: var(--accent-soft); color: var(--fg); }

/* summary strip */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); overflow: hidden; }
.sum { padding: 16px 18px; display: grid; gap: 4px; border-right: 1px solid var(--line); text-decoration: none; color: inherit; min-width: 0; }
.sum:last-child { border-right: 0; }
.sum:hover { background: var(--sunk); }
.sum b { font-family: var(--display); font-size: 1.7rem; line-height: 1; font-weight: 800; font-variant-numeric: tabular-nums; }
.sum b.bad { color: var(--bad); } .sum b.warn { color: var(--warn); } .sum b.ok { color: var(--ok); }
.sum span { font-size: 0.85rem; color: var(--muted); }

.scenes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.scene {
  border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 14px; text-align: left; cursor: pointer;
  display: grid; gap: 6px; align-content: start;
}
.scene:hover { border-color: var(--accent); }
.scene svg { width: 22px; height: 22px; stroke: var(--accent); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.scene span { font-size: 0.82rem; color: var(--muted); line-height: 1.35; }

/* lists */
.rows { display: grid; }
.row { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row > div { min-width: 0; display: grid; gap: 2px; }
.row .t { font-weight: 600; }
.row .s { font-size: 0.85rem; color: var(--muted); }
.row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.stripe { width: 4px; align-self: stretch; border-radius: 4px; background: var(--line); }
.stripe.bad { background: var(--bad); } .stripe.warn { background: var(--warn); } .stripe.ok { background: var(--ok); }

/* rooms */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chipbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 0.85rem; }
.chipbtn[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.room { display: grid; gap: 10px; }
.room-head { display: flex; align-items: baseline; gap: 10px; }
.devices { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.dev {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px;
  align-content: space-between; min-height: 142px;
}
.dev.off-line { border-color: var(--bad); border-style: dashed; }
.dev.disabled { opacity: .55; }
.dev-top { display: flex; gap: 10px; align-items: flex-start; }
.dev-ico { width: 34px; height: 34px; border-radius: 9px; background: var(--sunk); display: grid; place-items: center; flex: none; }
.dev-ico svg { width: 19px; height: 19px; stroke: var(--muted); fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.dev.is-on .dev-ico { background: var(--accent-soft); }
.dev.is-on .dev-ico svg { stroke: var(--accent); }
.dev-name { display: grid; gap: 1px; min-width: 0; flex: 1; }
.dev-name b { font-weight: 600; line-height: 1.25; }
.dev-name span { font-size: 0.82rem; color: var(--muted); }
.more { border: 0; background: transparent; cursor: pointer; padding: 4px; border-radius: 6px; color: var(--muted); }
.more:hover { background: var(--sunk); }
.more svg { width: 18px; height: 18px; fill: currentColor; }
.dev-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 6px 11px; cursor: pointer; font-size: 0.85rem; font-weight: 600; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); }
.switch { position: relative; width: 44px; height: 26px; border-radius: 99px; border: 0; background: var(--line); cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--panel); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
.switch[disabled] { opacity: .45; cursor: default; }

/* forms */
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .lbl { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
input[type="text"], input[type="number"], input[type="time"], input[type="datetime-local"], select {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg);
}
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.inline > .field { flex: 1 1 150px; }
.days { display: flex; gap: 5px; flex-wrap: wrap; }
.days button { width: 36px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; font-weight: 600; font-size: 0.82rem; }
.days button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.result { border-radius: 12px; background: var(--sunk); padding: 16px; display: grid; gap: 6px; }
.big-time { font-family: var(--display); font-weight: 800; font-size: 2.6rem; line-height: 1; font-variant-numeric: tabular-nums; }

/* pantry */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tabs button { border: 0; background: transparent; padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button[aria-selected="true"] { color: var(--fg); border-color: var(--accent); }
.shop { columns: 3 200px; column-gap: 24px; }
.shop label { display: flex; gap: 8px; align-items: center; padding: 5px 0; break-inside: avoid; cursor: pointer; }
.shop input { accent-color: var(--accent); width: 16px; height: 16px; }
.shop label.done span { text-decoration: line-through; color: var(--muted); }

/* log */
.log { font-family: var(--mono); font-size: 0.8rem; display: grid; }
.log .l { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); align-items: start; }
.log .l:first-child { border-top: 0; }
.log .l > div { min-width: 0; display: grid; gap: 2px; }
.log .said { font-family: var(--body); font-size: 0.9rem; font-weight: 600; }
.log .ans { font-family: var(--body); font-size: 0.85rem; color: var(--muted); }
.cmds { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.cmds div { display: grid; gap: 4px; align-content: start; }
.cmds q { quotes: "“" "”"; font-size: 0.9rem; }

/* drawer */
dialog.drawer {
  margin: 0 0 0 auto; height: 100%; max-height: 100%; width: min(440px, 100%); border: 0; padding: 0;
  background: var(--panel); color: var(--fg); box-shadow: -10px 0 40px rgba(0,0,0,.18);
}
dialog.drawer::backdrop { background: rgba(10, 14, 13, .35); }
.drawer-in {
  display: grid; gap: 18px; align-content: start; height: 100%; overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) 28px 20px;
}
.aliases { display: flex; flex-wrap: wrap; gap: 6px; }
.alias { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 99px; background: var(--sunk); font-size: 0.85rem; }
.alias button { border: 0; background: transparent; cursor: pointer; width: 20px; height: 20px; border-radius: 50%; color: var(--muted); }
.alias button:hover { background: var(--line); }
.steps { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 0.9rem; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 0; }

/* toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 500; font-size: 0.9rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.2); z-index: 50; max-width: calc(100% - 32px);
}
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: sp .7s linear infinite; display: inline-block; }
@keyframes sp { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2s; } .switch::after { transition: none; } }

/* home: greeting + floor plan */
.home-hero { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); gap: 32px; align-items: center; padding-block: 6px 4px; }
.hero-text { display: grid; gap: 10px; min-width: 0; }
.hero-text h1 { font-size: clamp(2.1rem, 4.6vw, 3.1rem); }
.story { font-size: 1.22rem; line-height: 1.45; max-width: 32ch; text-wrap: pretty; }
.plan { min-width: 0; }
.plan svg { width: 100%; max-width: 100%; height: auto; display: block; }
.plan .rm { fill: var(--room); transition: fill .4s; }
.plan .rm.lit { fill: var(--room-lit); }
.plan .glow { fill: var(--glow); opacity: .5; }
.plan .rn { font-family: var(--display); font-weight: 600; font-size: 19px; fill: var(--fg); }
.plan .rs { font-family: var(--body); font-size: 14.5px; fill: var(--muted); }
.plan .wall-out { fill: none; stroke: var(--wall); stroke-width: 7; stroke-linejoin: round; }
.plan .wall-in { fill: none; stroke: var(--wall); stroke-width: 3.5; stroke-linecap: round; }
.plan .door { stroke: var(--accent); stroke-width: 7; }
.plan .win { stroke: var(--wall); stroke-width: 2; }
.plan .win.sky { fill: var(--sky); }
.plan .win.dusk { fill: var(--sunk); }
.plan .win.shut { fill: var(--wall); }
.plan .bad-dot { fill: var(--bad); }
.plan .bad-n { fill: var(--panel); font: 600 13px var(--mono); }
.plan .person { fill: var(--accent); }
.plan .drive { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 6 6; }
.plan .car-body { fill: var(--sunk); stroke: var(--muted); stroke-width: 2; }
.plan a { cursor: pointer; outline: none; }
.plan a:hover .rm, .plan a:focus-visible .rm { stroke: var(--accent); stroke-width: 3; }
.plan a:focus-visible .drive { stroke: var(--accent); }
.block { display: grid; gap: 10px; }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }

/* the day of the house */
.day { display: grid; }
.it { display: grid; grid-template-columns: 54px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); align-items: baseline; }
.it:first-child { border-top: 0; }
.it time { font-family: var(--mono); font-size: .85rem; font-variant-numeric: tabular-nums; }
.it > div { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; min-width: 0; }
.it.past { color: var(--muted); }
.it.now { border-top: 2px solid var(--accent); color: var(--accent); font-weight: 600; }
.it.now + .it { border-top: 0; }
.ev { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: .92rem; }
.ev:first-child { border-top: 0; }
.ev .when { color: var(--muted); }

/* trip route */
.route { display: grid; }
.stop { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 14px; align-items: start; padding-bottom: 18px; position: relative; }
.stop::before { content: ""; position: absolute; left: 8px; top: 22px; bottom: 0; width: 2px; background: var(--line); }
.stop:last-child { padding-bottom: 0; }
.stop:last-child::before { display: none; }
.stop.leg::before { background: repeating-linear-gradient(var(--accent) 0 7px, transparent 7px 12px); }
.stop > div { display: grid; gap: 2px; }
.pin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--line); background: var(--panel); margin-top: 3px; }
.pin.home { border-color: var(--accent); background: var(--accent-soft); }
.pin.dest { border-color: var(--fg); }
.stop time { font-family: var(--display); font-weight: 800; font-size: 1.35rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stop.main time { font-size: 2.5rem; line-height: 1; }

@media (max-width: 900px) {
  .home-hero { grid-template-columns: 1fr; gap: 18px; }
  .app { grid-template-columns: 1fr; }
  .side {
    position: sticky; top: env(safe-area-inset-top, 0px); height: auto; z-index: 5; flex-direction: row; align-items: center;
    padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
    border-right: 0; border-bottom: 1px solid var(--line); gap: 12px;
  }
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
  .brand span:last-child { display: none; }
  nav { flex-direction: row; overflow-x: auto; scrollbar-width: none; min-width: 0; }
  nav a { padding: 7px 10px; }
  .side-foot { display: none; }
  .summary { grid-template-columns: 1fr 1fr; }
  .sum:nth-child(2) { border-right: 0; }
  .sum:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .scenes { grid-template-columns: 1fr 1fr; }
  .grid2 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  h1 { font-size: 1.55rem; }
  .row { grid-template-columns: auto 1fr; }
  .row .acts { grid-column: 2; justify-content: flex-start; }
}

/* ───── real app additions ───── */
body { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
a { color: inherit; }
.loading { display: grid; place-items: center; min-height: 50vh; color: var(--muted); gap: 12px; }
.err-banner { display: flex; gap: 10px; align-items: center; font-size: .9rem; padding: 10px 14px; border-radius: 10px; background: var(--bad-soft); color: var(--fg); }
.side-foot a { color: var(--muted); }
.side-foot { display: grid; gap: 6px; }
.frame { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); height: calc(100dvh - 150px); min-height: 520px; display: block; }
.meter { height: 8px; border-radius: 99px; background: var(--sunk); overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.meter i.warn { background: var(--warn); } .meter i.bad { background: var(--bad); }
.copyrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.copyrow code { font-family: var(--mono); font-size: .8rem; background: var(--sunk); padding: 8px 10px; border-radius: 8px; word-break: break-all; flex: 1 1 260px; user-select: all; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; font-family: var(--mono); }
.codes span { background: var(--sunk); border-radius: 8px; padding: 6px 10px; text-align: center; user-select: all; }
.confirm { color: var(--bad); border-color: var(--bad); }

/* login & invite */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding-block: 32px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.auth-card { width: min(400px, 100%); display: grid; gap: 18px; }
.auth-card .panel { gap: 16px; }
.auth-card h1 { font-size: 2rem; }
.auth-card input { font-size: 16px; padding: 11px 12px; }
.auth-card .btn { justify-content: center; padding: 11px 14px; font-size: 1rem; }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: min(240px, 100%); margin: 0 auto; }
.qr svg { width: 100%; height: auto; display: block; }
.msg { font-size: .9rem; padding: 9px 12px; border-radius: 9px; background: var(--bad-soft); }
.msg.ok { background: var(--ok-soft); }
@media (max-width: 900px) { .frame { height: calc(100dvh - 120px); } }

/* ───── móvil: cabecera compacta arriba y pestañas abajo, como una app ───── */
.tabbar, dialog.sheet:not([open]) { display: none; }
@media (max-width: 900px) {
  .side { padding-block: 10px; }
  .side nav { display: none; }
  .brand span:last-child { display: inline; }
  .side-foot { display: block; margin-left: auto; font-size: .75rem; text-align: right; }
  main { padding-block: 16px calc(88px + env(safe-area-inset-bottom, 0px)); }
  .inner { gap: 16px; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; inset: auto 0 0 0; z-index: 20;
    background: var(--panel); border-top: 1px solid var(--line);
    padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
  }
  .tab {
    position: relative; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 54px; padding: 4px 2px;
    border: 0; border-radius: 12px; background: none; color: var(--muted); font: 600 .7rem/1 var(--body); text-decoration: none; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .tab[aria-current="page"] { color: var(--fg); background: var(--accent-soft); }
  .tab .count { position: absolute; top: 3px; left: calc(50% + 6px); font-size: .65rem; padding: 0 5px; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  dialog.sheet[open] {
    display: block; margin: auto 0 0; width: 100%; max-width: 100%; max-height: 80dvh; border: 0; border-radius: 18px 18px 0 0;
    padding: 0; background: var(--panel); color: var(--fg); box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
  }
  dialog.sheet::backdrop { background: rgba(10, 14, 13, .35); }
  .sheet-in {
    display: grid; gap: 4px;
    padding: 14px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  }
  .sheet-in a { padding: 14px 12px; border-radius: 10px; text-decoration: none; font-weight: 600; font-size: 1.05rem; }
  .sheet-in a[aria-current="page"] { background: var(--accent-soft); }
  input[type="text"], input[type="number"], input[type="time"], input[type="datetime-local"], input[type="password"], select { font-size: 16px; }
  .btn { min-height: 40px; }
  .seg button { min-height: 38px; }
  .head h1 { font-size: 1.6rem; }
  .panel { padding: 16px; }
  .home-hero { padding-block: 0; }
  .frame { height: calc(100dvh - 215px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); min-height: 380px; }
  dialog.drawer { width: 100%; }
}
/* Instalada como app: sin márgenes de navegador que sobran. */
@media (display-mode: standalone) and (max-width: 900px) {
  .side { padding-top: max(10px, env(safe-area-inset-top, 0px)); top: 0; }
  body { padding-top: 0; }
}
[hidden] { display: none !important; }
.ev-list { display: grid; }
.ev-list .ev { grid-template-columns: 1fr; }
@media (max-width: 900px) {
  .dev { min-height: 0; gap: 8px; padding: 12px 14px; }
  .devices { gap: 8px; }
  .grid2 > .stack { order: -1; }
  .desp-head { display: none; }
  .frame { height: calc(100dvh - 130px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); border-radius: 12px; }
}
input, select { min-width: 0; max-width: 100%; }
@media (max-width: 480px) { #trip-form .inline > .field { flex-basis: 100% !important; } }
