/* Home Hub edit page. One layout that reflows: a phone gets a bottom tab bar and a compact month,
   a computer gets tabs along the top and a month with event titles in it. Follows the device's
   light or dark setting. */

:root {
  --bg: #eef3fa; --card: #ffffff; --card-dim: #f6f9fd; --ink: #0b1d3a; --ink-2: #53648a; --ink-3: #8b9bb8;
  --line: #dbe4f0; --fill: #e6edf7; --field: #ffffff; --accent: #c80f6b; --accent-fill: #e01e84;
  --danger: #c62828; --shadow: 0 1px 2px rgba(11, 29, 58, 0.06), 0 8px 24px rgba(11, 29, 58, 0.06);
  --scrim: rgba(11, 29, 58, 0.4); --tabs-h: 3.75rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1433; --card: #131f4a; --card-dim: #0f1a40; --ink: #f4f6ff; --ink-2: #aab5d8; --ink-3: #7382ad;
    --line: #26356a; --fill: #1d2b5e; --field: #0f1a40; --accent: #ff5fb0; --accent-fill: #ec1f8a;
    --danger: #ff6b6b; --shadow: 0 0 0 1px #26356a; --scrim: rgba(3, 8, 24, 0.66);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.sheet-open { overflow: hidden; }
h1 { margin: 0; font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { margin: 0 0 0.5rem; font-size: 1.1875rem; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0.5rem 0; }
small { font-weight: 400; color: var(--ink-2); }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* buttons and fields */
button, .button {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--fill); border: 0; border-radius: 0.625rem;
  min-height: 2.75rem; padding: 0 0.9375rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; white-space: nowrap; flex: 0 0 auto;
}
button:active, .button:active { opacity: 0.65; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary, .button.primary { background: var(--accent-fill); color: #fff; }
button.quiet { background: none; color: var(--ink-2); font-weight: 500; }
button.danger { background: none; color: var(--danger); }
button.armed { background: var(--danger); color: #fff; }
:focus-visible { outline: 0.1875rem solid var(--accent); outline-offset: 0.125rem; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line); border-radius: 0.625rem;
  min-height: 2.75rem; padding: 0.5rem 0.75rem; width: 100%; min-width: 0; margin: 0; -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: calc(100% - 1.125rem) 50%, calc(100% - 0.8125rem) 50%; background-size: 0.3125rem 0.3125rem; background-repeat: no-repeat; padding-right: 2rem; }
textarea { resize: vertical; line-height: 1.35; display: block; }
input[readonly] { color: var(--ink-2); background: var(--fill); }
input::placeholder, textarea::placeholder { color: var(--ink-3); }
label, .field { display: block; margin: 0.875rem 0 0; font-size: 0.875rem; font-weight: 600; color: var(--ink-2); }
label > input, label > select, label > textarea, .field > .label + * { margin-top: 0.3125rem; }
.field > .label { display: block; }
label.check { display: flex; align-items: center; gap: 0.5rem; font-size: 1rem; font-weight: 500; color: var(--ink); min-height: 2.75rem; margin: 0.375rem 0 0; cursor: pointer; }
label.check.tall { align-self: end; }
input[type=checkbox] { width: 1.375rem; height: 1.375rem; margin: 0; accent-color: var(--accent-fill); flex: 0 0 auto; }
.row { display: flex; align-items: center; gap: 0.5rem; }
.row.wrap { flex-wrap: wrap; }
.row > input { flex: 1 1 10rem; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 0.75rem; }
.spacer { flex: 1 1 auto; }
.hint { font-size: 0.875rem; font-weight: 400; color: var(--ink-2); }
.error { color: var(--danger); font-size: 0.9375rem; font-weight: 500; min-height: 0; margin: 0.5rem 0 0; }
.error:empty { display: none; }
.empty { color: var(--ink-2); padding: 0.75rem 0; }
.card { background: var(--card); border-radius: 1rem; padding: 1.125rem; box-shadow: var(--shadow); margin: 0 0 1rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1.125rem; }

/* sign in */
#gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
#gate-form { width: 100%; max-width: 25rem; margin: 0; padding: 1.5rem; }
#gate-form h1 { color: var(--accent); }
#gate-go { width: 100%; margin-top: 1.125rem; }

/* frame of the page */
#top { position: sticky; top: 0; z-index: 10; background: var(--bg); display: flex; align-items: center; gap: 1.5rem; padding: 0.625rem 1.5rem; border-bottom: 1px solid var(--line); }
.brand { font-size: 1.1875rem; font-weight: 700; letter-spacing: -0.01em; color: var(--accent); }
#tabs { display: flex; gap: 0.25rem; }
#tabs button { background: none; color: var(--ink-2); gap: 0.4375rem; padding: 0 0.75rem; }
#tabs svg { width: 1.375rem; height: 1.375rem; }
#tabs button.on { background: var(--fill); color: var(--accent); }
main { max-width: 76rem; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.875rem; }

/* calendar */
.cal-head { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
#cal-title { flex: 1 1 auto; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#cal-title span { font-weight: 400; color: var(--ink-2); }
.cal-nav { display: flex; gap: 0.25rem; }
.cal-nav button { padding: 0 0.75rem; }
.cal-nav svg { width: 1.25rem; height: 1.25rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.875rem; }
.chip { min-height: 2.25rem; border-radius: 1.125rem; padding: 0 0.875rem 0 0.75rem; gap: 0.4375rem; font-size: 0.9375rem; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.chip i, .pill i, .check i { width: 0.75rem; height: 0.75rem; border-radius: 50%; flex: 0 0 auto; }
.chip.off { color: var(--ink-3); text-decoration: line-through; }
.chip.off i { opacity: 0.3; }
.cal-body { display: grid; grid-template-columns: minmax(0, 1fr) 21.5rem; gap: 1.25rem; align-items: start; }
.dow { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); margin-bottom: 0.3125rem; }
.dow span { text-align: right; padding-right: 0.5rem; }
#grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 0.875rem; overflow: hidden; }
.day { min-height: 6.5rem; border-radius: 0; background: var(--card); padding: 0.3125rem; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; text-align: left; font-weight: 400; white-space: normal; min-width: 0; }
.day:active { opacity: 1; }
.day.other { background: var(--card-dim); }
.day.other .num { color: var(--ink-3); }
.day.sel { box-shadow: inset 0 0 0 0.125rem var(--accent-fill); }
.day:focus-visible { outline-offset: -0.1875rem; }
.num { align-self: flex-end; min-width: 1.625rem; height: 1.625rem; border-radius: 0.8125rem; display: flex; align-items: center; justify-content: center; font-size: 0.9375rem; font-weight: 600; padding: 0 0.25rem; }
.day.today .num { background: var(--accent-fill); color: #fff; }
.lines { display: block; min-width: 0; }
.ev { display: block; font-size: 0.8125rem; line-height: 1.1875rem; height: 1.1875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev i { display: inline-block; width: 0.4375rem; height: 0.4375rem; border-radius: 50%; margin: 0 0.25rem 0.0625rem 0; }
.ev.block { border-radius: 0.3125rem; padding: 0 0.3125rem; font-weight: 600; margin-bottom: 1px; }
.ev.more { color: var(--ink-2); font-weight: 600; padding-left: 0.6875rem; }
.dots { display: none; }
.day-panel { background: var(--card); border-radius: 1rem; padding: 1.125rem; box-shadow: var(--shadow); position: sticky; top: 4.5rem; max-height: calc(100vh - 5.5rem); overflow-y: auto; }
#day-head { color: var(--accent); margin-bottom: 0.625rem; }
#quick { display: flex; gap: 0.5rem; }
#quick input { flex: 1 1 auto; }
.keys { margin: 0.5rem 0 0; font-size: 0.8125rem; }
#agenda { margin-top: 0.625rem; }
.next-up { margin: 1rem 0 0; font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); }
.group { padding: 0.375rem 0; }
.group + .group { border-top: 1px solid var(--line); }
.group-head { background: none; min-height: 2rem; padding: 0; font-weight: 500; color: var(--ink-2); gap: 0.375rem; }
.group-head strong { color: var(--ink); font-weight: 700; }
.item { display: flex; align-items: stretch; justify-content: flex-start; width: 100%; background: none; border-radius: 0.5rem; padding: 0.4375rem 0.25rem; text-align: left; white-space: normal; font-weight: 400; min-height: 0; }
.item:hover { background: var(--fill); }
.item-time { flex: 0 0 4.75rem; font-size: 0.875rem; font-weight: 500; color: var(--ink-2); line-height: 1.3; padding-top: 0.125rem; }
.item-time small { display: block; color: var(--ink-3); }
.item-bar { flex: 0 0 0.25rem; border-radius: 0.125rem; margin-right: 0.625rem; }
.item-main { min-width: 0; display: block; }
.item-title { display: block; font-size: 1.0625rem; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.item-sub { display: block; font-size: 0.875rem; color: var(--ink-2); overflow-wrap: anywhere; }

/* the pop-up sheet */
#sheet-back { position: fixed; left: 0; top: 0; right: 0; bottom: 0; z-index: 30; background: var(--scrim); display: flex; align-items: center; justify-content: center; padding: 1.25rem; }
#sheet { width: 100%; max-width: 35rem; max-height: 100%; overflow-y: auto; background: var(--card); border-radius: 1.125rem; padding: 1.375rem; box-shadow: 0 1.5rem 4rem rgba(0, 0, 0, 0.3); overscroll-behavior: contain; }
#sheet h2 { font-size: 1.375rem; margin-bottom: 0.25rem; }
.pills { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pill, .swatch, .bg { margin: 0; cursor: pointer; position: relative; }
.pill input, .swatch input, .bg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill span { display: inline-flex; align-items: center; gap: 0.4375rem; min-height: 2.5rem; padding: 0 0.875rem 0 0.75rem; border-radius: 1.25rem; background: var(--fill); color: var(--ink); font-size: 0.9375rem; font-weight: 600; }
.pill input:checked + span { box-shadow: inset 0 0 0 0.125rem var(--accent-fill); background: var(--card); }
.pill input:focus-visible + span, .swatch input:focus-visible + span, .bg input:focus-visible + * { outline: 0.1875rem solid var(--accent); outline-offset: 0.125rem; }
.timepick { display: flex; align-items: center; gap: 0.375rem; margin-top: 0.3125rem; }
.timepick select { width: auto; flex: 0 0 auto; min-width: 4.5rem; margin: 0; font-weight: 600; }
.tp-sep { font-size: 1.125rem; font-weight: 700; color: var(--ink-2); }
.tp-ap { display: inline-flex; background: var(--fill); border-radius: 0.625rem; padding: 0.1875rem; margin-left: 0.25rem; }
.tp-ap button { min-height: 2.375rem; padding: 0 0.75rem; background: none; border-radius: 0.5rem; font-size: 0.9375rem; color: var(--ink-2); }
.tp-ap button.on { background: var(--accent-fill); color: #fff; }
.timepick.empty .tp-m, .timepick.empty .tp-sep, .timepick.empty .tp-ap { opacity: 0.4; }
.timepick.empty .tp-ap button.on { background: none; color: var(--ink-2); }
.night { display: flex; align-items: center; gap: 0.625rem; }
.night > span { flex: 0 0 2.75rem; font-weight: 500; }
.photo-view img { display: block; width: 100%; max-height: 60vh; object-fit: contain; border-radius: 0.75rem; background: #000; margin-top: 0.5rem; }

/* messages */
#view-messages { max-width: 44rem; margin: 0 auto; }
.msg { margin-bottom: 0.75rem; }
.msg-meta { font-size: 0.8125rem; font-weight: 500; color: var(--ink-2); margin: 0 0.75rem 0.1875rem; }
.msg-row { display: flex; align-items: center; gap: 0.25rem; }
.bubble { background: var(--card); border-radius: 1.125rem; padding: 0.5625rem 0.875rem; font-size: 1.0625rem; line-height: 1.3; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--shadow); }
.msg-del { font-size: 0.875rem; min-height: 2.25rem; padding: 0 0.625rem; }
#msg-form { position: sticky; bottom: 1rem; margin-top: 1rem; }
#msg-form .row { justify-content: space-between; margin-top: 0.5rem; }
#msg-form .row .primary { margin-left: auto; min-width: 6rem; }

/* photos */
#photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(7.5rem, 1fr)); gap: 0.375rem; }
#photo-grid .empty { grid-column: 1 / -1; }
.photo { position: relative; padding: 0; min-height: 0; aspect-ratio: 1; border-radius: 0.625rem; overflow: hidden; background: var(--fill); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tag { position: absolute; left: 0.3125rem; bottom: 0.3125rem; background: rgba(0, 0, 0, 0.62); color: #fff; font-size: 0.6875rem; font-weight: 600; padding: 0.125rem 0.4375rem; border-radius: 0.5rem; }

/* frames */
#frame-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 1rem; align-items: start; }
.frame-card { margin: 0; max-width: 40rem; }
.frame-top { display: flex; gap: 1rem; align-items: flex-start; }
.face { flex: 0 0 5.25rem; height: 5.25rem; border-radius: 50%; overflow: hidden; background: var(--fill); display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: 700; color: var(--ink-3); box-shadow: 0 0 0 0.125rem var(--line); }
.face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame-id { flex: 1 1 auto; min-width: 0; }
.frame-id label { margin-top: 0; }
.frame-id .row { margin-top: 0.5rem; flex-wrap: wrap; }
.frame-id .hint { margin: 0.375rem 0 0; }
.place-now strong { color: var(--ink); font-size: 1rem; flex: 1 1 auto; }
.place-find { margin-top: 0.5rem; }
.place-results { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.5rem; font-weight: 400; }
.place-results:empty { display: none; }
.checks { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.checks .check { margin: 0; }
.bgs { display: flex; gap: 0.5rem; overflow-x: auto; padding: 0.25rem 0.125rem 0.5rem; }
.bg { flex: 0 0 auto; }
.bg img, .bg .none { display: flex; align-items: center; justify-content: center; width: 5.25rem; height: 3.375rem; border-radius: 0.5rem; object-fit: cover; background: var(--fill); color: var(--ink-2); font-size: 0.875rem; font-weight: 600; }
.bg input:checked + * { box-shadow: 0 0 0 0.1875rem var(--accent-fill); }
.strength { display: flex; align-items: center; gap: 0.625rem; font-weight: 500; margin-top: 0.25rem; font-size: 0.875rem; }
.strength input { flex: 1 1 auto; accent-color: var(--accent-fill); min-width: 0; }

/* people and their devices */
#gate-wait { width: 100%; max-width: 25rem; margin: 0; padding: 1.5rem; }
#gate-wait h1 { color: var(--accent); }
#gate-wait button { margin-top: 0.75rem; }
#tabs button.alert span::after { content: ""; display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--accent-fill); margin-left: 0.3125rem; vertical-align: 0.0625rem; }
.person { padding: 0.875rem 0; border-top: 1px solid var(--line); }
.person .row { margin-top: 0.5rem; }
.person .row input { flex: 1 1 12rem; }
.person .row select { flex: 1 1 12rem; width: auto; }
.person > .label, .devs > .label { display: block; font-size: 0.875rem; font-weight: 600; color: var(--ink-2); }
.devs { margin-top: 0.75rem; }
.dev { display: flex; align-items: center; gap: 0.5rem; padding: 0.375rem 0; }
.dev > span { flex: 1 1 auto; min-width: 0; }
.dev small { display: block; }
.dev em { font-style: normal; font-size: 0.875rem; font-weight: 600; color: var(--accent); }
.dev button { min-height: 2.375rem; }
.waiting { box-shadow: 0 0 0 0.125rem var(--accent-fill); }
.waiting h2 { color: var(--accent); }

/* settings */
#view-settings { max-width: 44rem; margin: 0 auto; }
.cal-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 0.625rem; align-items: center; padding: 0.625rem 0; border-top: 1px solid var(--line); }
.swatches { display: flex; gap: 0.3125rem; }
.swatch span { display: block; width: 1.75rem; height: 1.75rem; border-radius: 50%; }
.swatch input:checked + span { box-shadow: 0 0 0 0.125rem var(--card), 0 0 0 0.25rem var(--ink); }
.code { margin: 0.75rem 0 0; background: var(--fill); border-radius: 0.625rem; padding: 0.75rem; font: 0.8125rem/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-x: auto; white-space: pre; color: var(--ink); }

#toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 40; background: var(--ink); color: var(--bg); padding: 0.625rem 1rem; border-radius: 1.25rem; font-size: 0.9375rem; font-weight: 600; max-width: calc(100vw - 2rem); text-align: center; box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.25); }
#toast.bad { background: var(--danger); color: #fff; }

@media (hover: none) { .keys { display: none; } .item:hover { background: none; } }

/* phones, and narrow windows */
@media (max-width: 52rem) {
  #top { position: static; padding: 0.75rem 1rem 0; border-bottom: 0; }
  #tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--card); border-top: 1px solid var(--line); gap: 0; padding: 0 0.25rem env(safe-area-inset-bottom); }
  #tabs button { flex: 1 1 0; flex-direction: column; gap: 0.125rem; height: var(--tabs-h); padding: 0; font-size: 0.6875rem; border-radius: 0.75rem; min-width: 0; }
  #tabs button.on { background: none; }
  #tabs svg { width: 1.5rem; height: 1.5rem; }
  main { padding: 0.75rem 1rem calc(var(--tabs-h) + env(safe-area-inset-bottom) + 5.5rem); }
  h1 { font-size: 1.5rem; }
  .cal-body { grid-template-columns: minmax(0, 1fr); gap: 0.875rem; }
  .day-panel { position: static; max-height: none; overflow: visible; }
  #new-event { position: fixed; right: 1rem; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 1rem); z-index: 15; width: 3.5rem; height: 3.5rem; border-radius: 50%; padding: 0; font-size: 0; box-shadow: 0 0.375rem 1.125rem rgba(224, 30, 132, 0.45); }
  #new-event::before { content: "+"; font-size: 2rem; font-weight: 400; line-height: 1; margin-top: -0.1875rem; }
  .dow span { text-align: center; padding: 0; }
  .day { min-height: 3.375rem; align-items: center; padding: 0.25rem 0 0.3125rem; }
  .num { align-self: center; }
  .lines { display: none; }
  .dots { display: flex; gap: 0.1875rem; margin-top: 0.25rem; height: 0.375rem; }
  .dots i { width: 0.375rem; height: 0.375rem; border-radius: 50%; }
  #sheet-back { align-items: flex-end; padding: 0; }
  #sheet { max-width: none; max-height: 94vh; border-radius: 1.125rem 1.125rem 0 0; padding: 1.125rem 1rem calc(1.125rem + env(safe-area-inset-bottom)); }
  #toast { bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 1rem); }
  #msg-form { bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 0.75rem); }
  .actions .spacer { display: none; }
  .actions button, .actions .button { flex: 1 1 auto; padding: 0 0.75rem; }
  .cal-row { grid-template-columns: minmax(0, 1fr); }
  .cal-row .row { justify-content: flex-end; }
}
@media (max-width: 23rem) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
