/* Aeronix: only the sensor readings. Colours and type follow Sawit Mandala (cream, garden green, yellow keyline,
   Fraunces for the name, Manrope for numbers); the floating controls are liquid glass over soft colour. */
@font-face {
  font-family: Manrope;
  font-weight: 400;
  src: url('/fonts/manrope-400.ttf') format('truetype');
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  font-weight: 600;
  src: url('/fonts/manrope-600.ttf') format('truetype');
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  font-weight: 700;
  src: url('/fonts/manrope-700.ttf') format('truetype');
  font-display: swap;
}

@font-face {
  font-family: Fraunces;
  font-weight: 700;
  src: url('/fonts/fraunces-700.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bg: #faf8ef;
  --green: #146c43;
  --deep: #174b35;
  --ink: #23382c;
  --muted: #53634f;
  --line: #c9d1bf;
  --yellow: #f6d365;
  --mint: #edf5df;
  --cream: #fff4cd;
  --rose: #ffe3dd;
  --clean: #146c43;
  --warn: #8a5a00;
  --alarm: #b3262b;
  --accent: #1f6fd6;
  --leaf: 24px 24px 24px 8px;
  --sans: Manrope, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: Fraunces, Georgia, serif;
  --gap: clamp(14px, 3vw, 28px);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body:has(.auth) {
  background: #fff;
}

body {
  min-height: 100vh;
  margin: 0;
  /* soft colour behind everything, so the glass has something to refract */
  background:
    radial-gradient(60vmax 40vmax at 8% -5%, #cfe8c6 0%, transparent 60%),
    radial-gradient(50vmax 36vmax at 100% 8%, #fbe6a0 0%, transparent 55%),
    radial-gradient(50vmax 40vmax at 40% 110%, #d6ebe0 0%, transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 16px/1.55 var(--sans);
}

h1,
h2,
p {
  margin: 0;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.vh {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 20;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--deep);
  color: #fff;
}

.skip:focus {
  top: 8px;
}

/* ---------- liquid glass ---------- */
.glass {
  border: 1px solid rgb(255 255 255 / 0.7);
  background: linear-gradient(135deg, rgb(255 255 255 / 0.62), rgb(255 255 255 / 0.34));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.9),
    inset 0 -1px 0 rgb(255 255 255 / 0.25),
    0 8px 28px rgb(23 75 53 / 0.14);
  -webkit-backdrop-filter: blur(18px) saturate(170%);
  backdrop-filter: blur(18px) saturate(170%);
}

@supports not (backdrop-filter: blur(1px)) {
  .glass {
    background: rgb(255 255 255 / 0.92);
  }
}

/* ---------- logo ---------- */
.logo {
  display: block;
  width: auto;
  height: 44px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

/* ---------- controls ---------- */
button,
select,
input {
  font: inherit;
  color: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--green);
  border-radius: 12px;
  background: transparent;
  color: var(--green);
  font-weight: 700;
  cursor: pointer;
  transition:
    background-color 0.15s,
    color 0.15s,
    transform 0.1s;
}

button:hover {
  background: var(--green);
  color: #fff;
}

button:active {
  transform: scale(0.96);
}

button.primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 3px 0 var(--deep);
}

button.primary:hover {
  background: var(--deep);
}

button.quiet {
  border-color: transparent;
  color: var(--deep);
  padding: 0 12px;
}

button.quiet:hover {
  background: rgb(23 75 53 / 0.1);
  color: var(--deep);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

input[type='text'],
input[type='password'] {
  min-height: 48px;
  width: 100%;
  padding: 0 14px;
  border: 1.5px solid #73836b;
  border-radius: 12px;
  background: #fff;
}

/* ---------- login and setup ---------- */
.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: 100vh;
}

.auth-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: clamp(24px, 5vw, 72px);
  background: #fff;
  color: var(--deep);
  text-align: center;
}

.auth-intro .logo {
  height: clamp(110px, 16vw, 210px);
  margin: 0 auto;
}

.auth-intro .mark {
  display: block;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--deep);
  font-size: clamp(40px, 5.4vw, 68px);
  letter-spacing: -0.02em;
}

.mark {
  font: 700 26px/1 var(--serif);
  letter-spacing: -0.01em;
}

.auth-intro p {
  max-width: 22ch;
  font: 700 clamp(28px, 3.4vw, 44px) / 1.15 var(--serif);
}

.auth-side {
  display: grid;
  place-items: center;
  padding: var(--gap);
}

.auth-form {
  display: grid;
  gap: 20px;
  width: min(100%, 440px);
  padding: 32px 34px 34px;
  border: 1px solid #aab6a3;
  border-top: 6px solid var(--yellow);
  border-radius: var(--leaf);
  background: #fff;
}

.auth-form h1 {
  font: 700 26px/1.2 var(--serif);
}

.stack {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 6px;
}

.field label {
  font-size: 14px;
  font-weight: 700;
}

.field .hint {
  color: var(--muted);
  font-size: 13px;
}

.field .err {
  color: var(--alarm);
  font-size: 14px;
  font-weight: 600;
}

.field.bad input {
  border-color: var(--alarm);
  box-shadow: 0 0 0 1px var(--alarm);
}

.pw {
  position: relative;
}

.pw input {
  padding-right: 52px;
}

.form-error {
  padding: 10px 12px;
  border-left: 4px solid var(--alarm);
  border-radius: 6px;
  background: var(--rose);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- dashboard: sidebar, content, dock ---------- */
.app {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
  background: var(--bg);
}

.side {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 26px 22px 18px;
  border-right: 1px solid var(--line);
  background: #fff;
  transition: width 0.25s;
}

.side-brand {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding-bottom: 6px;
}

.side-brand .logo {
  height: 64px;
}

.side-brand .mark {
  color: var(--deep);
  font-size: 28px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button,
.dock button {
  justify-content: flex-start;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  color: var(--ink);
  font-weight: 600;
}

.nav button:hover,
.dock button:hover {
  background: var(--mint);
  color: var(--ink);
}

.nav button[aria-current='page'] {
  background: var(--yellow);
  box-shadow: 0 3px 0 var(--deep);
  font-weight: 700;
}

svg {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-foot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--mint);
  color: var(--deep);
  font-weight: 700;
}

.who {
  display: grid;
  min-width: 0;
  line-height: 1.25;
}

.who b {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.who small {
  color: var(--muted);
  font-size: 12px;
}

.side-foot .quiet {
  min-height: 40px;
  padding: 0 8px;
  font-size: 13px;
}

.content {
  min-width: 0;
}

.content-top {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 84px;
  padding: 0 clamp(16px, 3vw, 44px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.icon-btn {
  width: 44px;
  padding: 0;
  border: 0;
  color: var(--ink);
}

.top-brand {
  display: none;
}

main {
  display: grid;
  gap: 18px;
  max-width: 1280px;
  padding: clamp(18px, 3vw, 44px) clamp(16px, 3vw, 44px) 56px;
}

.title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
}

.title-end {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.title-end button {
  min-height: 46px;
  border-radius: 14px 14px 14px 6px;
  background: var(--mint);
}

.title-end button:hover {
  background: var(--green);
}

.chip {
  padding: 4px 12px;
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
}

.chip.on {
  background: var(--mint);
  color: var(--clean);
}

.chip.off {
  background: var(--rose);
  color: var(--alarm);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 18px;
}

main > section[hidden] {
  display: none;
}

.dock,
.sheet {
  display: none;
}

@media (max-width: 899px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }

  .side,
  .icon-btn {
    display: none;
  }

  .content-top {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    padding: max(10px, env(safe-area-inset-top)) 16px 10px;
    background: rgb(255 255 255 / 0.85);
    -webkit-backdrop-filter: blur(16px) saturate(170%);
    backdrop-filter: blur(16px) saturate(170%);
  }

  .top-brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .top-brand .mark {
    color: var(--deep);
    font-size: 22px;
  }

  .sheet:not([hidden]) {
    position: fixed;
    left: 50%;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 74px);
    z-index: 20;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    width: min(380px, calc(100% - 24px));
    padding: 14px 14px 14px 16px;
    border-radius: var(--leaf);
    transform: translateX(-50%);
  }

  .dock {
    position: fixed;
    left: 50%;
    bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    width: min(300px, calc(100% - 24px));
    padding: 6px;
    border-radius: 999px;
    transform: translateX(-50%);
  }

  .dock button {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 13px;
  }

  .dock button[aria-current='page'] {
    background: var(--yellow);
    box-shadow: 0 2px 8px rgb(23 75 53 / 0.3);
  }

  .cards {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
    gap: 12px;
  }
}

/* collapsed sidebar (desktop): logo and icons only */
@media (min-width: 900px) {
  .app.collapsed {
    grid-template-columns: 84px minmax(0, 1fr);
  }

  .app.collapsed .side {
    padding-inline: 14px;
  }

  .app.collapsed .side-brand .mark,
  .app.collapsed .nav span,
  .app.collapsed .who,
  .app.collapsed .side-foot .quiet {
    display: none;
  }

  .app.collapsed .side-brand .logo {
    height: 44px;
  }

  .app.collapsed .nav button {
    justify-content: center;
    padding: 0;
  }

  .app.collapsed .side-foot {
    grid-template-columns: auto;
    justify-content: center;
  }
}

/* ---------- reading cards ---------- */
.card {
  --state: var(--clean);
  --tint: var(--mint);
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 220px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--leaf);
  background: var(--tint);
  color: var(--ink);
  font-weight: 400;
  text-align: left;
}

button.card {
  min-height: 220px;
  justify-content: stretch;
  width: 100%;
}

.card:hover {
  background: var(--tint);
  color: var(--ink);
}

button.card:hover,
.card[aria-pressed='true'] {
  border-color: var(--state);
  box-shadow: 0 0 0 1px var(--state);
}

.card[data-level='idle'] {
  --state: var(--muted);
  --tint: #fff;
}

.card[data-level='elevated'] {
  --state: var(--warn);
  --tint: var(--cream);
}

.card[data-level='smoke'] {
  --state: var(--alarm);
  --tint: var(--rose);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
}

.card-title svg {
  color: var(--ink);
}

.card .number {
  font: 700 clamp(48px, 5.4vw, 64px) / 1 var(--sans);
}

.card .number small {
  margin-left: 4px;
  font: 400 16px/1 var(--sans);
}

.card .meta {
  display: grid;
  gap: 2px;
  color: var(--warn);
  font-size: 15px;
}

.card .meta span:last-child {
  color: var(--muted);
}

.card[data-level='clean'] .meta,
.card[data-level='smoke'] .meta {
  color: var(--state);
}

.card[data-level='smoke'] svg {
  color: var(--alarm);
}

.history-ctl {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.history-ctl select {
  min-height: 44px;
  padding: 0 12px;
  border: 1.5px solid #73836b;
  border-radius: 12px;
  background: #fff;
  font: inherit;
}

/* ---------- history ---------- */
.history {
  display: grid;
  gap: 12px;
  padding: 18px 18px 14px;
  border-radius: var(--leaf);
  background: #fff;
  box-shadow: 0 2px 0 var(--line);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.history h2 {
  font: 700 18px/1.2 var(--serif);
}

.seg {
  display: flex;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
}

.seg button {
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  color: var(--deep);
  font-size: 14px;
}

.seg button:hover {
  background: rgb(255 255 255 / 0.7);
  color: var(--deep);
}

.seg button[aria-pressed='true'] {
  background: var(--green);
  color: #fff;
  box-shadow: 0 2px 8px rgb(20 108 67 / 0.35);
}

.chart-wrap {
  position: relative;
  height: clamp(210px, 32vw, 320px);
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y; /* scroll the page with one finger; tap or drag along the line to read a value */
}

.tip {
  position: absolute;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--deep);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
  transform: translate(-50%, -130%);
  white-space: nowrap;
}

.empty {
  padding: 40px 12px;
  color: var(--muted);
  font-size: 18px;
  text-align: center;
}

@media (max-width: 760px) {
  .auth {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .auth-intro {
    gap: 6px;
    padding: max(18px, env(safe-area-inset-top)) 18px 22px;
  }

  .auth-intro .logo {
    height: 84px;
  }

  .auth-intro .mark {
    font-size: 36px;
  }

  .auth-intro p {
    font-size: 22px;
  }

  .auth-side {
    place-items: start center;
    padding: 20px 14px max(32px, env(safe-area-inset-bottom));
  }

  .auth-form {
    padding: 22px 18px;
  }

  .logo {
    height: 38px;
  }

  .seg {
    width: 100%;
  }

  .seg button {
    flex: 1;
    padding: 0;
  }

  .history {
    padding: 14px 10px 10px;
  }

  .tick span {
    font-size: 10px;
  }
}

@media (min-width: 1100px) {
  .number {
    font-size: 104px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- show / hide password: the eye closes and opens ---------- */
.eye {
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  min-height: 48px;
  padding: 0;
  border: 0;
  border-radius: 0 12px 12px 0;
  background: transparent;
  color: var(--deep);
}

.eye:hover {
  background: rgb(23 75 53 / 0.08);
  color: var(--deep);
}

.eye svg {
  width: 26px;
  height: 26px;
  overflow: visible;
}

.eye .pupil {
  fill: currentColor;
  transform-origin: 12px 12px;
  transition: transform 0.2s;
}

.eye .slash {
  stroke-dasharray: 1;
  stroke-dashoffset: 0; /* hidden password: eye crossed out */
  transition: stroke-dashoffset 0.25s;
}

.eye[aria-pressed='true'] .slash {
  stroke-dashoffset: 1; /* visible: the slash draws away, the eye is open */
}

.eye[aria-pressed='false'] .pupil {
  transform: scale(0.6);
}

.eye.blink .lid {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink-eye 0.25s ease;
}

@keyframes blink-eye {
  50% {
    transform: scaleY(0.1);
  }
}

/* the page title sits under the top bar */
main h1 {
  color: var(--deep);
  font: 700 clamp(28px, 4.2vw, 50px) / 1.1 var(--serif);
  letter-spacing: -0.02em;
}

.title-row {
  align-items: center;
  justify-content: space-between;
}

/* ---------- time range: liquid-glass track with a draggable lens ---------- */
.seg {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  width: 460px;
  max-width: 100%;
  padding: 4px;
  border-radius: 999px;
  cursor: grab;
  touch-action: pan-y; /* the page still scrolls vertically; sideways moves drag the lens */
  user-select: none;
  -webkit-user-select: none;
}

.seg.dragging {
  cursor: grabbing;
}

.seg button {
  position: relative;
  z-index: 1;
  min-height: 42px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--deep);
  font-size: 14px;
  transition: color 0.2s;
}

.seg button:hover {
  background: transparent;
  color: var(--deep);
}

.seg button[aria-pressed='true'],
.seg button.near {
  background: transparent;
  box-shadow: none;
  color: #fff;
}

.seg.dragging button[aria-pressed='true']:not(.near) {
  color: var(--deep);
}

.lens {
  position: absolute;
  z-index: 0;
  top: 4px;
  bottom: 4px;
  left: var(--pad, 4px);
  width: calc((100% - 2 * var(--pad, 4px)) / var(--n, 5));
  border-radius: 999px;
  background: linear-gradient(180deg, rgb(40 150 98 / 0.96), rgb(20 108 67 / 0.96));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.55),
    inset 0 -1px 0 rgb(0 0 0 / 0.14),
    0 4px 14px rgb(20 108 67 / 0.42);
  /* `translate` (not `transform`) moves the lens: the `scale` used while dragging would otherwise stretch the offset and push the lens past its slot */
  translate: calc(var(--i, 0) * 100%) 0;
  transition:
    translate 0.35s cubic-bezier(0.22, 1.2, 0.36, 1),
    scale 0.2s;
  pointer-events: none;
}

.seg.dragging .lens,
.dock.dragging .lens {
  transition: scale 0.2s;
  scale: 1.06;
}

/* ---------- rooms in the sidebar ---------- */
.rooms {
  display: grid;
  gap: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.room {
  --state: var(--muted);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  color: var(--ink);
  font-weight: 600;
  text-align: left;
}

.room:hover {
  background: var(--mint);
  color: var(--ink);
}

.room[aria-pressed='true'] {
  background: var(--mint);
  box-shadow: inset 0 0 0 1.5px var(--green);
  color: var(--ink);
}

.room[data-level='clean'] {
  --state: var(--clean);
}

.room[data-level='elevated'] {
  --state: var(--warn);
}

.room[data-level='smoke'] {
  --state: var(--alarm);
}

.room .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--state);
}

.room[data-level='elevated'] .dot {
  border-radius: 0;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.room[data-level='smoke'] .dot {
  border-radius: 0;
  transform: rotate(45deg) scale(0.85);
  animation: blink 1s steps(2, jump-none) infinite;
}

.room b {
  font-variant-numeric: tabular-nums;
}

@media (min-width: 900px) {
  .app.collapsed .room {
    grid-template-columns: auto;
    justify-content: center;
    padding: 0;
  }

  .app.collapsed .room-name,
  .app.collapsed .room b {
    display: none;
  }
}

@media (max-width: 899px) {
  .rooms {
    display: none;
  }
}

/* ---------- phone: nothing wider than the screen ---------- */
main {
  grid-template-columns: minmax(0, 1fr);
}

.history,
.history-head,
.history-ctl {
  min-width: 0;
}

@media (max-width: 899px) {
  .seg {
    width: 100%;
  }

  .cards {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  /* a room is one compact row: name and status on the left, the number on the right */
  .card,
  button.card {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      'title num'
      'meta num';
    align-items: center;
    gap: 4px 12px;
    min-height: 0;
    padding: 14px 16px;
  }

  .card .card-title {
    grid-area: title;
  }

  .card .number {
    grid-area: num;
    font-size: 46px;
  }

  .card .meta {
    grid-area: meta;
  }
}

/* ---------- phone dock: the same lens, in yellow ---------- */
.dock {
  position: fixed;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}

.dock button {
  position: relative;
  z-index: 1;
}

.dock button[aria-current='page'] {
  background: transparent;
  box-shadow: none;
}

.dock .lens {
  background: linear-gradient(180deg, rgb(255 234 150 / 0.96), rgb(246 211 101 / 0.94));
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.85),
    inset 0 -1px 0 rgb(0 0 0 / 0.08),
    0 4px 14px rgb(176 138 24 / 0.4);
}

/* ---------- assistant popup ---------- */
.chat-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  gap: 8px;
  min-height: 52px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  background: var(--yellow);
  box-shadow: 0 3px 0 var(--deep), 0 8px 20px rgb(23 75 53 / 0.25);
  color: var(--deep);
}

.chat-fab:hover {
  background: #fbdf7e;
  color: var(--deep);
}

.chat {
  position: fixed;
  right: 24px;
  bottom: 92px;
  z-index: 30;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  width: min(380px, calc(100vw - 32px));
  height: min(460px, calc(100vh - 120px));
  border: 1px solid var(--line);
  border-radius: var(--leaf);
  background: #fff;
  box-shadow: 0 14px 40px rgb(23 75 53 / 0.22);
  overflow: hidden;
}

.chat[hidden] {
  display: none;
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--mint);
}

.chat-head h2 {
  font: 700 17px/1.2 var(--serif);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  overflow-y: auto;
}

.bubble {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 16px 16px 16px 4px;
  background: var(--mint);
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble.me {
  align-self: flex-end;
  border-radius: 16px 16px 4px 16px;
  background: var(--green);
  color: #fff;
}

.bubble.wait {
  color: var(--muted);
}

.chat-tips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 8px;
}

.chat-tips[hidden] {
  display: none;
}

.chat-tips button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 13px;
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line);
}

.chat-form input {
  min-height: 46px;
  padding: 0 14px;
  border: 1.5px solid #73836b;
  border-radius: 14px;
  background: #fff;
  font: inherit;
}

.chat-form button {
  width: 48px;
  padding: 0;
  border-radius: 14px;
}

@media (max-width: 899px) {
  .chat-fab {
    right: 14px;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 84px);
    min-height: 48px;
  }

  .chat {
    right: 12px;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 142px);
    width: calc(100vw - 24px);
    height: min(440px, 44dvh);
  }
}

/* ---------- device code page ---------- */
.view {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.view[hidden] {
  display: none;
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.code-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.code-tabs button {
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 14px;
}

.code-path {
  color: var(--muted);
  font: 600 14px/1.2 var(--sans);
}

.code-box {
  max-height: 68vh;
  margin: 0;
  padding: 16px 18px;
  overflow: auto;
  border-radius: var(--leaf);
  background: #14323a;
  color: #e6f6f1;
  font: 13px/1.55 ui-monospace, 'Cascadia Mono', Consolas, 'Liberation Mono', monospace;
  tab-size: 2;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 899px) {
  .dock {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: min(380px, calc(100% - 24px));
  }

  .code-box {
    max-height: 62vh;
    padding: 12px;
    font-size: 12px;
  }
}

.title-end[hidden] {
  display: none;
}

.code-tabs button[aria-pressed='true'] {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.bubble-note {
  max-width: 85%;
  margin-top: -4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

/* ======================================================================================================
   Revision: layout and finish follow BlockStudio (flat frosted glass, hairline edges, no shadows, one
   even type weight, one corner radius, line icons); the colours stay Aeronix (cream, garden green).
   ====================================================================================================== */
:root {
  --r: 16px;
  --leaf: 16px;
  --glass: linear-gradient(180deg, rgb(255 255 255 / 0.82), rgb(255 255 255 / 0.46));
  --edge: rgb(23 75 53 / 0.14);
}

/* even type: Manrope everywhere, 500 for text and 600 for emphasis; the serif stays only on the name */
h1,
h2,
.auth-form h1,
.history h2,
.chat-head h2 {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.title-row h1 {
  font-size: clamp(22px, 2.6vw, 28px);
  line-height: 1.2;
}
button,
.field label,
.chip,
.who b,
.avatar,
.tip,
.nav button[aria-current='page'],
.card .number {
  font-weight: 600;
}
.card .number {
  font-size: clamp(40px, 4.4vw, 54px);
}
.card-title {
  font-weight: 500;
}

/* glass surfaces: one recipe, shine kept, no shadow */
.glass,
.side,
.content-top,
.dock,
.sheet,
.chat,
.chat-fab,
.history,
.card,
.auth-form {
  box-shadow: none;
}
.glass,
.dock,
.sheet,
.chat {
  border: 1px solid var(--edge);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}
.side {
  background: linear-gradient(180deg, rgb(255 255 255 / 0.78), rgb(255 255 255 / 0.5));
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}
.content-top {
  height: 64px;
  background: transparent;
  border-bottom: 1px solid var(--edge);
}

/* buttons: one radius, outline by default, solid green only for the main action */
button {
  border-radius: 12px;
  font-size: 14px;
}
button.primary,
button.primary:hover {
  box-shadow: none;
  border-color: transparent;
  background: linear-gradient(180deg, color-mix(in srgb, var(--green) 82%, #fff), var(--green));
  color: #fff;
}
button.primary:hover {
  background: var(--deep);
}
.title-end button {
  min-height: 40px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: var(--glass);
  color: var(--deep);
}
.title-end button:hover {
  background: rgb(20 108 67 / 0.1);
  color: var(--deep);
}

/* navigation: active item is a green glass pill instead of the yellow block with a hard shadow */
.nav button,
.dock button {
  min-height: 44px;
  border-radius: 12px;
  font-weight: 500;
}
.nav button[aria-current='page'],
.dock button[aria-current='page'] {
  border: 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--green) 82%, #fff), var(--green));
  box-shadow: none;
  color: #fff;
}
.nav button:hover:not([aria-current='page']),
.dock button:hover:not([aria-current='page']) {
  background: rgb(20 108 67 / 0.08);
}

/* rooms list in the sidebar */
.rooms button {
  min-height: 42px;
  border-radius: 12px;
  font-weight: 500;
}

/* status chip: small pill with a dot */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  min-height: 40px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--glass);
  font-size: 13px;
}
.chip::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.chip.on {
  color: var(--clean);
}
.chip.off {
  color: var(--alarm);
}
.chip:not(.on):not(.off) {
  color: var(--muted);
}

/* reading cards: a frosted card, the state is a coloured dot in the title and the edge, not a heavy tint */
.card {
  --tint: rgb(255 255 255 / 0.62);
  min-height: 0;
  gap: 10px;
  padding: 18px 20px;
  border: 1px solid var(--edge);
  border-radius: var(--r);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}
button.card {
  min-height: 0;
}
.card:hover {
  background: var(--glass);
}
button.card:hover,
.card[aria-pressed='true'] {
  border-color: var(--state);
  box-shadow: none;
}
.card[aria-pressed='true'] {
  background: linear-gradient(180deg, color-mix(in srgb, var(--state) 14%, #fff), color-mix(in srgb, var(--state) 6%, #fff));
}
.card[data-level='idle'] {
  --tint: rgb(255 255 255 / 0.62);
}
.card[data-level='elevated'] {
  --tint: rgb(255 255 255 / 0.62);
}
.card[data-level='smoke'] {
  --tint: rgb(255 255 255 / 0.62);
}
.card[data-level='elevated']:not([aria-pressed='true']),
.card[data-level='smoke']:not([aria-pressed='true']) {
  border-color: color-mix(in srgb, var(--state) 55%, transparent);
}
.card-title {
  font-size: 15px;
}
.card .number small {
  font-size: 13px;
  color: var(--muted);
}
.card .meta {
  font-size: 13px;
  font-weight: 500;
}

/* chart panel and range switch */
.history {
  padding: 16px 18px 12px;
  border: 1px solid var(--edge);
  border-radius: var(--r);
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}
.seg {
  border-radius: 14px;
  padding: 3px;
}
.seg button {
  min-height: 36px;
  border-radius: 11px;
  font-weight: 500;
}
.seg button[aria-pressed='true'] {
  background: linear-gradient(180deg, color-mix(in srgb, var(--green) 82%, #fff), var(--green));
  box-shadow: none;
  font-weight: 600;
}

/* assistant */
.chat-fab,
.chat-fab:hover {
  border: 1px solid var(--edge);
  background: var(--glass);
  color: var(--deep);
  box-shadow: none;
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}
.chat-fab:hover {
  background: rgb(20 108 67 / 0.1);
}
.chat {
  box-shadow: none;
  border-radius: var(--r);
}
.chat-tips button {
  border-radius: 999px;
  font-weight: 500;
}

/* mobile dock and account sheet */
@media (max-width: 899px) {
  .dock {
    border-radius: 18px;
    padding: 5px;
  }
  .dock button {
    min-height: 48px;
    border-radius: 14px;
    font-size: 12px;
  }
  .sheet:not([hidden]) {
    border-radius: var(--r);
  }
  .content-top {
    height: auto;
    background: rgb(250 248 239 / 0.7);
  }
}

/* login and setup */
.auth-intro {
  background: transparent;
}
.auth-form {
  border: 1px solid var(--edge);
  border-top: 1px solid var(--edge);
  border-radius: 20px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
}
.auth-form h1 {
  font-size: 22px;
}
body:has(.auth) {
  background:
    radial-gradient(60vmax 40vmax at 8% -5%, #cfe8c6 0%, transparent 60%),
    radial-gradient(50vmax 36vmax at 100% 8%, #fbe6a0 0%, transparent 55%), var(--bg);
}
input[type='text'],
input[type='password'] {
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: rgb(255 255 255 / 0.7);
}
input[type='text']:focus,
input[type='password']:focus {
  border-color: var(--green);
  outline-offset: 1px;
}

/* sliding lens (range switch and mobile dock): flat green glass, no glow */
.lens {
  border-radius: 11px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--green) 82%, #fff), var(--green));
  box-shadow: none;
}
.dock .lens {
  border-radius: 14px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--green) 82%, #fff), var(--green));
  box-shadow: none;
}
.seg button,
.seg button[aria-pressed='true'] {
  background: transparent;
  box-shadow: none;
}
.dock button[aria-current='page'] {
  background: transparent;
  color: #fff;
}
.dock button:hover:not([aria-current='page']) {
  background: transparent;
}
.seg button {
  font-weight: 500;
}
.seg button[aria-pressed='true'] {
  font-weight: 600;
}

/* rooms in the sidebar */
.room {
  min-height: 42px;
  border-radius: 12px;
  font-weight: 500;
}
.room b,
.room strong {
  font-weight: 600;
}
.room[aria-pressed='true'] {
  background: rgb(20 108 67 / 0.1);
  box-shadow: none;
  border: 1px solid rgb(20 108 67 / 0.35);
}
.rooms {
  border-top: 1px solid var(--edge);
}
.side-foot {
  border-top: 1px solid var(--edge);
}

/* the school crest has a white background: let it melt into the cream */
.logo {
  mix-blend-mode: multiply;
}

/* assistant button: same clean glass as the rest */
.chat-fab {
  min-height: 46px;
  padding: 0 18px;
  font-weight: 600;
}
.chat-head {
  border-bottom: 1px solid var(--edge);
}

/* title in the same sans as everything else; crest is now transparent so no blend trick is needed */
.title-row h1,
#pageTitle {
  font-family: var(--sans);
  font-weight: 600;
}
.logo {
  mix-blend-mode: normal;
}

/* ---- second pass ---- */
/* the name uses the same sans as the rest, semi-bold instead of the heavy serif */
.mark,
.side-brand .mark,
.top-brand .mark,
.auth-intro .mark {
  font-family: var(--sans);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.side-brand .mark {
  font-size: 24px;
}
.auth-intro .mark {
  border-bottom: 0;
  padding-bottom: 0;
  font-size: clamp(34px, 4.4vw, 52px);
}
.side-brand {
  gap: 10px;
  padding-top: 4px;
}
.side-brand .logo {
  height: 60px;
}

/* a room with no sensor yet: quiet card, no giant placeholder */
.card[data-level='idle'] .number {
  color: var(--muted);
  font-weight: 500;
}
.card[data-level='idle'] .meta span {
  color: var(--muted);
}
.card[data-level='idle'][aria-pressed='true'] {
  --state: var(--green);
  border-color: rgb(20 108 67 / 0.45);
  background: linear-gradient(180deg, rgb(20 108 67 / 0.1), rgb(20 108 67 / 0.04));
}
.room[data-level='idle'] .dot {
  opacity: 0.35;
}
.room b {
  font-weight: 600;
}
.room[data-level='idle'] b {
  color: var(--muted);
  font-weight: 500;
}

/* page header: title and actions on one tidy line */
.title-row {
  align-items: center;
  padding-bottom: 4px;
}
.chip {
  font-weight: 500;
}

/* ======================================================================================================
   Imitech look: ink black, cream and orange (the Kas Dewayani palette), flat frosted glass with hairline
   edges and no shadows as on imitech.my.id. Status colours stay readable: green clean, amber elevated,
   red smoke. This block comes last and replaces the garden-green colours above.
   ====================================================================================================== */
:root {
  color-scheme: dark;
  --bg: #111111;
  --ink: #f3eee3;
  --muted: #a8a399;
  --line: #3d3a36;
  --green: #d9541e;
  --deep: #f3eee3;
  --yellow: #d9541e;
  --mint: #1c1b1a;
  --cream: #2a2418;
  --rose: #2d1b19;
  --clean: #5fbf86;
  --warn: #e8b04a;
  --alarm: #ff6b5e;
  --accent: #ef7a4a;
  --glass: linear-gradient(180deg, rgb(var(--fg) / 0.08), rgb(var(--fg) / 0.03));
  --edge: rgb(var(--fg) / 0.13);
  --on-accent: #111111;
  --fg: 243 238 227;
  --bg-rgb: 17 17 17;
  --panel: 28 27 26;
  --panel2: 20 20 19;
  --sheet: 44 42 40;
  --sheet2: 30 29 28;
  --code: 0 0 0;
  --warn-rgb: 232 176 74;
  --alarm-rgb: 255 107 94;
}
body,
body:has(.auth) {
  background:
    radial-gradient(60vmax 36vmax at 100% -6%, rgb(217 84 30 / 0.16), transparent 60%),
    radial-gradient(50vmax 36vmax at -4% 110%, rgb(217 84 30 / 0.07), transparent 60%), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
}
.app {
  background: transparent;
}
.skip {
  background: var(--green);
  color: var(--on-accent);
}

/* surfaces */
.glass,
.dock,
.sheet,
.chat,
.chat-fab,
.history,
.card,
.auth-form,
.chip,
.title-end button {
  border-color: var(--edge);
  background: var(--glass);
}
.side {
  background: linear-gradient(180deg, rgb(var(--panel) / 0.85), rgb(var(--panel2) / 0.7));
  border-right: 1px solid var(--edge);
}
.content-top {
  border-bottom: 1px solid var(--edge);
}
.chat {
  background: rgb(var(--panel) / 0.94);
}
.chat-head {
  background: transparent;
  border-bottom: 1px solid var(--edge);
}
.chat-form {
  border-top: 1px solid var(--edge);
}
.chat-form input {
  border: 1px solid var(--edge);
  background: rgb(var(--fg) / 0.05);
}
.chat-head h2 {
  font: 600 16px/1.2 var(--sans);
}
.bubble {
  background: rgb(var(--fg) / 0.08);
}
.bubble.me {
  background: var(--green);
  color: var(--on-accent);
}

/* text and brand */
.mark,
.side-brand .mark,
.top-brand .mark,
.auth-intro .mark,
.auth-intro {
  color: var(--ink);
}
.avatar {
  background: rgb(var(--fg) / 0.1);
  color: var(--ink);
}
.who small,
.field .hint {
  color: var(--muted);
}

/* buttons */
button {
  border-color: var(--edge);
  color: var(--ink);
}
button:hover {
  background: rgb(var(--fg) / 0.08);
  color: var(--ink);
}
button.quiet,
button.quiet:hover {
  color: var(--ink);
}
button.quiet:hover {
  background: rgb(var(--fg) / 0.08);
}
button.primary,
button.primary:hover {
  background: linear-gradient(180deg, #ef7a4a, #d9541e);
  color: var(--on-accent);
}
button.primary:hover {
  background: #ef7a4a;
}
.title-end button,
.title-end button:hover {
  color: var(--ink);
}
.title-end button:hover {
  background: rgb(var(--fg) / 0.08);
}
.code-tabs button[aria-pressed='true'] {
  border-color: var(--green);
  background: var(--green);
  color: var(--on-accent);
}

/* navigation: the active item is orange glass with dark text */
.nav button,
.dock button {
  color: var(--ink);
}
.nav button[aria-current='page'] {
  background: linear-gradient(180deg, #ef7a4a, #d9541e);
  color: var(--on-accent);
}
.nav button:hover:not([aria-current='page']),
.dock button:hover:not([aria-current='page']) {
  background: rgb(var(--fg) / 0.07);
}
.dock button[aria-current='page'] {
  color: var(--on-accent);
}
.lens,
.dock .lens {
  background: linear-gradient(180deg, #ef7a4a, #d9541e);
  box-shadow: none;
}
.seg button {
  color: var(--ink);
}
.seg button[aria-pressed='true'],
.seg button.near {
  color: var(--on-accent);
}
.seg.dragging button[aria-pressed='true']:not(.near) {
  color: var(--ink);
}

/* rooms */
.room {
  color: var(--ink);
}
.room:hover {
  background: rgb(var(--fg) / 0.07);
  color: var(--ink);
}
.room[aria-pressed='true'] {
  background: rgb(217 84 30 / 0.14);
  border: 1px solid rgb(217 84 30 / 0.5);
}
.rooms,
.side-foot {
  border-top: 1px solid var(--edge);
}

/* chip */
.chip.on {
  color: var(--clean);
}
.chip.off {
  color: var(--alarm);
}
.chip:not(.on):not(.off) {
  color: var(--muted);
}

/* reading cards */
.card {
  color: var(--ink);
}
button.card:hover,
.card[aria-pressed='true'] {
  border-color: var(--state);
}
.card[aria-pressed='true'] {
  background: linear-gradient(180deg, color-mix(in srgb, var(--state) 20%, var(--bg)), color-mix(in srgb, var(--state) 8%, var(--bg)));
}
.card[data-level='idle'][aria-pressed='true'] {
  --state: var(--green);
  border-color: rgb(217 84 30 / 0.5);
  background: linear-gradient(180deg, rgb(217 84 30 / 0.16), rgb(217 84 30 / 0.05));
}
.card .number small,
.card[data-level='idle'] .number,
.card[data-level='idle'] .meta span {
  color: var(--muted);
}
.card[data-level='elevated'] .meta {
  color: var(--warn);
}
.card .meta span:last-child {
  color: var(--muted);
}
.card-title svg {
  color: var(--ink);
}
.card[data-level='smoke'] svg {
  color: var(--alarm);
}

/* chart extras */
.tip {
  background: var(--ink);
  color: var(--bg);
}

/* forms */
input[type='text'],
input[type='password'],
.history-ctl select {
  border: 1px solid var(--edge);
  background: rgb(var(--fg) / 0.05);
  color: var(--ink);
}
input::placeholder {
  color: var(--muted);
}
input[type='text']:focus,
input[type='password']:focus {
  border-color: var(--green);
}
.form-error {
  background: var(--rose);
  color: var(--ink);
}
.eye,
.eye:hover {
  color: var(--ink);
}
.eye:hover {
  background: rgb(var(--fg) / 0.08);
}
body:has(.auth) .auth-intro {
  background: transparent;
}

/* source code view */
.code-box {
  border: 1px solid var(--edge);
  background: rgb(var(--code) / 0.35);
  color: var(--ink);
}

/* mobile bar */
@media (max-width: 899px) {
  .content-top {
    background: rgb(var(--bg-rgb) / 0.72);
  }
  .dock {
    background: linear-gradient(180deg, rgb(var(--sheet) / 0.85), rgb(var(--sheet2) / 0.78));
  }
}

/* account sheet over the dock: nearly opaque so the cards behind do not show through */
.sheet,
.sheet.glass {
  background: linear-gradient(180deg, rgb(var(--sheet) / 0.97), rgb(var(--sheet2) / 0.97));
}

/* account panel open: the lens sits on "Akun", so the page item goes back to light text, and the assistant button gets out of the way */
.dock:has(#accountBtn[aria-expanded='true']) button[aria-current='page'] {
  color: var(--ink);
}
.dock #accountBtn[aria-expanded='true'] {
  color: var(--on-accent);
}
body:has(.sheet:not([hidden])) .chat-fab {
  display: none;
}


/* ======================================================================================================
   Light mode: the Kas Dewayani palette (cream, ink, orange). Dark stays the default.
   ====================================================================================================== */
html[data-theme='light'] {
  color-scheme: light;
  --bg: #f3eee3;
  --bg-rgb: 243 238 227;
  --ink: #111111;
  --muted: #6b665e;
  --line: #d6cfbf;
  --deep: #111111;
  --mint: #fbf8f1;
  --cream: #f3e6c3;
  --rose: #f6dcd6;
  --clean: #1f8a55;
  --warn: #9a6200;
  --alarm: #c8362b;
  --accent: #d9541e;
  --glass: linear-gradient(180deg, rgb(255 255 255 / 0.78), rgb(255 255 255 / 0.46));
  --edge: rgb(17 17 17 / 0.13);
  --fg: 17 17 17;
  --panel: 255 253 248;
  --panel2: 250 246 238;
  --sheet: 255 253 248;
  --sheet2: 248 243 233;
  --code: 255 255 255;
  --warn-rgb: 154 98 0;
  --alarm-rgb: 200 54 43;
}
html[data-theme='light'] body,
html[data-theme='light'] body:has(.auth) {
  background:
    radial-gradient(60vmax 36vmax at 100% -6%, rgb(217 84 30 / 0.12), transparent 60%),
    radial-gradient(50vmax 36vmax at -4% 110%, rgb(217 84 30 / 0.06), transparent 60%), var(--bg);
  background-attachment: fixed;
}
/* dark mode: the crest as white line art; light mode: the original colour crest */
/* (the colour crest is used in both modes) */

/* ---------- theme button ---------- */
.theme-btn {
  width: 44px;
  min-height: 44px;
  padding: 0;
  margin-left: auto;
  border-radius: 12px;
  border: 1px solid var(--edge);
  background: var(--glass);
  color: var(--ink);
}
.theme-btn .i-sun {
  display: none;
}
html[data-theme='light'] .theme-btn .i-moon {
  display: none;
}
html[data-theme='light'] .theme-btn .i-sun {
  display: block;
}
.theme-btn.floating {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  z-index: 40;
}

/* ---------- logout: same glass as the other buttons ---------- */
.side-foot .quiet,
.side-foot .quiet:hover {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: var(--glass);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}
.side-foot .quiet:hover {
  background: rgb(var(--fg) / 0.08);
}

/* ---------- one room at a time: reading, alert, limits ---------- */
.room-top {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  grid-template-areas:
    'card alert'
    'card limits';
  gap: 16px;
  align-items: stretch;
}
.room-top .cards {
  grid-area: card;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.room-top .card {
  align-content: center;
  min-height: 100%;
}
.room-top .card .number {
  font-size: clamp(52px, 6vw, 76px);
}
.alert {
  grid-area: alert;
  --state: var(--muted);
  display: grid;
  gap: 8px;
  padding: 18px 20px;
  border: 1px solid var(--edge);
  border-left: 4px solid var(--state);
  border-radius: var(--r);
  background: var(--glass);
}
.alert[data-level='clean'] {
  --state: var(--clean);
}
.alert[data-level='elevated'] {
  --state: var(--warn);
}
.alert[data-level='smoke'] {
  --state: var(--alarm);
  background: linear-gradient(180deg, rgb(var(--alarm-rgb) / 0.2), rgb(var(--alarm-rgb) / 0.08));
}
.alert-head {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--state);
  font-size: 20px;
  font-weight: 600;
}
.alert-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}
.alert[data-level='smoke'] .alert-dot {
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}
.alert p {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}
.gauge {
  position: relative;
  height: 8px;
  margin-top: 4px;
  border-radius: 999px;
  background: rgb(var(--fg) / 0.1);
}
.gauge .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--v, 0%);
  border-radius: 999px;
  background: var(--state);
  transition: width 0.4s;
}
.gauge .tick {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: rgb(var(--fg) / 0.55);
}
.gauge .tick.warn {
  left: var(--w, 40%);
}
.gauge .tick.alarm {
  left: var(--a, 60%);
}
.gauge-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}
.limits {
  grid-area: limits;
  display: grid;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--r);
}
.limits-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.limits-head h2 {
  font-size: 16px;
}
.limits-head small,
.limits-note {
  color: var(--muted);
  font-size: 12px;
}
.limits-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.limits-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.limits-form input {
  min-height: 44px;
  width: 100%;
  padding: 0 12px;
  border: 1px solid var(--edge);
  border-radius: 12px;
  background: rgb(var(--fg) / 0.05);
  color: var(--ink);
  font: 600 16px var(--sans);
}
.limits-form input:focus {
  border-color: var(--green);
}
.limits-form .primary {
  min-height: 44px;
}
.limits-note:empty {
  display: none;
}
.limits-note[data-bad='true'] {
  color: var(--alarm);
}
@media (max-width: 899px) {
  .room-top {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'card'
      'alert'
      'limits';
    gap: 12px;
  }
  .room-top .card {
    min-height: 0;
  }
  .limits-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .limits-form .primary {
    grid-column: 1 / -1;
  }
  /* five stops: R1 R2 R3 Source Akun */
  .dock {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: min(420px, calc(100% - 24px));
  }
  .dock button {
    gap: 2px;
    padding: 0 2px;
  }
}

/* ---------- theme switch: a liquid-glass lens on a pill (drag it, or tap) ---------- */
.theme-switch {
  --on: 0;
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  width: 82px;
  height: 44px;
  margin-left: auto;
  padding: 3px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  backdrop-filter: blur(20px) saturate(160%);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.theme-switch[aria-checked='true'] {
  --on: 1;
}
.theme-switch:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.theme-switch .ts-lens {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ef7a4a, #d9541e);
  translate: var(--drag, calc(var(--on) * 38px)) 0;
  transition: translate 0.35s cubic-bezier(0.22, 1.2, 0.36, 1), scale 0.2s;
}
.theme-switch.dragging .ts-lens {
  transition: scale 0.2s;
  scale: 1.1;
}
.theme-switch svg {
  position: relative;
  z-index: 1;
  width: 18px;
  height: 18px;
  margin: 0 9px;
  color: var(--ink);
  transition: color 0.25s;
}
.theme-switch .i-moon {
  margin-right: 0;
}
.theme-switch .i-sun {
  margin-left: auto;
  display: block;
}
.theme-switch[aria-checked='false'] .i-moon,
.theme-switch[aria-checked='true'] .i-sun {
  color: var(--on-accent);
}
/* the old button rules no longer apply; the floating variant sits top right on the sign-in pages */
.theme-switch.floating {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  z-index: 40;
}
html[data-theme='light'] .theme-switch .i-moon,
html[data-theme='light'] .theme-switch .i-sun {
  display: block;
}

/* room card: name at the top, the reading in the middle, the state line at the bottom */
.room-top .card {
  align-content: stretch;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
}
.room-top .card .number {
  align-self: center;
}
@media (max-width: 899px) {
  .room-top .card {
    grid-template-rows: none;
  }
  .room-top .card .number {
    align-self: auto;
  }
}

/* the room name is not repeated as a page title: the chip and Perbarui sit at the right */
.title-end {
  margin-left: auto;
}

/* collapsed sidebar: each room is its status dot with R1, R2, R3 under it */
@media (min-width: 900px) {
  .app.collapsed .room {
    grid-template-columns: auto;
    justify-items: center;
    align-content: center;
    gap: 4px;
    min-height: 54px;
    padding: 6px 0;
  }
  .app.collapsed .room::after {
    content: attr(data-short);
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
  }
}

/* top bar on desktop: collapse button on the left, status chip + Perbarui + theme switch on the right */
.top-actions {
  display: none;
}
@media (min-width: 900px) {
  .top-actions {
    display: flex;
    align-items: center;
    margin-left: auto;
  }
  .top-actions .title-end {
    margin-left: 0;
  }
  .top-actions + .top-brand + .theme-switch {
    margin-left: 12px;
  }
  .title-row:not(:has(h1:not(.vh))):not(:has(#pageActions)) {
    display: none;
  }
}

/* the page fills the space beside the sidebar, collapsed or not: no empty strip on the right */
main {
  max-width: none;
}

/* phone bar: a compact, fully rounded pill like the Kas Dewayani bar, not edge to edge */
@media (max-width: 899px) {
  .dock {
    width: min(332px, calc(100% - 56px));
    padding: 5px;
    border-radius: 999px;
    gap: 2px;
  }
  .dock button {
    min-height: 48px;
    border-radius: 999px;
    font-size: 11px;
  }
  .dock .lens {
    border-radius: 999px;
  }
  .dock button svg {
    width: 20px;
    height: 20px;
  }
}

/* phone sign-in: logo and form sit together in the middle of the screen, not stuck at the top */
@media (max-width: 760px) {
  .auth {
    min-height: 100svh;
    align-content: center;
    grid-auto-rows: max-content;
    padding-bottom: 6vh;
  }
  .auth-intro {
    padding-top: 12px;
    padding-bottom: 18px;
  }
  .auth-intro .logo {
    height: 96px;
  }
  .auth-side {
    padding-top: 0;
  }
}

/* ---------- smooth minimise: the column glides, labels fade, nothing snaps ---------- */
@media (min-width: 900px) {
  .app {
    transition: grid-template-columns 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .side {
    overflow-x: hidden;
    transition: padding 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .side-brand .logo {
    transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .side-brand .mark {
    max-height: 40px;
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease, max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .nav button span,
  .who,
  .side-foot .quiet {
    overflow: hidden;
    white-space: nowrap;
    transition: opacity 0.2s ease;
  }
  /* collapsed: the same elements stay in place, they just fade and the column clips them */
  .app.collapsed .side-brand .mark {
    display: block;
    max-height: 0;
    opacity: 0;
  }
  .app.collapsed .nav span {
    display: block;
    opacity: 0;
  }
  .app.collapsed .who {
    display: grid;
    opacity: 0;
  }
  .app.collapsed .side-foot .quiet {
    display: inline-flex;
    opacity: 0;
    pointer-events: none;
  }
  .app.collapsed .nav button {
    justify-content: flex-start;
    padding: 0 16px;
  }
  .app.collapsed .side-foot {
    grid-template-columns: auto minmax(0, 1fr) auto;
    justify-content: start;
    padding-left: 9px;
  }
  .side-foot {
    transition: padding 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  }
}
@media (min-width: 900px) {
  .nav {
    grid-template-columns: minmax(0, 1fr);
  }
  .nav button {
    min-width: 0;
    overflow: hidden;
  }
}
