:root {
  color-scheme: light;
  font: 16px/1.5 system-ui, sans-serif;
  color: #172f2b;
  background: #f3f5ef;
  --surface: #fff;
  --line: #d5dfd5;
  --muted: #4c655d;
  --accent: #165849;
}
* { box-sizing: border-box; }
body { margin: 0; }
[hidden] { display: none !important; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: .8rem 1.2rem; max-width: 48rem; margin: auto; padding: 1rem 1.25rem;
}
.brand { font-weight: 760; letter-spacing: -.025em; font-size: 1.15rem; }
.portal-identity { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .65rem; }
.current-person { font-size: .85rem; color: var(--muted); overflow-wrap: anywhere; }
nav { display: flex; flex-wrap: wrap; gap: .9rem; font-size: .9rem; }
a { color: var(--accent); text-underline-offset: .2em; }
nav a:not([aria-current]), .brand { text-decoration: none; }
.brand[aria-current] { text-decoration: underline; }
#profile-switch {
  display: inline-flex; align-items: center; gap: .4rem; margin: 0;
  color: var(--muted); font-size: .85rem;
}
#active-profile { min-height: 2rem; padding: .2rem .4rem; }
@media (max-width: 40rem) {
  .desktop-services { display: none; }
}
main { max-width: 48rem; margin: auto; padding: .75rem 1.25rem 2rem; }
h1, h2, h3, p { margin: 0; }
h1 { margin: 0 0 .85rem; font-size: clamp(1.85rem, 5.5vw, 3rem); line-height: 1.02; letter-spacing: -.055em; }
h2 { margin-bottom: .5rem; font-size: 1.25rem; letter-spacing: -.025em; }
h3 { margin-bottom: .25rem; font-size: 1.05rem; }
p + p { margin-top: .45rem; }
.hero {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem;
  padding: clamp(1.05rem, 4vw, 2rem); border-radius: 1.35rem; background: #153f36; color: #f9fbf6;
}
.hero h1 { margin-bottom: 0; }
.hero .source-note { color: #d6e9de; }
.status {
  display: inline-flex; gap: .45rem; align-items: center; margin-bottom: .65rem;
  color: #e2f6e3; background: #26584a; border-radius: 3rem; padding: .26rem .66rem; font-size: .85rem;
}
.status::before { content: ""; width: .5rem; height: .5rem; background: #a6dab0; border-radius: 50%; }
.status[data-state="off"]::before { background: #ff858b; }
.status:is([data-state="running"], [data-state="quiet"])::before {
  background: #63f2df;
  animation: washing-pulse 1.6s ease-out infinite;
}
@keyframes washing-pulse {
  0% { box-shadow: 0 0 0 0 rgb(99 242 223 / .62); }
  70%, 100% { box-shadow: 0 0 0 .4rem rgb(99 242 223 / 0); }
}
@media (prefers-reduced-motion: reduce) {
  .status::before { animation: none !important; }
}
.washer, .espresso-machine {
  flex: none; width: clamp(2.8rem, 13vw, 5rem); aspect-ratio: 4/5;
  position: relative;
}
.washer {
  border: 2px solid #bee4cb; border-radius: .55rem;
  background: linear-gradient(#bee4cb 2px, transparent 0) no-repeat 0 22% / 100% 2px;
}
.washer::before { content: ""; width: 10%; aspect-ratio: 1; background: #bee4cb; border-radius: 50%; position: absolute; top: 7%; left: 10%; }
.washer span { width: 62%; aspect-ratio: 1; border: 2px solid #bee4cb; border-radius: 50%; position: absolute; left: 19%; top: 36%; }
.espresso-machine { color: #bee4cb; }
.espresso-machine::before {
  content: ""; position: absolute; inset: 27% auto 12% 12%; width: 13%;
  border-inline: 2px solid;
}
.espresso-machine::after {
  content: ""; position: absolute; inset: auto 0 0; height: 14%;
  border: 2px solid; border-radius: .28rem .28rem .5rem .5rem;
}
.espresso-controls {
  position: absolute; inset: 0 0 auto; height: 29%;
  border: 2px solid; border-radius: .55rem .55rem .28rem .28rem;
  background:
    radial-gradient(circle, currentColor 44%, transparent 55%) 30% center / 7px 7px no-repeat,
    radial-gradient(circle, currentColor 44%, transparent 55%) 50% center / 7px 7px no-repeat,
    radial-gradient(circle, currentColor 44%, transparent 55%) 70% center / 7px 7px no-repeat;
}
.espresso-portafilter {
  position: absolute; top: 29%; left: 35%; width: 30%; height: 13%;
  border: 2px solid; border-top: 0; border-radius: 0 0 .3rem .3rem;
}
.espresso-portafilter::before {
  content: ""; position: absolute; top: 42%; left: 100%; width: 84%; height: 2px;
  background: currentColor; border-radius: 1px;
}
.espresso-portafilter::after {
  content: ""; position: absolute; top: 100%; left: 50%; width: 2px; height: 55%;
  margin-left: -1px; background: currentColor;
}
.espresso-cup {
  position: absolute; bottom: 19%; left: 34%; width: 31%; height: 23%;
  border: 2px solid; border-radius: .12rem .12rem .45rem .45rem;
}
.espresso-cup::after {
  content: ""; position: absolute; top: 16%; left: 100%; width: 42%; height: 58%;
  border: 2px solid; border-left: 0; border-radius: 0 .25rem .25rem 0;
}
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 1rem;
  padding: clamp(1rem, 3.5vw, 1.45rem); margin: .9rem 0;
}
.demo { background: #f9fbf6; }
summary { font-weight: 700; cursor: pointer; }
details[open] > summary { margin-bottom: .65rem; }
.timeline {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .65rem 1rem;
  margin: .9rem 0; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: .9rem;
}
.timeline dt { color: var(--muted); font-size: .87rem; }
.timeline dd { font-weight: 650; margin: 0; }
.panel #recognition { font-size: 1.14rem; font-weight: 720; color: #172f2b; }
#scan-primary .notify {
  width: 100%; min-height: 3.45rem; margin-top: .85rem; font-size: 1.12rem;
}
.panel p { color: var(--muted); overflow-wrap: anywhere; }
.inline, .actions { display: flex; flex-wrap: wrap; gap: .55rem; align-items: end; }
.inline > input, .inline > select { flex: 1 1 12rem; min-width: 0; }
.actions:not(:empty), form:not(.panel), .subsection { margin-top: .85rem; }
.subsection { border-top: 1px solid var(--line); padding-top: .85rem; }
label { display: block; margin: .55rem 0 .35rem; font-weight: 620; }
.check { display: flex; gap: .5rem; align-items: center; margin: .85rem 0; font-weight: 500; }
input, select, button, .button {
  font: inherit; color: inherit; min-height: 2.65rem; border-radius: .55rem;
  border: 1px solid #9cad9f; background: #fff; padding: .5rem .65rem;
}
input:not([type=checkbox]), select { width: 100%; }
input[type=checkbox] { width: 1.2rem; min-height: 1.2rem; accent-color: var(--accent); }
button, .button {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  cursor: pointer; border-color: var(--accent); background: var(--accent); color: #fff; font-weight: 650;
}
button:hover, .button:hover { filter: brightness(.93); }
button.secondary, .button.secondary { background: #edf5ee; border-color: #c4d6c8; color: #18483f; }
button:disabled { cursor: wait; opacity: .6; }
:focus-visible { outline: 2px solid #236959; outline-offset: 3px; }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: .25rem .75rem; margin-bottom: .65rem; }
.rule-grid input { margin-top: .25rem; }
.person-row { padding-top: .9rem; margin-top: .9rem; border-top: 1px solid var(--line); }
.person-row .group { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; align-items: start; }
.person-row ul { list-style: none; padding: 0; margin: .65rem 0 0; }
.person-row li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: .35rem; }
#ntfy-settings { margin-top: 1rem; }
#ntfy-settings a { display: inline-block; margin-top: .45rem; }
#feedback { background: #e6f1e7; border-radius: .55rem; padding: .6rem .8rem; }
#feedback.error { background: #fae9e5; color: #742f25; }
.portal-hero { margin-bottom: .95rem; }
.heating { margin: 1.15rem 0; }
.heating-heading { display: flex; align-items: baseline; gap: .65rem; flex-wrap: wrap; }
.heating-heading { justify-content: space-between; }
.heating-source, .heating-target, .heating-humidity, .heating-note { color: var(--muted); font-size: .84rem; }
.heating-note { margin: .15rem 0 .65rem; }
.heating-error { color: #872f24; }
#heating-preview-profile { margin-bottom: .65rem; }
.heating-card {
  display: grid; gap: .8rem; align-content: space-between; min-width: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 1rem;
  padding: clamp(.9rem, 3vw, 1.15rem);
}
.heating-personal {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 17rem), 1fr)); align-items: end;
  background: #e7f0e6; border-color: #c6d8c8; padding: clamp(1rem, 4vw, 1.5rem);
}
.heating-shared-title { margin: .95rem 0 .5rem; }
.heating-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: .65rem; }
.heating-grid .heating-card { grid-row: span 2; grid-template-rows: subgrid; align-content: start; }
.heating-room-heading { display: flex; align-items: center; gap: .45rem; margin-bottom: .35rem; }
.heating-icon {
  flex: none; width: 1.25rem; height: 1.25rem; color: var(--accent);
  fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round;
}
.heating-window { margin-inline-start: auto; width: 1.375rem; height: 1.375rem; color: #933d26; }
.heating-room { font-weight: 720; }
.heating-temperature { font-size: 1.6rem; font-weight: 730; line-height: 1.3; letter-spacing: -.055em; }
.heating-personal .heating-temperature { font-size: clamp(2.3rem, 7vw, 3.5rem); }
.heating-target { position: relative; display: grid; justify-items: center; align-content: center; gap: .05rem; line-height: 1.15; white-space: nowrap; }
.heating-target strong { color: #172f2b; font-size: 1.02rem; font-variant-numeric: tabular-nums; }
.heating-setting > .heating-target { justify-items: start; }
.heating-target-status { width: .85rem; height: .85rem; stroke-width: 2.35; }
.heating-action .heating-target-status { position: absolute; inset: .15rem 0 auto auto; width: .68rem; height: .68rem; }
.heating-target-status.is-pending { color: #826128; }
.heating-target-status.is-confirmed { color: var(--accent); }
.heating-humidity { margin: .2rem 0 0; }
.heating-action { display: grid; grid-template-columns: 1fr 1fr minmax(4.5rem, 1.6fr) 1fr 1fr; gap: .25rem; }
.heating-action button { min-width: 0; min-height: 2.75rem; margin: 0; padding: .45rem .15rem; font-size: .9rem; white-space: nowrap; }
.heating-action button:disabled { cursor: default; opacity: 1; background: #edf0eb; color: #53645a; border-color: #d5dfd5; }
.heating-room-status { margin-top: .35rem; color: #872f24; font-size: .8rem; }
#heating-feedback { margin: .65rem 0 0; }
@media (max-width: 27rem) {
  .heating-grid .heating-temperature { font-size: 1.35rem; }
}
.portal-links, .system-links, .admin-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: .7rem;
}
.portal-tile, .system-link {
  text-decoration: none; border: 1px solid var(--line); border-radius: .8rem;
  display: flex; align-items: center; justify-content: space-between; gap: .65rem;
  min-height: 3.25rem; padding: .72rem .9rem; color: #18483f; background: #f5f9f4;
}
.portal-tile { align-items: start; justify-content: flex-start; flex-direction: column; padding: 1rem; }
.portal-tile strong { font-size: 1.17rem; }
.portal-tile span { color: var(--muted); }
.portal-tile:hover, .system-link:hover { background: #e8f3e8; border-color: #b7cbbd; }
.system-link { font-weight: 650; }
.admin-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); align-items: start; }
.admin-grid > .panel { margin: 0; }
.admin-list { margin: 0; padding: 0; list-style: none; }
.admin-list li {
  display: flex; justify-content: space-between; align-items: center; gap: .8rem;
  border-bottom: 1px solid #e7eee7; padding: .53rem 0;
}
.admin-list li:last-child { border-bottom: 0; }
.admin-list small { display: block; color: var(--muted); }
.tag { flex: none; border-radius: 3rem; padding: .22rem .55rem; background: #e7f1e7; font-size: .82rem; font-weight: 670; }
.tag.attention { background: #f9eacb; color: #643f06; }
.tag.archived { background: #edf0ec; color: #4b6056; }
.source-note { margin-top: .7rem; font-size: .86rem; }
.qr-share { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; margin: .55rem 0; }
.qr-share img { width: 172px; height: auto; }
body:has(#admin-panel:not([hidden])) main, body:has(#admin-panel:not([hidden])) .topbar { max-width: 76rem; }
@media (max-width: 380px) {
  .topbar, main { padding-left: .8rem; padding-right: .8rem; }
  .hero { gap: .55rem; }
}
