@font-face {
  font-family: "Plex Arabic";
  src: url("/fonts/plex-arabic-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Plex Arabic";
  src: url("/fonts/plex-arabic-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

/* ---------- themes: --plastic is the page (the strip's plastic, in shade), --body the strip itself,
   --live the color of current flowing. One block per theme, light then dark. ---------- */
:root {
  --plastic: #E9EEEC;
  --body: #FBFCFB;
  --well: #F0F3F2;
  --ink: #17262A;
  --muted: #56676A;
  --line: #CCD6D3;
  --live: #00A37A;
  --aura: #36B9E8;
  --live-soft: #D3F0E5;
  --warn: #B3303D;
  --edge: 0 2px 0 var(--line);
  --shine: inset 0 1px 0 rgba(255, 255, 255, .8);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --plastic: #0E1618;
    --body: #172225;
    --well: #1E2B2F;
    --ink: #E3ECEA;
    --muted: #97A8AA;
    --line: #2B3B3F;
    --live: #2FD6A6;
    --aura: #2BB8F0;
    --live-soft: #123C32;
    --warn: #FF8591;
    --edge: 0 2px 0 #070C0D;
    --shine: inset 0 1px 0 rgba(255, 255, 255, .05);
  }
}
:root[data-theme="dark"] {
  --plastic: #0E1618;
  --body: #172225;
  --well: #1E2B2F;
  --ink: #E3ECEA;
  --muted: #97A8AA;
  --line: #2B3B3F;
  --live: #2FD6A6;
  --aura: #2BB8F0;
  --live-soft: #123C32;
  --warn: #FF8591;
  --edge: 0 2px 0 #070C0D;
  --shine: inset 0 1px 0 rgba(255, 255, 255, .05);
}
:root[data-accent="ion"] {
  --plastic: #E8ECF2;
  --body: #FBFCFE;
  --well: #EEF2F8;
  --ink: #151F2E;
  --muted: #556274;
  --line: #CAD3E0;
  --live: #1A66D9;
  --aura: #7A5CF0;
  --live-soft: #D9E6FA;
  --warn: #B3303D;
  --edge: 0 2px 0 var(--line);
  --shine: inset 0 1px 0 rgba(255, 255, 255, .8);
}
@media (prefers-color-scheme: dark) {
  :root[data-accent="ion"]:not([data-theme="light"]) {
    --plastic: #0B111C;
    --body: #141C29;
    --well: #1B2535;
    --ink: #E2E9F3;
    --muted: #93A0B4;
    --line: #273348;
    --live: #5AA9FF;
    --aura: #9C7BFF;
    --live-soft: #14294A;
    --warn: #FF8591;
    --edge: 0 2px 0 #05080E;
    --shine: inset 0 1px 0 rgba(255, 255, 255, .05);
  }
}
:root[data-accent="ion"][data-theme="dark"] {
  --plastic: #0B111C;
  --body: #141C29;
  --well: #1B2535;
  --ink: #E2E9F3;
  --muted: #93A0B4;
  --line: #273348;
  --live: #5AA9FF;
  --aura: #9C7BFF;
  --live-soft: #14294A;
  --warn: #FF8591;
  --edge: 0 2px 0 #05080E;
  --shine: inset 0 1px 0 rgba(255, 255, 255, .05);
}
:root[data-accent="arc"] {
  --plastic: #ECEAF2;
  --body: #FCFBFE;
  --well: #F2F0F8;
  --ink: #1E1A2E;
  --muted: #625C74;
  --line: #D4CFE2;
  --live: #6A45DB;
  --aura: #E0459E;
  --live-soft: #E5DEFB;
  --warn: #B3303D;
  --edge: 0 2px 0 var(--line);
  --shine: inset 0 1px 0 rgba(255, 255, 255, .8);
}
@media (prefers-color-scheme: dark) {
  :root[data-accent="arc"]:not([data-theme="light"]) {
    --plastic: #100D1A;
    --body: #1A1627;
    --well: #221D33;
    --ink: #EAE6F5;
    --muted: #A49CB8;
    --line: #302944;
    --live: #A88BFF;
    --aura: #FF6BC2;
    --live-soft: #2A2150;
    --warn: #FF8591;
    --edge: 0 2px 0 #07050D;
    --shine: inset 0 1px 0 rgba(255, 255, 255, .05);
  }
}
:root[data-accent="arc"][data-theme="dark"] {
  --plastic: #100D1A;
  --body: #1A1627;
  --well: #221D33;
  --ink: #EAE6F5;
  --muted: #A49CB8;
  --line: #302944;
  --live: #A88BFF;
  --aura: #FF6BC2;
  --live-soft: #2A2150;
  --warn: #FF8591;
  --edge: 0 2px 0 #07050D;
  --shine: inset 0 1px 0 rgba(255, 255, 255, .05);
}
:root[data-accent="amber"] {
  --plastic: #ECEBE7;
  --body: #FCFCFA;
  --well: #F3F2EE;
  --ink: #24201A;
  --muted: #67615A;
  --line: #D7D3CA;
  --live: #B26A00;
  --aura: #E2552D;
  --live-soft: #F6E6C6;
  --warn: #B3303D;
  --edge: 0 2px 0 var(--line);
  --shine: inset 0 1px 0 rgba(255, 255, 255, .8);
}
@media (prefers-color-scheme: dark) {
  :root[data-accent="amber"]:not([data-theme="light"]) {
    --plastic: #12100C;
    --body: #1C1914;
    --well: #25211B;
    --ink: #F0EBE2;
    --muted: #ABA396;
    --line: #36302A;
    --live: #FFB938;
    --aura: #FF7A45;
    --live-soft: #3A2C10;
    --warn: #FF8591;
    --edge: 0 2px 0 #080604;
    --shine: inset 0 1px 0 rgba(255, 255, 255, .05);
  }
}
:root[data-accent="amber"][data-theme="dark"] {
  --plastic: #12100C;
  --body: #1C1914;
  --well: #25211B;
  --ink: #F0EBE2;
  --muted: #ABA396;
  --line: #36302A;
  --live: #FFB938;
  --aura: #FF7A45;
  --live-soft: #3A2C10;
  --warn: #FF8591;
  --edge: 0 2px 0 #080604;
  --shine: inset 0 1px 0 rgba(255, 255, 255, .05);
}
:root[data-accent="plasma"] {
  --plastic: #EEE9EE;
  --body: #FDFBFD;
  --well: #F5EFF4;
  --ink: #2A1726;
  --muted: #6E5A69;
  --line: #DCCDD8;
  --live: #C2187A;
  --aura: #7C4DFF;
  --live-soft: #F8DCEC;
  --warn: #B3303D;
  --edge: 0 2px 0 var(--line);
  --shine: inset 0 1px 0 rgba(255, 255, 255, .8);
}
@media (prefers-color-scheme: dark) {
  :root[data-accent="plasma"]:not([data-theme="light"]) {
    --plastic: #140C13;
    --body: #1F141E;
    --well: #291B28;
    --ink: #F3E6F0;
    --muted: #B39DAE;
    --line: #3B2738;
    --live: #FF5CB8;
    --aura: #A57CFF;
    --live-soft: #401731;
    --warn: #FF8591;
    --edge: 0 2px 0 #090408;
    --shine: inset 0 1px 0 rgba(255, 255, 255, .05);
  }
}
:root[data-accent="plasma"][data-theme="dark"] {
  --plastic: #140C13;
  --body: #1F141E;
  --well: #291B28;
  --ink: #F3E6F0;
  --muted: #B39DAE;
  --line: #3B2738;
  --live: #FF5CB8;
  --aura: #A57CFF;
  --live-soft: #401731;
  --warn: #FF8591;
  --edge: 0 2px 0 #090408;
  --shine: inset 0 1px 0 rgba(255, 255, 255, .05);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--plastic);
  color: var(--ink);
  font-family: "Plex Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .35s ease, color .35s ease;
}
button { font: inherit; color: inherit; }
input, select { font: inherit; color: var(--ink); }
bdi, .ip { unicode-bidi: isolate; }

.shell {
  position: relative;
  z-index: 1;
  max-width: 34rem;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px calc(40px + env(safe-area-inset-bottom, 0px));
}

/* ---------- header ---------- */
.top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
h1 { margin: 0; font-size: 1.5rem; line-height: 1.3; font-weight: 600; }
.beta-tag { display: inline-block; margin-inline-start: 8px; padding: 1px 8px; border-radius: 999px; vertical-align: 3px;
  background: var(--live-soft); color: var(--ink); font-size: .75rem; font-weight: 600; line-height: 1.6; }
.beta-tag[hidden] { display: none; }
.summary { margin: 2px 0 0; color: var(--muted); font-size: .95rem; font-variant-numeric: tabular-nums; min-height: 1.6em; }
.summary b { color: var(--ink); font-weight: 600; }
.link { margin: 4px 0 12px; font-size: .88rem; color: var(--warn); }
/* the strips as last seen, until the server's live state arrives (or while it can't be reached) */
.strip .bar, .strip-foot { transition: opacity .3s; }
body.stale .strip .bar, body.stale .strip-foot { opacity: .6; }

/* the last minute of power, drawn live */
.spark { display: block; inline-size: 100%; block-size: 38px; margin: 4px 0 16px; overflow: visible; }
.spark path { vector-effect: non-scaling-stroke; }
.spark-line { fill: none; stroke: var(--live); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; transition: stroke .35s; }
.spark-fill { fill: var(--live-soft); opacity: .45; transition: fill .35s; }

.top-actions { display: flex; align-items: center; margin-inline-end: -10px; }
.icon-btn {
  flex: none; inline-size: 44px; block-size: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  transition: background-color .15s, transform .12s;
}
.icon-btn svg { inline-size: 22px; block-size: 22px; fill: currentColor; }
.icon-btn .line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.icon-btn:active { background: var(--line); transform: scale(.94); }

/* ---------- rooms ---------- */
.rooms {
  display: flex; gap: 22px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -18px 20px; padding: 0 18px; border-bottom: 1px solid var(--line);
}
.rooms::-webkit-scrollbar { display: none; }
.rooms button {
  flex: none; border: 0; background: none; cursor: pointer;
  padding: 8px 0 10px; margin-bottom: -1px;
  font-size: .95rem; color: var(--muted); border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}
.rooms button[aria-current="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--live); }

/* ---------- a strip ---------- */
.list { display: grid; gap: 28px; }
.strip-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.strip-name { margin: 0; min-width: 0; font-size: 1.06rem; font-weight: 600; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-tag { flex: none; font-size: .82rem; color: var(--muted); }
.strip-head .icon-btn { margin-inline-start: auto; margin-inline-end: -10px; }
.strip.enter { animation: rise .55s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.bar {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  padding: 14px 8px 10px;
  background: var(--body);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shine), var(--edge);
  transition: background-color .35s, border-color .35s, opacity .3s;
}
.strip.offline .bar { opacity: .5; }

.socket {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 0; padding: 2px 2px 4px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  border: 0; border-radius: 18px; background: none; cursor: pointer;
}
.socket:disabled { cursor: default; }
.face { inline-size: 100%; max-inline-size: 58px; block-size: auto; aspect-ratio: 1; overflow: visible; margin-bottom: 4px; transition: transform .14s cubic-bezier(.3, .7, .2, 1); }
.face .rim { fill: var(--body); stroke: var(--line); stroke-width: 2; transform-box: fill-box; transform-origin: center; transition: stroke .3s, fill .35s; }
.face .charge {
  fill: none; stroke: var(--live); stroke-width: 3.2; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100; opacity: 0;
  transition: stroke-dashoffset .55s cubic-bezier(.3, .7, .2, 1), opacity .25s, stroke .35s;
}
.face .well { fill: var(--well); transition: fill .4s ease; }
.face .pin { fill: var(--muted); opacity: .5; transition: fill .3s, opacity .3s; }
.face .clip { fill: var(--line); transition: fill .3s, opacity .3s; }
.socket.on .charge { stroke-dashoffset: 0; opacity: 1; filter: drop-shadow(0 0 3px var(--live)); }
.socket.on .well { fill: var(--live-soft); }
.socket.on .pin { fill: var(--live); opacity: 1; }
.socket.on .clip { fill: var(--live); opacity: .45; }
.socket:not(:disabled):active .face { transform: scale(.92); }
.socket.pending .rim { stroke: var(--muted); stroke-dasharray: 5 5; animation: turn 1.1s linear infinite; }
.socket.pending .charge { opacity: .35; }
@keyframes turn { to { transform: rotate(360deg); } }

.o-name { max-width: 100%; font-size: .8rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.o-watts { font-size: .78rem; line-height: 1.35; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; transition: color .3s; }
.socket.on .o-watts { color: var(--ink); font-weight: 600; }

.strip-foot { display: flex; align-items: center; gap: 14px; margin-top: 8px; padding-inline: 4px; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.conn { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.conn::before { content: ""; inline-size: 7px; block-size: 7px; border-radius: 50%; background: var(--muted); opacity: .6; transition: background-color .3s; }
.strip:not(.offline) .conn::before { background: var(--live); opacity: 1; box-shadow: 0 0 6px var(--live); }
.strip-foot .btn.text { margin-inline-start: auto; }

/* ---------- buttons and fields ---------- */
.btn {
  min-height: 44px; padding: 9px 16px; cursor: pointer;
  font-size: .95rem; font-weight: 600;
  border: 1px solid var(--line); border-radius: 12px; background: transparent;
  transition: background-color .2s, color .2s, border-color .2s, transform .12s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--ink); color: var(--body); border-color: var(--ink); }
.btn.text { min-height: 40px; padding: 6px 4px; border: 0; font-size: .88rem; color: var(--ink); }
.btn.danger { border: 0; padding-inline: 0; color: var(--warn); justify-self: start; }
input, select {
  width: 100%; min-height: 46px; padding: 10px 12px;
  font-size: 16px; background: var(--body);
  border: 1px solid var(--line); border-radius: 12px;
  transition: border-color .2s, background-color .35s;
}
input:focus, select:focus { border-color: var(--live); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.socket:focus-visible { outline-offset: 0; }

/* ---------- sign in ---------- */
.login { display: grid; gap: 10px; margin-top: 8vh; }
.login label { font-weight: 600; }
.login .mark { inline-size: 64px; block-size: 64px; margin-bottom: 6px; border-radius: 16px; }
.login .hint { margin-top: -2px; }
.lang-switch { justify-self: end; margin-bottom: -6px; font-weight: 400; }
.err { min-height: 1.6em; margin: 0; font-size: .9rem; color: var(--warn); }

/* ---------- empty state ---------- */
.empty { padding: 18px 18px 20px; background: var(--body); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shine), var(--edge); }
.empty h2 { margin: 0 0 2px; font-size: 1.1rem; }
.empty p { margin: 0; color: var(--muted); }
.empty ol { margin: 12px 0 0; padding-inline-start: 1.3em; display: grid; gap: 8px; }
.empty li::marker { font-weight: 600; }
.none { margin: 8px 0; color: var(--muted); }

/* ---------- sheets: slide up from the bottom ---------- */
.sheet {
  width: 100%; max-width: 34rem; max-height: 90vh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 22px 22px 0 0;
  background: var(--body); color: var(--ink);
  transform: translateY(100%);
  transition: transform .34s cubic-bezier(.2, .8, .2, 1), overlay .34s allow-discrete, display .34s allow-discrete;
}
.sheet[open] { transform: translateY(0); }
@starting-style { .sheet[open] { transform: translateY(100%); } }
.sheet::backdrop {
  background: rgba(10, 18, 20, 0);
  transition: background-color .34s, overlay .34s allow-discrete, display .34s allow-discrete;
}
.sheet[open]::backdrop { background: rgba(10, 18, 20, .45); }
@starting-style { .sheet[open]::backdrop { background: rgba(10, 18, 20, 0); } }
.sheet-in { display: grid; gap: 8px; padding: 20px 18px calc(22px + env(safe-area-inset-bottom, 0px)); }
.sheet h2 { margin: 0 0 4px; font-size: 1.15rem; }
.sheet h2:focus { outline: none; }
.sheet h3 { margin: 16px 0 4px; font-size: .95rem; }
.sheet label { font-size: .9rem; font-weight: 600; margin-top: 4px; }
.pair-app { display: grid; gap: 8px; }
fieldset { margin: 8px 0 0; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 6px; font-size: .9rem; font-weight: 600; }
.outlet-names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.outlet-names label { display: grid; gap: 4px; margin: 0; font-size: .8rem; font-weight: 400; color: var(--muted); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; margin: 10px 0 0; font-size: .82rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; direction: ltr; text-align: left; font-variant-numeric: tabular-nums; }
[dir="rtl"] .facts dd { text-align: right; }
.facts .group { grid-column: 1 / -1; margin-top: 8px; color: var(--ink); font-weight: 600; }
.actions { display: flex; gap: 10px; margin-top: 12px; }
.actions .btn { flex: 1; }
.room-list { list-style: none; margin: 0; padding: 0; }
.room-list li { display: flex; align-items: center; justify-content: space-between; min-height: 44px; border-bottom: 1px solid var(--line); }
.room-list .muted { color: var(--muted); border: 0; }
.inline { display: flex; gap: 8px; margin-top: 8px; }
.inline input { flex: 1; }
.inline .btn { flex: none; }
.hint { margin: 0; font-size: .88rem; color: var(--muted); }
.ip { margin: 0; direction: ltr; text-align: left; font-size: 1.3rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.empty .ip { display: inline-block; font-size: 1.05rem; }
[dir="rtl"] .ip { text-align: right; }

/* color themes */
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.swatch {
  display: grid; justify-items: center; gap: 6px; padding: 10px 0 8px;
  border: 1px solid transparent; border-radius: 14px; background: none; cursor: pointer;
  font-size: .78rem; color: var(--muted);
  transition: background-color .2s, border-color .2s, color .2s;
}
.swatch i { display: block; inline-size: 30px; block-size: 30px; border-radius: 50%; box-shadow: inset 0 0 0 3px var(--body), 0 0 0 1px var(--line); transition: box-shadow .2s, transform .2s; }
.swatch[aria-pressed="true"] { color: var(--ink); font-weight: 600; background: var(--well); border-color: var(--line); }
.swatch[aria-pressed="true"] i { box-shadow: inset 0 0 0 3px var(--body), 0 0 0 2px var(--live); transform: scale(1.06); }
.swatch[data-accent="jade"] i { background: #00A37A; }
[data-theme="dark"] .swatch[data-accent="jade"] i { background: #2FD6A6; }
.swatch[data-accent="ion"] i { background: #1A66D9; }
[data-theme="dark"] .swatch[data-accent="ion"] i { background: #5AA9FF; }
.swatch[data-accent="arc"] i { background: #6A45DB; }
[data-theme="dark"] .swatch[data-accent="arc"] i { background: #A88BFF; }
.swatch[data-accent="amber"] i { background: #B26A00; }
[data-theme="dark"] .swatch[data-accent="amber"] i { background: #FFB938; }
.swatch[data-accent="plasma"] i { background: #C2187A; }
[data-theme="dark"] .swatch[data-accent="plasma"] i { background: #FF5CB8; }

/* light / dark / follow the phone */
.seg { display: flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-top: 8px; }
.seg button { flex: 1; min-height: 42px; border: 0; background: transparent; cursor: pointer; font-size: .9rem; transition: background-color .2s, color .2s; }
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--body); font-weight: 600; }

/* about */
.about { display: grid; gap: 2px; margin-top: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--well); }
.about-name { display: flex; align-items: baseline; gap: 10px; margin: 0; font-size: 1.05rem; font-weight: 600; }
.about-name span { color: var(--muted); font-weight: 400; }
.about p { margin: 0; color: var(--muted); font-size: .88rem; }
.about .by, .about .about-name { color: var(--ink); }
.about .about-name span { color: var(--muted); }

/* ---------- toast ---------- */
.toast {
  position: fixed; inset-inline: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  max-width: 32rem; margin: 0 auto; padding: 12px 16px;
  background: var(--ink); color: var(--body); border-radius: 12px; font-size: .92rem;
  opacity: 0; transform: translateY(10px); transition: opacity .22s, transform .22s cubic-bezier(.2, .8, .2, 1); pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }

/* ---------- language ---------- */
.langs { display: flex; gap: 8px; }
.langs .btn { flex: 1; font-weight: 400; }
.langs .btn[aria-pressed="true"] { background: var(--ink); color: var(--body); border-color: var(--ink); font-weight: 600; }

/* ---------- waiting for a newly added strip; the dot blinks like the strip's own Wi-Fi light ---------- */
.pairing {
  display: grid; gap: 6px; margin-bottom: 20px; padding: 16px 18px;
  background: var(--body); border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shine), var(--edge);
}
.pairing h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 1.02rem; }
.pairing p { margin: 0; color: var(--muted); font-size: .92rem; }
.pairing .actions { margin-top: 6px; }
.pulse { flex: none; inline-size: 10px; block-size: 10px; border-radius: 50%; background: var(--live); box-shadow: 0 0 8px var(--live); animation: blink .9s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .2; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, .sheet, .sheet::backdrop { transition-duration: 0s !important; animation: none !important; }
  .socket:not(:disabled):active .face, .btn:active, .icon-btn:active { transform: none; }
}

/* ---------- moving backgrounds (behind everything; the strips stay solid so they read clearly) ---------- */
.bg { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg canvas { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; }
.bg i { display: none; position: absolute; border-radius: 50%; will-change: transform; opacity: .5; }
[data-theme="light"] .bg i { opacity: .32; }
[data-bg="aurora"] .bg i { display: block; }
.bg i:nth-child(1) { inline-size: 80vmax; block-size: 80vmax; left: -30vmax; top: -35vmax; background: radial-gradient(circle, var(--live) 0%, transparent 62%); animation: drift-a 24s ease-in-out infinite alternate; }
.bg i:nth-child(2) { inline-size: 70vmax; block-size: 70vmax; right: -32vmax; top: 18vh; background: radial-gradient(circle, var(--aura) 0%, transparent 62%); animation: drift-b 31s ease-in-out infinite alternate; }
.bg i:nth-child(3) { inline-size: 75vmax; block-size: 75vmax; left: -10vmax; bottom: -45vmax; background: radial-gradient(circle, var(--live) 0%, transparent 60%); opacity: .35; animation: drift-c 37s ease-in-out infinite alternate; }
@keyframes drift-a { to { transform: translate(22vw, 26vh) scale(1.18); } }
@keyframes drift-b { to { transform: translate(-26vw, -14vh) scale(.86); } }
@keyframes drift-c { to { transform: translate(30vw, -18vh) scale(1.1); } }

/* ---------- current flowing around a switched-on socket, faster with more load ---------- */
.face .flow { fill: none; stroke: var(--body); stroke-width: 2.4; stroke-linecap: round; stroke-dasharray: 1 7; opacity: 0; }
.socket.on .flow { opacity: .85; animation: flow var(--flow, 3s) linear infinite; }
@keyframes flow { to { stroke-dashoffset: -100; } }
.badge {
  position: absolute; inset-block-start: 0; inset-inline-end: 2px;
  padding: 1px 6px; border-radius: 999px; background: var(--ink); color: var(--body);
  font-size: .68rem; font-weight: 600; line-height: 1.5; font-variant-numeric: tabular-nums; pointer-events: none;
  box-shadow: 0 0 0 2px var(--body);
}
.badge[hidden] { display: none; }
.tip { display: flex; align-items: center; gap: 10px; margin: -6px 0 18px; padding: 10px 14px; border-radius: 14px; background: var(--well); color: var(--muted); font-size: .88rem; }
.tip .btn.text { margin-inline-start: auto; flex: none; }

/* ---------- outlet sheet: timer, schedules, idle ---------- */
.o-head { display: flex; align-items: center; gap: 12px; }
.o-head h2 { flex: 1; min-width: 0; margin: 0; }
.power-btn {
  flex: none; inline-size: 52px; block-size: 52px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--line); background: var(--well); color: var(--muted);
  display: grid; place-items: center; transition: background-color .25s, border-color .25s, color .25s, box-shadow .25s;
}
.power-btn svg { inline-size: 24px; block-size: 24px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.power-btn[aria-pressed="true"] { border-color: var(--live); background: var(--live-soft); color: var(--live); box-shadow: 0 0 14px var(--live); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 40px; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; font-size: .9rem;
  transition: background-color .2s, border-color .2s, color .2s;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--body); border-color: var(--ink); font-weight: 600; }
.day { min-width: 40px; padding: 6px 0; text-align: center; }
.running { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--live-soft); }
.running b { font-variant-numeric: tabular-nums; }
.running .btn { margin-inline-start: auto; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rules li { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 4px 6px 12px; border: 1px solid var(--line); border-radius: 14px; }
.rules li.off { opacity: .55; }
.rules .when { font-weight: 600; font-variant-numeric: tabular-nums; }
.rules .what { color: var(--muted); font-size: .85rem; min-width: 0; flex: 1; }
.switch { position: relative; flex: none; inline-size: 46px; block-size: 28px; border-radius: 999px; border: 0; cursor: pointer; background: var(--line); transition: background-color .2s; }
.switch::after { content: ""; position: absolute; inset-block-start: 3px; inset-inline-start: 3px; inline-size: 22px; block-size: 22px; border-radius: 50%; background: var(--body); transition: transform .2s cubic-bezier(.3, .7, .2, 1); }
.switch[aria-checked="true"] { background: var(--live); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }
[dir="rtl"] .switch[aria-checked="true"]::after { transform: translateX(-18px); }
.add-rule { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 14px; }
.add-rule .row { display: grid; gap: 8px; }
.add-rule .row .seg { margin-top: 0; }
.idle-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.idle-row input { inline-size: 64px; min-height: 40px; padding: 6px 8px; text-align: center; }
.mini-x { flex: none; inline-size: 40px; block-size: 40px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; font-size: 1.2rem; }

/* edit sheet: per-outlet voice type and timer shortcut */
.outlet-row { display: grid; gap: 6px; }
.outlet-row .row { display: flex; gap: 6px; }
.outlet-row select { flex: 1; min-height: 40px; padding: 6px 10px; font-size: .85rem; }
.outlet-row .btn { flex: none; min-height: 40px; padding: 6px 10px; font-size: .82rem; }

/* settings: backgrounds, notifications, voice, activity */
.bgs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.bg-choice { display: grid; justify-items: center; gap: 6px; padding: 8px 0 6px; border: 1px solid transparent; border-radius: 14px; background: none; cursor: pointer; font-size: .76rem; color: var(--muted); }
.bg-choice span:first-child { display: block; inline-size: 46px; block-size: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--plastic); overflow: hidden; }
.bg-choice[aria-pressed="true"] { border-color: var(--live); color: var(--ink); font-weight: 600; background: var(--well); }
.bg-choice[data-bg="aurora"] span:first-child { background: radial-gradient(circle at 25% 30%, var(--live), transparent 60%), radial-gradient(circle at 80% 75%, var(--aura), transparent 55%), var(--plastic); }
.bg-choice[data-bg="current"] span:first-child { background: repeating-linear-gradient(170deg, transparent 0 9px, var(--live) 9px 10px, transparent 10px 18px), var(--plastic); opacity: .9; }
.bg-choice[data-bg="sparks"] span:first-child { background: radial-gradient(circle at 30% 70%, var(--live) 0 2px, transparent 3px), radial-gradient(circle at 70% 30%, var(--aura) 0 2px, transparent 3px), radial-gradient(circle at 55% 60%, var(--live) 0 1.5px, transparent 2.5px), radial-gradient(circle at 20% 25%, var(--aura) 0 1.5px, transparent 2.5px), var(--plastic); }
.bg-choice[data-bg="circuit"] span:first-child { background: linear-gradient(var(--live), var(--live)) 30% 0 / 1px 60% no-repeat, linear-gradient(var(--live), var(--live)) 30% 60% / 50% 1px no-repeat, linear-gradient(var(--aura), var(--aura)) 80% 60% / 1px 40% no-repeat, var(--plastic); }
.toggles { display: grid; gap: 2px; }
.toggle-row { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.toggle-row span { flex: 1; font-size: .92rem; }
/* Notifications: quiet hours, and how they arrive (through Google, or the app's own connection) */
.quiet-times { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; margin: 4px 0 6px; }
.quiet-f { display: grid; gap: 4px; min-width: 0; font-size: .8rem; font-weight: 600; color: var(--muted); }
.quiet-f input { min-height: 42px; padding: 8px 10px; min-width: 0; }
.quiet-times .hint { grid-column: 1 / -1; margin: 0; }
.status.n-way { display: flex; align-items: flex-start; margin: 10px 0 4px; line-height: 1.4; }
.status.n-way::before { flex: none; margin-top: .45em; }
.copy-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.copy-row dt { grid-column: 1 / -1; color: var(--muted); font-size: .78rem; }
.copy-row dd { margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: ltr; font-size: .85rem; font-variant-numeric: tabular-nums; }
[dir="rtl"] .copy-row dd { text-align: right; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); }
.status::before { content: ""; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--muted); }
.status.ok::before { background: var(--live); box-shadow: 0 0 6px var(--live); }
.steps-mini { margin: 4px 0 0; padding-inline-start: 1.2em; color: var(--muted); font-size: .86rem; display: grid; gap: 4px; }
details.more summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; font-size: .95rem; }
.activity { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.activity li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: .86rem; }
.activity time { flex: none; color: var(--muted); font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: reduce) {
  .bg i, .socket.on .flow { animation: none !important; }
}

/* firmware overview */
.fw-list { list-style: none; margin: 0 0 8px; padding: 0; }
.fw-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .88rem; }
.fw-list li span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; text-align: end; }
.fw-list .fw-old { color: var(--ink); font-weight: 600; }
#fwPhone { margin-top: 8px; }

/* many strips: search, room counts, bulk off, compact rows */
.tools { display: flex; align-items: center; gap: 8px; margin: -8px 0 14px; }
.tools:not(:has(:not([hidden]))) { display: none; }
.find { flex: 1; min-width: 0; }
.find input { min-height: 42px; padding: 8px 14px; border-radius: 999px; font-size: 15px; }
#allOff { flex: none; margin-inline-start: auto; min-height: 42px; color: var(--warn); font-weight: 600; }
.rooms button .n { margin-inline-start: 6px; padding: 0 6px; border-radius: 999px; background: var(--well); color: var(--muted); font-size: .72rem; font-variant-numeric: tabular-nums; }
.rooms button[aria-current="true"] .n { background: var(--live-soft); color: var(--ink); }

.list.dense { gap: 10px; }
.strip .mini { display: none; }
.strip.compact .bar, .strip.compact .strip-foot { display: none; }
.strip.compact .strip-head {
  margin-bottom: 0; min-height: 60px; padding: 4px 6px 4px 16px; cursor: pointer;
  background: var(--body); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shine), var(--edge);
  transition: background-color .35s, border-color .35s, opacity .3s, transform .12s;
}
[dir="rtl"] .strip.compact .strip-head { padding: 4px 16px 4px 6px; }
.strip.compact .strip-head:active { transform: scale(.985); }
.strip.compact .strip-head:focus-visible { outline-offset: 0; }
.strip.compact.offline .strip-head { opacity: .55; }
.strip.compact .strip-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 12px; row-gap: 0; align-items: center;
  grid-template-areas: "name mini edit" "tag mini edit";
}
.strip.compact .strip-name { grid-area: name; align-self: end; }
.strip.compact .room-tag { grid-area: tag; align-self: start; margin-top: -4px; font-size: .74rem; }
.strip.compact .mini { grid-area: mini; display: inline-flex; align-items: center; gap: 12px; }
.strip.compact .strip-head .icon-btn { grid-area: edit; }
.strip.compact .strip-head .icon-btn { margin-inline-start: 0; margin-inline-end: 0; }
.dots { display: inline-flex; gap: 5px; }
.dots i { inline-size: 10px; block-size: 10px; border-radius: 50%; background: var(--line); transition: background-color .25s, box-shadow .25s; }
.dots i.on { background: var(--live); box-shadow: 0 0 7px var(--live); }
.mini-w { min-inline-size: 3.6em; text-align: end; font-size: .84rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.strip:not(.offline) .mini-w { color: var(--ink); }
/* a row that is open in the list layout */
.list.dense .strip:not(.compact) .strip-head { margin-bottom: 8px; }

.summary .fleet { display: block; font-size: .84rem; }

/* readings: size is one setting for the whole app (Settings, Readings) */
:root { --r-watts: .78rem; --r-sub: .68rem; --r-foot: .82rem; }
:root[data-size="s"] { --r-watts: .7rem; --r-sub: .62rem; --r-foot: .74rem; }
:root[data-size="l"] { --r-watts: 1.02rem; --r-sub: .8rem; --r-foot: 1rem; }
:root[data-size="xl"] { --r-watts: 1.36rem; --r-sub: .98rem; --r-foot: 1.28rem; }
.o-watts { font-size: var(--r-watts); line-height: 1.25; }
.o-amps { font-size: var(--r-sub); line-height: 1.2; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.strip-foot { font-size: var(--r-foot); flex-wrap: wrap; row-gap: 2px; }
.strip-foot .volts { white-space: nowrap; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.strip-foot .volts.muted { color: var(--muted); font-weight: 400; }
.mini-w { font-size: var(--r-foot); }
.size-preview { display: flex; align-items: baseline; justify-content: center; gap: 16px; margin: 10px 0 4px; padding: 14px; border-radius: 16px; background: var(--well); font-variant-numeric: tabular-nums; }
.size-preview .pv-w { font-size: var(--r-watts); }
.size-preview .pv-a, .size-preview .pv-v { font-size: var(--r-sub); color: var(--muted); }
:root[data-size="l"] .size-preview .pv-a, :root[data-size="l"] .size-preview .pv-v,
:root[data-size="xl"] .size-preview .pv-a, :root[data-size="xl"] .size-preview .pv-v { font-size: var(--r-foot); }

/* protection and limits */
#oHardBox[hidden] { display: none; }
.rule { display: grid; gap: 8px; margin-top: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; }
.rule-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rule-body { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.rule-body input { inline-size: 76px; min-height: 42px; padding: 6px 8px; text-align: center; }
.unit-seg { margin-top: 0; flex: none; }
.unit-seg button { min-height: 42px; padding: 0 14px; }
.rule .hint { margin: 0; }
.rule .r-hint { color: var(--ink); font-variant-numeric: tabular-nums; }

/* removed strips and the connection log */
.fw-list small { color: var(--muted); margin-inline-start: 6px; }
.diag-list { list-style: none; margin: 0 0 8px; padding: 0; }
.diag-list li { display: grid; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .86rem; }
.diag-list small { color: var(--muted); }
.diag-list .btn.text { justify-self: start; min-height: 36px; padding-inline: 0; }
.hint.warn { color: var(--warn); font-weight: 600; }
.r-pair { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

/* notices (old server, changed address) and the waiting-for-a-strip details */
.notice { margin: 0 0 14px; padding: 12px 14px; border-radius: 14px; background: var(--warn); color: var(--body); font-size: .9rem; line-height: 1.5; font-weight: 600; }
.pair-status { white-space: pre-line; font-size: .88rem; color: var(--ink); }
.pair-status:empty { display: none; }
.pair-checks-title { margin: 6px 0 0 !important; font-weight: 600; color: var(--ink) !important; }
.pair-checks { margin: 0; padding-inline-start: 1.2em; display: grid; gap: 4px; color: var(--muted); font-size: .86rem; }

/* start fresh */
.btn.danger-line { width: 100%; margin-top: 4px; border-color: var(--warn); color: var(--warn); }

/* adding a strip: flashed (MQTT) or on LG's firmware */
.add-body { display: grid; gap: 10px; margin-top: 12px; }
.add-body > .hint { margin: 0; }
.add-steps { margin: 0; padding-inline-start: 1.3em; display: grid; gap: 8px; font-size: .9rem; line-height: 1.5; }
.add-steps li::marker { font-weight: 600; }
.broker { margin: 0; }
.broker .copy-row dd { font-size: 1.15rem; font-weight: 600; }
.fw-head { margin: 12px 0 2px; font-weight: 600; font-size: .86rem; }
.add-steps bdi { white-space: nowrap; }
.facts a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }

/* ---------- strips and outlets in their own colors, with what's plugged in drawn in the socket ---------- */
.tint { display: none; flex: none; inline-size: 10px; block-size: 10px; border-radius: 50%; background: var(--live); box-shadow: 0 0 6px var(--live); }
.strip.colored .tint { display: block; }
.strip.colored .bar { border-color: color-mix(in srgb, var(--live) 28%, var(--line)); }
.face .dev { fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: .75; transition: stroke .3s, opacity .3s; }
.socket.on .face .dev { stroke: var(--live); opacity: 1; }
.socket.has-icon .pin { display: none; }
/* an outlet set to keep on (a router): a small lock where the bottom clip is */
.face .keep { display: none; }
.socket.keep .face .keep { display: inline; }
.socket.keep .face .clip.low { display: none; }
.face .keep rect { fill: var(--muted); transition: fill .3s; }
.face .keep path { fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-linecap: round; transition: stroke .3s; }
.socket.on .face .keep rect { fill: var(--live); }
.socket.on .face .keep path { stroke: var(--live); }

/* a row of colors to pick from */
.field-label { margin: 4px 0 0; font-size: .9rem; font-weight: 600; }
.colors { display: flex; flex-wrap: wrap; gap: 7px; }
.dot {
  inline-size: 32px; block-size: 32px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  background: var(--dot, var(--live)); box-shadow: inset 0 0 0 3px var(--body), 0 0 0 1px var(--line);
  transition: box-shadow .2s, transform .2s;
}
.dot.inherit { background: conic-gradient(from 45deg, var(--dot, var(--live)) 0 50%, var(--well) 0 100%); }
.dot[aria-pressed="true"] { box-shadow: inset 0 0 0 3px var(--body), 0 0 0 2.5px var(--ink); transform: scale(1.08); }

/* the edit sheet: a button per outlet for its icon and color, beside its name */
.name-row { display: flex; gap: 6px; }
.name-row input { flex: 1; min-width: 0; }
.outlet-row > label { display: block; margin: 0; font-size: .8rem; font-weight: 400; color: var(--muted); }
.look-btn {
  flex: none; display: grid; place-items: center; inline-size: 46px; block-size: 46px; padding: 0; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--live) 45%, var(--line)); border-radius: 14px;
  background: var(--live-soft); color: var(--live);
}
.look-btn svg { inline-size: 24px; block-size: 24px; }
.look-btn:active { transform: scale(.95); }
.o-head .look-btn { inline-size: 52px; block-size: 52px; border-radius: 50%; }

/* the icon picker */
.look-head { display: flex; align-items: center; gap: 14px; }
.look-head h2 { margin: 0; }
.look-preview {
  flex: none; display: grid; place-items: center; inline-size: 60px; block-size: 60px; border-radius: 50%;
  background: var(--live-soft); color: var(--live); box-shadow: 0 0 0 3px var(--live), 0 0 16px color-mix(in srgb, var(--live) 45%, transparent);
}
.look-preview svg { inline-size: 32px; block-size: 32px; }
.dev-group { margin: 14px 0 6px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.dev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.dev-choice {
  display: grid; justify-items: center; align-content: start; gap: 5px; min-height: 76px; padding: 10px 4px 8px; cursor: pointer;
  border: 1px solid transparent; border-radius: 14px; background: none; color: var(--ink);
  font-size: .72rem; line-height: 1.25; text-align: center;
  transition: background-color .2s, border-color .2s;
}
.dev-choice svg { inline-size: 26px; block-size: 26px; }
.dev-choice[aria-pressed="true"] { border-color: var(--live); background: var(--live-soft); color: var(--live); font-weight: 600; }
.look-done { position: sticky; bottom: calc(-22px - env(safe-area-inset-bottom, 0px)); margin: 8px -18px calc(-22px - env(safe-area-inset-bottom, 0px)); padding: 10px 18px calc(14px + env(safe-area-inset-bottom, 0px)); background: var(--body); border-top: 1px solid var(--line); }

/* away from home (Tailscale) */
.away-pill {
  display: inline-flex; align-items: center; gap: 6px; margin: 6px 0 0; padding: 3px 10px 3px 8px;
  border-radius: 999px; background: var(--live-soft); color: var(--live); font-size: .8rem; font-weight: 600;
}
.away-pill[hidden] { display: none; }
.away-pill svg { inline-size: 15px; block-size: 15px; flex: none; }
.away-pill .line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#awayBox .hint + dl { margin-top: 6px; }
#awayBox dl { margin: 0; }
#aSteps { margin: 10px 0 12px; }
#aSteps li.done { color: var(--live); }
#aTailscale { margin: 0 0 12px; }
#awayBox label { display: block; margin-top: 4px; }
#aSteps bdi { white-space: nowrap; }

/* sign in, create an account (cloud) */
.login-title { margin: 0 0 2px; font-size: 1.3rem; }
.login-rows { display: grid; gap: 10px; }
#loginSwitch { justify-self: center; }
.expired .hint { margin: 0; line-height: 1.5; }
.welcome .hint { margin: 0 0 14px; font-size: 1rem; }
.welcome .btn { min-height: 48px; }
/* Denjin's own question ("Turn off 6 outlets?"), instead of the browser's: the same on the phone, in a browser, in Arabic */
.ask-text { margin: 4px 0 10px; font-size: 1.02rem; line-height: 1.5; }
.ask-actions { display: flex; gap: 8px; }
.ask-actions .btn { flex: 1 1 0; min-height: 46px; }
#askYes.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
/* Add a strip, on the phone: Denjin finds the strip and sets it up by itself */
.auto-body { display: grid; gap: 10px; }
.auto-body h3 { margin: 4px 0 0; font-size: 1.05rem; }
.auto-look { display: flex; align-items: center; gap: 10px; margin: 10px 0; font-size: 1.02rem; }
.auto-strip { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 14px; }
.auto-strip span { display: grid; min-width: 0; }
.auto-strip small { color: var(--muted); }
.auto-body .check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.auto-body .check input { inline-size: auto; }
.auto-body > .btn.text { justify-self: start; }
.account-sub { margin: 0; font-size: .9rem; color: var(--muted); }
.account-sub.ok { color: var(--ink); }
.account-sub.soon { color: var(--warn); }
#expiredOut { justify-self: center; }

/* the account, at the top of the settings */
.account { display: grid; gap: 12px; padding: 14px; margin: 4px 0 8px; border: 1px solid var(--line); border-radius: 16px; background: var(--body); }
.account-who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.account-who > div { min-width: 0; }
.avatar { flex: none; inline-size: 44px; block-size: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--live-soft); color: var(--live); font-weight: 700; font-size: 1.15rem; }
.account-name { margin: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .hint { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.account-actions .btn { flex: 1 1 auto; text-align: center; text-decoration: none; }
.btn.danger-fill { background: var(--warn); border-color: var(--warn); color: var(--body); }
.account-actions a.btn { display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }

/* the owner's admin panel (/admin) */
.admin-page .shell { max-width: 46rem; }
.admin-tag { display: inline-block; margin-inline-start: 4px; padding: 0 10px; border-radius: 999px; background: var(--ink); color: var(--body); font-size: .8rem; vertical-align: middle; }
.admin-back { text-decoration: none; display: inline-flex; align-items: center; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0 6px; }
.stat { display: grid; gap: 0; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--body); }
.stat b { font-size: 1.35rem; font-variant-numeric: tabular-nums; line-height: 1.3; }
.stat span { font-size: .78rem; color: var(--muted); line-height: 1.35; }
.stat.alert { border-color: var(--warn); }
.stat.alert b { color: var(--warn); }
button.stat { font: inherit; color: inherit; text-align: start; cursor: pointer; transition: transform .1s; }
button.stat:active { transform: scale(.98); }
.admin-show { margin: 8px 0 10px; }
/* one account's subscription, with the owner's buttons */
.sub-box { display: grid; gap: 8px; margin: 12px 0 4px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; }
.sub-box[data-state="expired"], .sub-box[data-state="none"] { border-color: var(--warn); }
.sub-status { margin: 0; font-weight: 600; }
.sub-box[data-state="expired"] .sub-status, .sub-box[data-state="none"] .sub-status { color: var(--warn); }
.sub-box .hint { margin: 0; }
.sub-box .chips { margin: 0; }
.sub-date { display: flex; gap: 8px; }
.sub-date input { flex: 1 1 auto; min-width: 0; }
.sub-box .danger-line { margin-top: 0; }
.audit li.warn span { color: var(--warn); }
.admin-strip .btn.text { justify-self: start; padding-inline: 0; min-height: 36px; }
.admin-tabs button[aria-selected="true"] { background: var(--ink); color: var(--body); font-weight: 600; }
.admin-tabs { margin: 14px 0 10px; }
.admin-filter { margin: 0 0 10px; }
#aFind { margin-bottom: 10px; }
.admin-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.admin-list > li.muted { color: var(--muted); padding: 8px 2px; }
.admin-row { width: 100%; display: flex; align-items: flex-start; gap: 12px; padding: 12px; text-align: start; cursor: pointer;
  border: 1px solid var(--line); border-radius: 14px; background: var(--body); color: var(--ink); font: inherit; }
.admin-row:active { transform: scale(.99); }
.admin-main { display: grid; gap: 1px; min-width: 0; }
.admin-main b { font-weight: 600; }
.admin-main small { color: var(--muted); font-size: .8rem; overflow-wrap: anywhere; }
.avatar.small { inline-size: 38px; block-size: 38px; font-size: 1rem; }
.a-badge { display: inline-block; padding: 0 8px; border-radius: 999px; font-size: .7rem; font-weight: 600; background: var(--line); color: var(--ink); vertical-align: 1px; }
.a-badge.warn { background: var(--warn); color: var(--body); }
.a-badge.live { background: var(--live-soft); color: var(--live); }
.admin-strip { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--body); }
.admin-list.compact .admin-strip { padding: 10px; }
.a-dot { flex: none; inline-size: 10px; block-size: 10px; margin-top: 8px; border-radius: 50%; background: var(--muted); }
.a-dot.on { background: var(--live); box-shadow: 0 0 6px var(--live); }
.give { display: grid; gap: 4px; margin-top: 6px; font-size: .82rem; color: var(--muted); }
.give select { min-height: 40px; }
.pw-once { margin: 0; padding: 12px; border-radius: 12px; background: var(--live-soft); color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
.admin-facts { margin: 4px 0 6px; }
@media (max-width: 420px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.admin-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.admin-title .a-badge { flex: none; }

/* watches added in Settings */
.watch-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.watch-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; }
.watch-list li > span { display: grid; gap: 2px; min-width: 0; }
.watch-list bdi { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.watch-list small { color: var(--muted); font-size: .82rem; }
.watch-list .btn { color: var(--warn); flex: none; }
#watchCode { inline-size: 7.5em; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- energy (Denjin 3.0): what was used, from the server's history ---------- */
.spark { cursor: pointer; }
.sheet.energy { max-height: 94vh; min-height: 72vh; }
.en-head { display: flex; align-items: center; gap: 6px; margin-inline-end: -10px; }
.en-head #enBack { margin-inline-start: -10px; }
.en-titles { flex: 1; min-width: 0; }
.en-titles h2, .en-titles .hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.en-titles h2 { margin: 0; }
.en-icon { flex: none; inline-size: 40px; block-size: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--well); color: var(--c, var(--live)); }
.en-icon svg { inline-size: 22px; block-size: 22px; }
.flip { transform-box: fill-box; transform-origin: center; }
[dir="rtl"] .flip { transform: scaleX(-1); }
.en-range { margin-top: 6px; }
.en-nav { display: flex; align-items: center; gap: 4px; margin: 2px -10px 0; }
.en-nav .icon-btn:disabled { opacity: .28; cursor: default; }
.en-when { flex: 1; margin: 0; text-align: center; font-weight: 600; font-size: .95rem; }
.en-body { min-height: 320px; }
.en-main { display: grid; gap: 16px; transition: opacity .2s; }
.en-main.busy { opacity: .45; }
.en-hero { display: grid; }
.en-tl { margin: 0; font-size: .8rem; color: var(--muted); }
.en-big { display: flex; align-items: baseline; gap: 8px; margin: 2px 0 0; line-height: 1.05; }
.en-big b { font-size: 3rem; font-weight: 600; letter-spacing: -.01em; }
.en-big span { font-size: 1rem; color: var(--muted); }
.en-delta { display: flex; align-items: center; gap: 6px; margin: 8px 0 0; font-size: .88rem; color: var(--muted); }
.en-delta svg { flex: none; inline-size: 16px; block-size: 16px; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.en-delta.up svg { stroke: var(--warn); }
.en-delta.down svg { stroke: var(--live); }
.en-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.en-tile { min-width: 0; padding: 10px 12px; border-radius: 14px; background: var(--well); }
.en-tv { margin: 2px 0 0; font-size: 1.02rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.en-tv small { margin-inline-start: 4px; font-size: .74rem; font-weight: 400; color: var(--muted); }
.en-add { display: block; margin: 2px 0 0; padding: 0; border: 0; background: none; cursor: pointer; font-size: .95rem; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.en-trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.en-trio div { display: grid; padding: 0 4px; }
.en-trio small { color: var(--muted); font-size: .78rem; }
.en-trio b { font-size: .95rem; font-weight: 600; }
.en-chart { margin: 0; }
.en-cap { margin-bottom: 6px; font-size: .8rem; color: var(--muted); }
.en-plot { position: relative; min-height: 176px; }
.en-svg { display: block; inline-size: 100%; overflow: visible; touch-action: pan-y; direction: ltr; }   /* x and text-anchor as drawn, in both languages */
.en-svg:focus { outline: none; }
.en-svg:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 6px; }
.en-grid { stroke: var(--line); stroke-width: 1; }
.en-grid.base { stroke: var(--muted); stroke-opacity: .55; }
.en-ytick, .en-xtick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.en-peak { fill: var(--ink); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.en-bar { fill: var(--live); cursor: pointer; transition: opacity .15s, fill .35s; }
.en-bar.dim { opacity: .35; }
.en-tip {
  position: absolute; z-index: 2; display: grid; padding: 6px 10px; border-radius: 10px;
  background: var(--ink); color: var(--body); font-size: .8rem; line-height: 1.35; white-space: nowrap;
  pointer-events: none; box-shadow: 0 4px 14px rgba(0, 0, 0, .18);
}
.en-tip b { font-size: .95rem; }
.en-none { margin: 0; padding: 56px 12px; text-align: center; color: var(--muted); font-size: .9rem; }
.en-table summary { display: flex; align-items: center; min-height: 40px; cursor: pointer; font-size: .86rem; color: var(--muted); }
.en-table table { inline-size: 100%; border-collapse: collapse; font-size: .85rem; font-variant-numeric: tabular-nums; }
.en-table th { padding: 4px 0; border-bottom: 1px solid var(--line); text-align: start; font-size: .78rem; font-weight: 600; color: var(--muted); }
.en-table td { padding: 5px 0; border-bottom: 1px solid var(--line); }
.en-table th:not(:first-child), .en-table td:not(:first-child) { text-align: end; }
.en-list h3 { margin: 4px 0 4px; font-size: .95rem; }
.en-rows { list-style: none; margin: 0; padding: 0; }
.en-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "ico who amt" "ico bar bar";
  align-items: center; gap: 4px 12px; inline-size: 100%; padding: 10px 4px;
  border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; text-align: start;
  transition: background-color .15s;
}
.en-row:active { background: var(--well); }
.en-ico { grid-area: ico; inline-size: 38px; block-size: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--well); color: var(--c, var(--live)); }
.en-ico svg { inline-size: 20px; block-size: 20px; }
.en-who { grid-area: who; display: grid; min-width: 0; }
.en-who b, .en-who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.en-who b, .en-amt b { font-size: .93rem; font-weight: 600; }
.en-who small, .en-amt small { color: var(--muted); font-size: .78rem; }
.en-amt { grid-area: amt; display: grid; text-align: end; font-variant-numeric: tabular-nums; }
.en-share { grid-area: bar; block-size: 4px; border-radius: 2px; background: var(--live-soft); overflow: hidden; }
.en-share i { display: block; block-size: 100%; border-radius: 2px; background: var(--live); }
.en-goal { display: grid; gap: 14px; }
.en-meter { display: grid; gap: 6px; }
.en-ml { display: flex; justify-content: space-between; gap: 10px; margin: 0; font-size: .88rem; }
.en-ml span { color: var(--muted); font-variant-numeric: tabular-nums; }
.en-track { position: relative; block-size: 8px; border-radius: 4px; background: var(--live-soft); }
.en-track .fill { position: absolute; inset-block: 0; inset-inline-start: 0; border-radius: 4px; background: var(--live); }
.en-track .proj { position: absolute; inset-block: -4px; inline-size: 2px; margin-inline-start: -1px; border-radius: 1px; background: var(--ink); }
.en-meter.over .proj { background: var(--warn); }
.en-warn { inline-size: 15px; block-size: 15px; margin-inline-end: 4px; vertical-align: -2px; fill: none; stroke: var(--warn); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.en-link {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; inline-size: 100%; min-height: 44px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: transparent; cursor: pointer;
  font-size: .9rem; text-align: start;
}
.en-link .go { flex: none; font-weight: 600; }
.en-link .go::after { content: " ›"; }
[dir="rtl"] .en-link .go::after { content: " ‹"; }
#oEnergy { margin-top: 4px; }
.en-msg { display: grid; justify-items: center; gap: 12px; margin: 48px 0; text-align: center; }
.en-msg p { margin: 0; color: var(--muted); }
.en-price input:first-child { flex: 1; }
.en-cur { flex: none !important; inline-size: 5.5em; text-align: center; text-transform: uppercase; }

/* ---------- activity (Denjin 3.0): what happened, day by day, from the server's history ---------- */
.act-open {
  display: flex; align-items: center; justify-content: space-between; inline-size: 100%; min-height: 44px;
  padding: 0; border: 0; background: transparent; cursor: pointer; color: var(--ink);
  font: inherit; font-weight: 600; font-size: .95rem; text-align: start;
}
.act-open::after { content: "›"; color: var(--muted); font-weight: 400; font-size: 1.3rem; line-height: 1; }
[dir="rtl"] .act-open::after { content: "‹"; }
#oActivity { margin-top: 2px; }
.sheet.act { max-height: 94vh; min-height: 72vh; }
.act-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.sheet .act-f { display: grid; gap: 4px; margin: 0; min-width: 0; font-size: .8rem; font-weight: 600; color: var(--muted); }
.act-f select, .act-f input { min-height: 42px; padding: 8px 10px; font-size: .92rem; min-width: 0; }
/* a strip or outlet name too long for its half of the row ends with "…" instead of being cut */
.act-f select { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.act-clear { justify-self: start; }
.act-body { min-height: 30vh; }
.sheet .act-day h3 {
  position: sticky; top: 0; z-index: 1; margin: 10px 0 0; padding: 8px 0 6px;
  background: var(--body); color: var(--muted); font-size: .82rem; font-weight: 600;
}
.act-list { list-style: none; margin: 0; padding: 0; }
.act-row {
  display: grid; grid-template-columns: auto 18px 1fr; align-items: start; gap: 10px;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: .9rem; line-height: 1.4;
}
.act-row time { color: var(--muted); font-variant-numeric: tabular-nums; }
.act-ico { inline-size: 18px; block-size: 18px; margin-top: 1px; color: var(--muted); }
.act-ico .line { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.act-row[data-cat="on"] .act-ico, .act-row[data-cat="conn"] .act-ico { color: var(--live); }
.act-row[data-cat="warn"] .act-ico { color: var(--warn); }
.act-none { margin: 48px 0; text-align: center; color: var(--muted); }
.act-note { margin: 4px 0 0; padding: 8px 12px; border-radius: 12px; background: var(--well); font-size: .85rem; }
.act-more { display: flex; justify-content: center; margin: 16px 0 6px; }
