/* HomeHub webapp — extracted from the design handoff.
   Tokens are shared with the panel firmware (src/ui/theme.cpp) so the wall
   display and the webapp read as one product. */

:root {
  --bg: #f2efe9;
  --surface: #ffffff;
  --surface-hi: #e4e0d8;
  --border: #cbc6bc;
  --text: #1c1e22;
  --muted: #5f656e;
  --accent: #a8670c;
  --on-accent: #ffffff;
  --house: #8a857a;

  /* Night weather cards: dark-inked in light mode, deeper than --surface in dark. */
  --night-bg: #1d2026;
  --night-border: #39404b;
  --night-hi: #2a2e37;
  --night-text: #e8e6e0;
  --night-muted: #9aa0aa;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --rail-w: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --surface: #1d2026;
    --surface-hi: #2a2e37;
    --border: #39404b;
    --text: #e8e6e0;
    --muted: #9aa0aa;
    --accent: #e8a33d;
    --on-accent: #14161a;
    --house: #9b9587;
    --night-bg: #0e1013;
    --night-border: #2c323b;
    --night-hi: #20242b;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
}

button, input, select, textarea { font: inherit; color: var(--text); }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { color: var(--text); }

/* Never remove the focus ring. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@keyframes hh-pulse { 0%, 100% { opacity: .45 } 50% { opacity: .9 } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---- shell ---------------------------------------------------------------- */

.shell { display: flex; min-height: 100vh; }

.rail {
  flex: 0 0 var(--rail-w);
  width: var(--rail-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail-nav, .rail-profiles {
  display: flex; flex-direction: column; align-items: center;
  width: 100%; gap: 2px;
}
.rail-profiles {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.rail-spacer { flex: 1 1 auto; }

.rail-item {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 38px;
  color: var(--muted);
  border: 0; background: transparent; cursor: pointer;
  text-decoration: none;
}
.rail-item:hover { background: var(--surface-hi); color: var(--text); }
.rail-item[aria-current="page"] { background: var(--surface-hi); color: var(--accent); }
.rail-item svg { width: 22px; height: 22px; }

.avatar {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  color: #fff; flex: 0 0 auto;
}
.avatar svg { width: 17px; height: 17px; }
.rail-item[aria-current="true"] .avatar { box-shadow: 0 0 0 2.5px var(--accent); }

.chrome {
  position: fixed; top: 12px; right: 12px;
  display: flex; gap: 8px; z-index: 20;
}
.chrome a, .chrome button {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--muted); cursor: pointer;
}
.chrome a:hover, .chrome button:hover { background: var(--surface-hi); color: var(--text); }

main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 18px 116px 32px 18px;   /* right padding clears the fixed chrome */
}

.page-head { margin-bottom: 18px; }
.page-title {
  font-family: var(--serif);
  font-weight: 400;
  margin: 0;
  font-size: clamp(26px, 3.4vw, 34px);
}
.eyebrow {
  font-size: 12.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 4px;
}

/* ---- cards ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px;
}
.card-title { margin: 0; font-size: 16px; font-weight: 600; }
.card-sub { font-size: 12.5px; color: var(--muted); }

.panes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(288px, 1fr));
  gap: 16px;
}

/* ---- controls ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface); cursor: pointer; font-size: 15px;
}
.btn:hover { background: var(--surface-hi); }
.btn-primary {
  border: 0; background: var(--accent); color: var(--on-accent); font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--text); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; flex: 0 0 auto;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-hi); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.is-on { color: var(--accent); border-color: var(--accent); }

.field {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 11px;
  background: var(--bg);
}
.field::placeholder { color: var(--muted); }
.label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form .field { flex: 1 1 auto; min-width: 0; }
.inline-form .icon-btn { width: 46px; height: 46px; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 44px; padding: 0 15px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: 14.5px;
  text-decoration: none; color: var(--text);
}
.pill:hover { background: var(--surface-hi); color: var(--text); }
.pill[aria-current="true"], .pill.is-active {
  background: var(--accent); border-color: var(--accent);
  color: var(--on-accent); font-weight: 600;
}

.dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }

.empty {
  color: var(--muted); font-size: 14.5px; line-height: 1.5;
  padding: 10px 0;
}

.flash {
  border: 1px solid var(--accent); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--surface); font-size: 14.5px;
}

/* ---- rows (todos, list items, agenda) ------------------------------------- */

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: center; gap: 12px;
  min-height: 52px; padding: 4px 0;
  border-top: 1px solid var(--border);
}
.rows .row:first-child { border-top: 0; }
.row-main { flex: 1 1 auto; min-width: 0; }
.row-title { display: block; font-size: 16px; }
.row-meta { display: block; margin-top: 2px; font-size: 12.5px; color: var(--muted); }
.row-time {
  flex: 0 0 62px; font-family: var(--mono); font-size: 13.5px; color: var(--muted);
}
.row.is-done .row-title { color: var(--muted); text-decoration: line-through; }

input[type="checkbox"].check {
  width: 24px; height: 24px; flex: 0 0 auto;
  accent-color: var(--accent); cursor: pointer;
}

.owner-bar {
  border-left: 3px solid var(--house);
  padding-left: 12px;
}

/* ---- board ---------------------------------------------------------------- */

.collage { columns: 268px; column-gap: 16px; }
.collage > * { break-inside: avoid; margin: 0 0 16px; }

.board-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--house);
  border-radius: 14px;
  overflow: hidden;
}
.board-body { padding: 14px; }
.board-title {
  font-family: var(--serif); font-size: 19px; line-height: 1.25; margin: 0;
}
.board-title a { color: inherit; text-decoration: none; }
.board-title a:hover { text-decoration: underline; }
.board-desc {
  margin: 7px 0 0; font-size: 13.5px; color: var(--muted); line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.board-meta {
  margin-top: 10px; display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
}
.board-actions {
  display: flex; gap: 6px; padding: 0 14px 14px; margin-top: -4px;
}
.board-actions .icon-btn { width: 44px; height: 44px; }

.board-image { display: block; width: 100%; height: auto; background: var(--surface-hi); }
.board-figure { position: relative; margin: 0; }
.play-badge {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.play-badge span {
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: 50%;
  background: rgba(0, 0, 0, .55);
}

.board-note {
  background: var(--surface-hi);
  transform: rotate(-.5deg);
}
.board-note .board-title { font-size: 18px; }

.board-blocked {
  border: 1px dashed var(--border); border-radius: 11px;
  padding: 12px; margin-bottom: 10px;
  font-size: 13px; color: var(--muted); line-height: 1.45;
}
.board-pending {
  height: 90px; border-radius: 11px; margin-bottom: 10px;
  background: var(--surface-hi);
  animation: hh-pulse 1.6s ease-in-out infinite;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
}

/* ---- weather -------------------------------------------------------------- */

.weather-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(304px, 1fr));
  gap: 16px;
}
.weather-card { position: relative; }
.weather-card.is-night {
  background: var(--night-bg);
  border-color: var(--night-border);
  color: var(--night-text);
}
.weather-card.is-night .card-sub,
.weather-card.is-night .row-meta,
.weather-card.is-night .outlook-day { color: var(--night-muted); }
.weather-card.is-night .outlook { border-top-color: var(--night-border); }

.weather-now { display: flex; align-items: center; gap: 14px; }
.weather-now svg { width: 46px; height: 46px; flex: 0 0 auto; color: var(--accent); }
.weather-temp { font-family: var(--serif); font-size: 44px; line-height: 1; }
.weather-stats {
  margin-top: 12px; display: flex; gap: 16px;
  font-size: 13px; color: var(--muted);
}
.weather-card.is-night .weather-stats { color: var(--night-muted); }

.outlook {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 6px; margin-top: 14px; padding-top: 12px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.outlook svg { width: 22px; height: 22px; }
.outlook-day { font-size: 12px; color: var(--muted); }
.outlook-hi { font-size: 14px; }
.outlook-lo { font-size: 13px; color: var(--muted); }
.outlook-rain { font-size: 11.5px; font-family: var(--mono); color: var(--muted); }
.outlook-rain.is-wet { color: var(--accent); }

.tag {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 11.5px; color: var(--muted);
}

/* ---- calendar ------------------------------------------------------------- */

.cal-layout { display: grid; grid-template-columns: minmax(320px, 1.3fr) minmax(260px, 1fr); gap: 16px; }
@media (max-width: 880px) { .cal-layout { grid-template-columns: 1fr; } }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow {
  text-align: center; font-size: 11.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em; padding-bottom: 6px;
}
.cal-cell {
  aspect-ratio: 1; min-height: 44px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  border: 1px solid transparent; border-radius: 11px;
  background: transparent; color: var(--text);
  cursor: pointer; font-size: 14px; text-decoration: none;
}
.cal-cell:hover { background: var(--surface-hi); }
.cal-cell.is-outside { color: var(--muted); opacity: .55; }
.cal-cell.has-events { background: var(--bg); }
.cal-cell.is-selected { background: var(--surface-hi); box-shadow: 0 0 0 2px var(--accent) inset; }
.cal-cell.is-today { background: var(--accent); color: var(--on-accent); }
.cal-dots { display: flex; gap: 3px; height: 6px; }
.cal-dots .dot { width: 5px; height: 5px; }

/* ---- login ---------------------------------------------------------------- */

.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.login-col { width: 100%; max-width: 380px; }
.login-title {
  font-family: var(--serif); font-weight: 400;
  font-size: clamp(30px, 6vw, 40px); margin: 0 0 20px;
}
.login-field {
  width: 100%; min-height: 52px; padding: 12px 14px;
  letter-spacing: .18em;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.login-field[aria-invalid="true"] { border-color: var(--accent); }
.login-error {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 0 0; font-size: 14px; color: var(--accent);
}
.profile-tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 10px; margin-top: 14px;
}
.profile-tile {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 14px 8px;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); cursor: pointer; text-decoration: none; color: var(--text);
}
.profile-tile:hover { background: var(--surface-hi); color: var(--text); }
.profile-tile .avatar { width: 56px; height: 56px; border-radius: 16px; }
.profile-tile .avatar svg { width: 28px; height: 28px; }
.profile-name { font-size: 15px; font-weight: 600; }
.profile-role { font-size: 12px; color: var(--muted); }

/* ---- responsive ----------------------------------------------------------- */

@media (max-width: 640px) {
  main { padding: 14px 14px 84px; }
  .chrome { top: auto; bottom: 12px; right: 12px; }
  .shell { flex-direction: column-reverse; }
  .rail {
    flex-direction: row; width: 100%; height: auto;
    position: fixed; bottom: 0; left: 0;
    border-right: 0; border-top: 1px solid var(--border);
    overflow-x: auto; padding: 4px 6px; z-index: 15;
  }
  .rail-nav, .rail-profiles { flex-direction: row; width: auto; }
  .rail-profiles { margin: 0 0 0 8px; padding: 0 0 0 8px; border-top: 0; border-left: 1px solid var(--border); }
  .rail-item { width: 46px; }
  .rail-spacer { display: none; }
}
