/* Household Lists — mobile-first board. One list per screen. */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #16181d;
  --muted: #8a8f98;
  --line: #e2e4e8;
  --accent: #2f6df6;
  --danger: #c0392b;
  --emphasis: #fff7e6;
  --emphasis-line: #f0b429;
  --bar-h: 4.5rem;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e8eaed;
    --muted: #8a8f98;
    --line: #2a2e35;
    --accent: #5b8cff;
    --emphasis: #2a2410;
    --emphasis-line: #f0b429;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; background: transparent; border: none; cursor: pointer; }
input {
  font: inherit; color: inherit; background: transparent;
  border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.6rem 0.7rem;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- board layout: fixed top/bottom, scrolling middle ---- */
.board {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
}
.top-bar {
  display: flex; align-items: center; gap: 0.5rem;
  /* Pad for the status bar / notch when installed standalone (no browser
     chrome to inset content). env() resolves to 0 where unsupported. */
  padding: calc(0.75rem + env(safe-area-inset-top, 0px))
           calc(1rem + env(safe-area-inset-right, 0px))
           0.75rem
           calc(1rem + env(safe-area-inset-left, 0px));
  border-bottom: 1px solid var(--line);
}
.list-title {
  flex: 1; text-align: center;
  font-size: 1.1rem; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0.4rem; border-radius: 0.5rem;
}
.list-title:hover { background: var(--line); }
.nav-btn { font-size: 1.6rem; line-height: 1; width: 2.5rem; color: var(--muted); }

/* ---- items ---- */
.items {
  list-style: none; margin: 0; padding: 0.25rem 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  touch-action: pan-y;
}
.item.emphasis { background: var(--emphasis); box-shadow: inset 3px 0 0 var(--emphasis-line); }
.item.emphasis .item-text { font-weight: 700; }
.item.done .item-text { text-decoration: line-through; color: var(--muted); }
.item.dragging { opacity: 0.35; }

.check {
  flex: none; width: 1.5rem; height: 1.5rem;
  border: 1.5px solid var(--muted); border-radius: 50%;
  display: grid; place-items: center; font-size: 0.85rem; color: var(--accent);
}
.item.done .check { border-color: var(--accent); }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.item-text { word-break: break-word; }
.item-when { font-size: 0.7rem; color: var(--muted); }
.item-edit { width: 100%; }
.item-menu-btn, .drag-handle {
  flex: none; width: 2rem; height: 2rem; color: var(--muted);
  font-size: 1.2rem; border-radius: 0.4rem;
}
.drag-handle { touch-action: none; cursor: grab; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); }

/* ---- bottom bar: quick-add + tabs ---- */
/* Pad below the tabs for the home indicator when installed standalone, so the
   tabs aren't under the system gesture area. */
.bottom-bar { border-top: 1px solid var(--line); background: var(--bg); padding-bottom: env(safe-area-inset-bottom, 0px); }
.quick-form {
  display: flex; gap: 0.5rem;
  padding: 0.6rem calc(1rem + env(safe-area-inset-right, 0px)) 0.6rem calc(1rem + env(safe-area-inset-left, 0px));
}
.quick-add { flex: 1; }
.primary {
  background: var(--accent); color: #fff; border-radius: 0.5rem;
  padding: 0 1rem; font-weight: 600; min-width: 2.75rem;
}
.tabs { display: flex; border-top: 1px solid var(--line); }
.tab {
  flex: 1; padding: 0.75rem 0.25rem; text-transform: uppercase;
  font-size: 0.7rem; letter-spacing: 0.08em; color: var(--muted);
  border-top: 2px solid transparent;
}
.tab.active { color: var(--fg); border-top-color: var(--accent); font-weight: 700; }

/* ---- item menu ---- */
.menu {
  position: fixed; z-index: 20; min-width: 12rem;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 0.6rem; box-shadow: 0 8px 30px rgba(0,0,0,0.25);
  padding: 0.35rem; display: flex; flex-direction: column;
}
.menu-item { text-align: left; padding: 0.6rem 0.7rem; border-radius: 0.4rem; }
.menu-item:hover { background: var(--line); }
.menu-item.danger { color: var(--danger); }
.menu-remind { display: flex; flex-direction: column; gap: 0.3rem; padding: 0.5rem 0.7rem; font-size: 0.8rem; color: var(--muted); }
.menu-remind input { color: var(--fg); }
.menu-hint { font-size: 0.7rem; }
.menu-sep { height: 1px; background: var(--line); margin: 0.3rem 0; }

/* ---- setup overlay ---- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(0,0,0,0.45); display: grid; place-items: end center;
}
.setup-panel {
  width: 100%; max-width: 32rem; max-height: 85dvh; overflow-y: auto;
  background: var(--bg); border-radius: 1rem 1rem 0 0;
  padding: 1rem 1.25rem calc(2rem + env(safe-area-inset-bottom, 0px));
}
.setup-head { display: flex; align-items: center; justify-content: space-between; }
.setup-head h2 { text-transform: uppercase; letter-spacing: 0.08em; font-size: 1rem; }
.setup-row { display: flex; gap: 0.4rem; align-items: center; padding: 0.4rem 0; }
.setup-name { flex: 1; }
/* Per-list notify allow-list */
.setup-notify-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; padding: 0 0 0.5rem; margin: -0.1rem 0 0.3rem; }
.setup-notify-caption { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.55; }
.member-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.member-chip {
  font: inherit; font-size: 0.8rem; padding: 0.25rem 0.7rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: transparent; color: var(--muted);
}
.member-chip[aria-checked="true"] { background: var(--accent); color: #fff; border-color: transparent; }
.setup-add { display: flex; gap: 0.4rem; margin-top: 1rem; flex-wrap: wrap; }
.setup-add .setup-name, .setup-add .setup-cat { flex: 1; min-width: 8rem; }
.icon-btn { width: 2.25rem; height: 2.25rem; border: 1px solid var(--line); border-radius: 0.5rem; }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.icon-btn.danger { color: var(--danger); }
.setup-sep { height: 1px; background: var(--line); margin: 1rem 0 0.5rem; }
.setup-notify { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; padding: 0.3rem 0; font-size: 0.9rem; }
.setup-notify .primary { padding: 0.4rem 0.9rem; }
.setup-subhead { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.15em; opacity: 0.6; margin: 0.5rem 0; }
.setup-rooms { display: flex; flex-direction: column; gap: 0.5rem; }
.setup-room-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.room-chip { font: inherit; padding: 0.35rem 0.8rem; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: inherit; cursor: pointer; letter-spacing: 0.08em; }
.room-chip[aria-pressed="true"] { background: var(--accent, #2f6df6); color: #fff; border-color: transparent; }
.menu-hint { font-size: 0.72rem; opacity: 0.6; margin: 0.25rem 0 0; }
.room-join-form { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.room-join-form .quick-add { flex: 1; }

/* Notifications bell */
.bell { position: relative; font: inherit; font-size: 1.1rem; background: transparent; border: none; color: inherit; cursor: pointer; padding: 0.2rem 0.4rem; opacity: 0.7; }
.bell.active { opacity: 1; }
.bell-count { position: absolute; top: -2px; right: -2px; min-width: 1.1em; height: 1.1em; padding: 0 0.25em; box-sizing: border-box; background: #e0245e; color: #fff; border-radius: 999px; font-size: 0.6rem; line-height: 1.1em; text-align: center; }

/* Notifications panel (reuses .overlay) */
.notices-panel { background: var(--panel, #fff); color: inherit; width: min(24rem, 92vw); max-height: 80vh; overflow-y: auto; margin: auto; border-radius: 0.5rem; padding: 1rem; }
@media (prefers-color-scheme: dark) { .notices-panel { background: #1c1f24; } }
.notice-row { display: flex; justify-content: space-between; gap: 0.75rem; padding: 0.5rem 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.notice-list { opacity: 0.55; white-space: nowrap; }

/* Room code display */
.room-code { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0; }
.room-code-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; opacity: 0.6; }
.room-code-value { font-size: 1.1rem; letter-spacing: 0.25em; font-weight: 600; }

/* Notification settings toggles */
.setup-toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; }
.setup-toggle-text { display: flex; flex-direction: column; gap: 0.15rem; }
.setup-toggle-label { font-size: 0.95rem; }
.toggle { font: inherit; min-width: 3rem; padding: 0.3rem 0.7rem; border: 1px solid var(--line); border-radius: 999px; background: transparent; color: inherit; cursor: pointer; }
.toggle[aria-checked="true"] { background: var(--accent, #2f6df6); color: #fff; border-color: transparent; }

/* Greyed-out quick-add when no active list */
.quick-add:disabled, .quick-form .primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- drag ghost + toast + connection ---- */
.ghost {
  position: fixed; left: 1rem; right: 1rem; z-index: 40;
  transform: translateY(-50%); pointer-events: none; opacity: 0.9;
  background: var(--bg); border: 1px solid var(--accent); border-radius: 0.5rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
#toast {
  position: fixed; bottom: calc(var(--bar-h) + 1rem); left: 50%; transform: translateX(-50%);
  background: var(--danger); color: #fff; padding: 0.6rem 1rem; border-radius: 0.5rem;
  font-size: 0.85rem; opacity: 0; transition: opacity 0.2s; z-index: 50; pointer-events: none;
}
#toast.show { opacity: 1; }
body[data-connection="offline"] .top-bar { box-shadow: inset 0 3px 0 var(--danger); }
