/* ============================================================================
   Home Data — "Hearth"  ·  warm editorial climate log
   Ember base (warm ink + cream + ember accent, Fraunces display) with a
   printed-report sensibility (overlines, hairline rules, generous air).
   ============================================================================ */
:root {
  --bg: #161210;
  --bg-2: #1b1510;
  --panel: #1c1713;
  --paper: #221b15;          /* warm inset surface — the "paper" nod */
  --ink: #f3ebe0;
  --ink-dim: #cdbfae;
  --ink-mut: #998a7a;
  --line: #322a22;
  --line-soft: #261f19;

  --ember: #e8843c;
  --ember-2: #f2b44d;
  --ember-deep: #c25a23;
  --ember-glow: rgba(232,132,60,.15);

  --cold: #5f93d4;
  --cool: #58b5c4;
  --warm: #ecb44e;
  --hot: #e8753a;
  --red: #df5238;
  --green: #7cc293;

  --thermo: linear-gradient(90deg, #4f7cc9, #57b8c9, #e9c46a, #ec7a3c, #d34f3a);

  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

  --radius: 14px;
  --maxw: 1240px;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  background-image:
    radial-gradient(900px 460px at 86% -8%, rgba(232,132,60,.10), transparent 60%),
    radial-gradient(700px 420px at -6% 4%, rgba(120,80,40,.08), transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
/* faint paper grain */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
#app { max-width: var(--maxw); margin: 0 auto; padding: 0 30px 40px; position: relative; z-index: 1; }

.overline {
  font-family: var(--sans); font-size: 10.5px; font-weight: 600;
  letter-spacing: .2em; text-transform: uppercase; color: var(--ink-mut);
}
.mono { font-family: var(--mono); }
.rule { height: 1px; background: var(--line); margin: 6px 0; }

/* ---------- Masthead ---------- */
.masthead {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 26px;
  padding: 20px 0 16px; flex-wrap: wrap;
  background: linear-gradient(180deg, var(--bg) 64%, rgba(22,18,16,0));
  backdrop-filter: blur(6px);
}
.mast-brand { display: flex; align-items: center; gap: 13px; }
.ember-mark {
  width: 40px; height: 40px; border-radius: 50%; position: relative; flex: 0 0 auto;
  background: radial-gradient(circle at 50% 60%, #f2b44d, #e8843c 45%, #8c3d16 100%);
  box-shadow: 0 0 26px -2px var(--ember-glow), inset 0 -3px 8px rgba(0,0,0,.35);
}
.ember-mark span {
  position: absolute; inset: 0; border-radius: 50%;
  box-shadow: 0 0 0 0 var(--ember-glow); animation: ember 3.4s ease-in-out infinite;
}
@keyframes ember { 0%,100% { box-shadow: 0 0 14px -2px rgba(232,132,60,.5); } 50% { box-shadow: 0 0 26px 2px rgba(242,180,77,.55); } }
.wordmark { font-family: var(--serif); font-optical-sizing: auto; font-weight: 500; font-size: 26px; letter-spacing: -.01em; margin: 1px 0 0; line-height: 1; }

.tabs { display: flex; gap: 2px; }
.tab {
  appearance: none; border: 0; background: transparent; color: var(--ink-mut);
  padding: 8px 4px; margin: 0 10px; border-radius: 0; font-family: var(--sans);
  font-size: 13.5px; font-weight: 600; cursor: pointer; position: relative;
  transition: color .16s ease;
}
.tab:first-child { margin-left: 0; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); }
.tab.active::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -4px; height: 2px;
  background: var(--ember); border-radius: 2px;
}

.mast-controls { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.range { display: flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; background: rgba(0,0,0,.18); }
.range button {
  appearance: none; border: 0; background: transparent; color: var(--ink-mut);
  padding: 6px 11px; border-radius: 7px; font-family: var(--mono); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all .14s ease;
}
.range button:hover { color: var(--ink); }
.range button.active { background: var(--ember); color: #2a1606; font-weight: 600; }
.icon-btn {
  appearance: none; width: 36px; height: 36px; border-radius: 9px; cursor: pointer;
  background: transparent; border: 1px solid var(--line); color: var(--ink-mut);
  display: grid; place-items: center; transition: all .15s ease;
}
.icon-btn:hover { color: var(--ember); border-color: var(--ember-deep); }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.subline {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-mut);
  padding: 4px 0 18px; border-bottom: 1px solid var(--line-soft); margin-bottom: 22px;
}
.live { display: flex; align-items: center; gap: 8px; }
.live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 0 rgba(124,194,147,.6); animation: pulse 2.4s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(124,194,147,.5); } 70% { box-shadow: 0 0 0 7px rgba(124,194,147,0); } 100% { box-shadow: 0 0 0 0 rgba(124,194,147,0); } }
.auto { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.auto input { accent-color: var(--ember); }

/* ---------- Views ---------- */
.view { display: none; }
.view.active { display: grid; gap: 22px; animation: rise .4s cubic-bezier(.2,.7,.3,1); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.lede { max-width: 680px; }
.lede p { font-family: var(--serif); font-size: 21px; font-weight: 400; line-height: 1.3; color: var(--ink-dim); margin: 8px 0 0; letter-spacing: -.01em; }

.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 940px) { .cols-2 { grid-template-columns: 1fr; } }
.cols-3 { display: grid; grid-template-columns: 1.1fr 1fr 1.1fr; gap: 22px; }
@media (max-width: 1040px) { .cols-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 720px) { .cols-3 { grid-template-columns: 1fr; } }

/* ---------- Panels ---------- */
.panel {
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
  border: 1px solid var(--line-soft); border-radius: var(--radius);
  padding: 20px 22px 22px;
}
.panel.wide { grid-column: 1 / -1; }
.panel-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head .overline { flex-basis: 100%; margin-bottom: 2px; }
.panel-head h3 { font-family: var(--serif); font-weight: 500; font-size: 19px; margin: 0; letter-spacing: -.01em; }
.hint { font-family: var(--mono); font-size: 11px; color: var(--ink-mut); margin-left: auto; }

.chart { width: 100%; height: 300px; }
.chart.tall { height: 400px; }
.chart.cal { height: 200px; }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.15fr .85fr 1.4fr; gap: 0;
  border: 1px solid var(--line-soft); border-radius: var(--radius); overflow: hidden;
  background: linear-gradient(180deg, var(--panel), var(--bg-2));
}
.hero > div { padding: 24px 26px; }
.hero-now { border-right: 1px solid var(--line-soft); }
.hero-state { border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; }
.hero-temp { font-family: var(--serif); font-weight: 500; font-size: 76px; line-height: .92; letter-spacing: -.03em; margin: 10px 0 16px; }
.hero-temp .deg { font-size: 26px; color: var(--ember); font-weight: 500; margin-left: 2px; }
.thermo { position: relative; height: 9px; border-radius: 6px; background: var(--thermo); }
.thermo-mark { position: absolute; top: 50%; width: 3px; height: 19px; background: var(--ink); border-radius: 2px; transform: translate(-50%, -50%); box-shadow: 0 0 0 2px var(--bg); transition: left .6s cubic-bezier(.2,.7,.3,1); }
.hero-sub { font-family: var(--mono); font-size: 12px; color: var(--ink-mut); margin-top: 12px; }
.cop-dial { height: 156px; margin: 2px 0; }
.hero-mode { font-family: var(--mono); font-size: 12px; color: var(--ink-dim); text-align: center; margin-top: auto; }
.hero-spark { display: flex; flex-direction: column; }
.spark { flex: 1; min-height: 130px; margin-top: 6px; }
.spark-legend { display: flex; gap: 16px; font-family: var(--mono); font-size: 11px; color: var(--ink-mut); }
.spark-legend .sl::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.sl.outdoor::before { background: var(--cold); }
.sl.cop::before { background: var(--ember); }
@media (max-width: 940px) {
  .hero { grid-template-columns: 1fr; }
  .hero-now, .hero-state { border-right: 0; border-bottom: 1px solid var(--line-soft); }
}

/* ---------- Vitals (editorial stat blocks) ---------- */
.vitals { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.vital { padding: 4px 22px 4px 0; margin: 8px 0; border-right: 1px solid var(--line-soft); }
.vital:last-child { border-right: 0; }
.vital .v-label { font-family: var(--sans); font-size: 10.5px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-mut); }
.vital .v-num { font-family: var(--serif); font-weight: 500; font-size: 38px; line-height: 1; letter-spacing: -.02em; margin: 8px 0 6px; }
.vital .v-num .u { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--ink-mut); margin-left: 4px; letter-spacing: 0; }
.vital .v-sub { font-family: var(--mono); font-size: 11px; color: var(--ink-mut); }
.vital.accent .v-num { color: var(--ember); }
@media (max-width: 720px) { .vital { border-right: 0; } }

/* ---------- Readout (system status) ---------- */
.readout { display: grid; gap: 0; }
.ro-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.ro-row:last-child { border-bottom: 0; }
.ro-label { font-size: 13px; color: var(--ink-dim); }
.ro-val { font-family: var(--mono); font-weight: 500; font-size: 13.5px; color: var(--ink); }
.ro-val .muted { color: var(--ink-mut); }

.pill { font-family: var(--sans); font-size: 10.5px; font-weight: 700; letter-spacing: .06em; padding: 3px 9px; border-radius: 20px; text-transform: uppercase; }
.pill.on { background: rgba(124,194,147,.15); color: var(--green); }
.pill.off { background: rgba(153,138,122,.16); color: var(--ink-mut); }
.pill.warn { background: rgba(242,180,77,.16); color: var(--warm); }
.pill.alarm { background: rgba(223,82,56,.18); color: var(--red); }

/* ---------- Alert ribbon ---------- */
.alert-ribbon {
  display: flex; align-items: center; gap: 11px;
  padding: 13px 18px; border-radius: 12px; font-size: 13.5px;
  background: rgba(242,180,77,.1); border: 1px solid rgba(242,180,77,.34); color: #f3d79a;
}
.alert-ribbon.is-alarm { background: rgba(223,82,56,.12); border-color: rgba(223,82,56,.42); color: #f4bcae; }
.alert-ribbon .ico { font-size: 15px; }

/* ---------- Health tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); border-radius: 11px; overflow: hidden; margin-bottom: 16px; }
.tile { background: var(--bg-2); padding: 13px 15px; }
.tile .t-l { font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-mut); }
.tile .t-v { font-family: var(--serif); font-weight: 500; font-size: 24px; margin-top: 5px; letter-spacing: -.02em; }
.tile .t-v span { font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--ink-mut); margin-left: 3px; }
.tile .t-s { font-family: var(--mono); font-size: 10.5px; color: var(--ink-mut); margin-top: 3px; min-height: 13px; }

/* ---------- Alarm list ---------- */
.alarm-list { display: grid; gap: 8px; }
.alarm-ok { font-family: var(--mono); font-size: 12.5px; color: var(--green); background: rgba(124,194,147,.08); border: 1px solid rgba(124,194,147,.2); border-radius: 10px; padding: 13px 15px; }
.alarm-item { display: flex; gap: 11px; align-items: flex-start; padding: 11px 14px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 10px; }
.ai-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; flex: 0 0 auto; }
.ai-dot.alarm { background: var(--red); box-shadow: 0 0 0 3px rgba(223,82,56,.18); }
.ai-dot.warn { background: var(--warm); box-shadow: 0 0 0 3px rgba(242,180,77,.18); }
.ai-label { font-size: 13px; font-weight: 600; display: flex; gap: 7px; align-items: center; }
.ai-meta { font-family: var(--mono); font-size: 11px; color: var(--ink-mut); margin-top: 2px; }

/* ---------- Rooms (overview climate tiles) ---------- */
.rooms { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.room { background: var(--paper); border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px 13px; }
.room-name { font-size: 11px; color: var(--ink-mut); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-temp { font-family: var(--serif); font-weight: 500; font-size: 25px; letter-spacing: -.02em; margin: 4px 0 2px; }
.room-temp span { font-family: var(--mono); font-size: 11px; color: var(--ink-mut); margin-left: 2px; }
.room-rh { font-family: var(--mono); font-size: 11px; color: var(--cool); }

/* ---------- Shutters ---------- */
.shutters { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.shutter { padding: 12px 14px; background: var(--paper); border: 1px solid var(--line-soft); border-radius: 10px; transition: opacity .15s ease; }
.shutter.busy { opacity: .5; pointer-events: none; }
.sh-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 9px; }
.sh-name { font-size: 12.5px; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sh-val { font-family: var(--mono); font-size: 11px; color: var(--ink-mut); flex: 0 0 auto; }
.sh-bar { height: 7px; border-radius: 4px; background: var(--bg-2); border: 1px solid var(--line-soft); overflow: hidden; }
.sh-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--ember-deep), var(--ember)); transition: width .4s ease; }
.sh-ctrl { display: flex; align-items: center; gap: 6px; margin-top: 11px; }
.sh-btn {
  appearance: none; flex: 0 0 auto; width: 30px; height: 28px; border-radius: 8px; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--ink-dim); font-size: 11px;
  display: grid; place-items: center; transition: all .14s ease; font-family: var(--sans);
}
.sh-btn:hover { color: var(--ember); border-color: var(--ember-deep); }
.sh-btn:active { transform: translateY(1px); }
.sh-slider { flex: 1; min-width: 0; accent-color: var(--ember); cursor: pointer; height: 4px; }

/* ---------- Banner ---------- */
.banner { background: rgba(242,180,77,.09); border: 1px solid rgba(242,180,77,.3); color: #f3d79a; padding: 13px 16px; border-radius: 12px; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.banner button { margin-left: auto; background: var(--ember); color: #2a1606; border: 0; padding: 6px 13px; border-radius: 8px; font-weight: 700; cursor: pointer; font-family: var(--sans); }

/* ---------- Loading shimmer ---------- */
.chart.loading, .is-loading { position: relative; min-height: 120px; }
.chart.loading::after, .is-loading::after {
  content: 'gathering readings…'; position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--mono); color: var(--ink-mut); font-size: 12px;
  background: repeating-linear-gradient(90deg, transparent, rgba(232,132,60,.045) 40%, transparent 80%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- Colophon ---------- */
.colophon { margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line-soft); font-family: var(--mono); font-size: 11px; color: var(--ink-mut); display: flex; gap: 10px; }
.colophon .sep { opacity: .5; }

/* ---------- Sign-in gate ---------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background-color: var(--bg);
  background-image:
    radial-gradient(820px 480px at 72% -12%, rgba(232,132,60,.14), transparent 60%),
    radial-gradient(640px 420px at -8% 6%, rgba(120,80,40,.1), transparent 55%);
}
.auth-card { text-align: center; max-width: 360px; padding: 40px 34px; }
.auth-card .ember-mark { margin: 0 auto 22px; width: 54px; height: 54px; }
.auth-card .overline { justify-content: center; }
.auth-card h2 { font-family: var(--serif); font-weight: 500; font-size: 36px; margin: 8px 0 8px; letter-spacing: -.01em; }
.auth-card p { color: var(--ink-mut); font-size: 14px; margin: 0 0 26px; }
.auth-card button {
  font-family: var(--sans); font-size: 14px; font-weight: 600; color: #2a1606;
  background: var(--ember); border: 0; border-radius: 11px; padding: 12px 24px; cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.auth-card button:hover { background: var(--ember-2); }
.auth-card button:active { transform: translateY(1px); }
.auth-msg { color: var(--red); font-size: 12px; font-family: var(--mono); margin-top: 16px; min-height: 16px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #2a1512; border: 1px solid #6b2c22; color: #f4bcae; padding: 12px 18px; border-radius: 12px; font-size: 13px; z-index: 100; box-shadow: 0 12px 34px -10px rgba(0,0,0,.7); max-width: 90vw; }

@media (max-width: 720px) {
  #app { padding: 0 18px 36px; }
  .masthead { gap: 14px; }
  .tabs { order: 3; width: 100%; }
  .tab { margin: 0 16px 0 0; }
  .mast-controls { margin-left: auto; }
  .hero-temp { font-size: 60px; }
}
