:root {
  --sun: #ffb000;
  --sun-deep: #f59e0b;
  --sky: #fff7e6;
  --ink: #2b2118;
  --muted: #6f6048;
  --line: #ecdcbf;
  --card: #ffffff;
  --good: #34a853;
  --bad: #e8554d;
  --shadow: 0 6px 20px rgba(180, 130, 30, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  background: var(--sky);
  min-height: 100vh;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.5;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Responsive mobile-first app container (centred on wider screens). */
.app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--sky);
  position: relative;
  display: flex;
  flex-direction: column;
}

@media (min-width: 520px) {
  body {
    background: linear-gradient(160deg, #ffe9b8, #ffd27a 60%, #ffbf52);
    padding: 24px 12px;
  }
  .app {
    min-height: 0;
    height: calc(100vh - 48px);
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow: hidden;
  }
}

/* Top bar */
.topbar {
  padding: max(18px, env(safe-area-inset-top)) 18px 12px;
  background: linear-gradient(135deg, var(--sun), var(--sun-deep));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  z-index: 10;
}
.topbar h1 { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.topbar .sub { font-size: 13px; opacity: .95; }
.topbar .who {
  display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600;
  background: rgba(255,255,255,.22); padding: 6px 11px; border-radius: 20px;
}

/* Screen container */
.screens { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.screen { display: none; padding: 16px 16px 96px; }
.screen.active { display: block; }
.screen h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.screen .lead { color: var(--muted); font-size: 15px; margin-bottom: 14px; }

/* Avatars */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; flex: none;
}
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }

/* Cards */
.card {
  background: var(--card);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

/* Login */
.login-hero { text-align: center; padding: 30px 0 18px; }
.login-hero .logo { font-size: 56px; }
.login-hero h2 { font-size: 22px; margin: 8px 0 2px; }
.member-pick {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border: 1px solid var(--line); border-radius: 16px;
  background: #fff; margin-bottom: 10px; cursor: pointer;
  transition: transform .08s, box-shadow .15s;
}
.member-pick:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.member-pick .name { font-weight: 700; font-size: 16px; }
.member-pick .role { font-size: 13px; color: var(--muted); }
.member-pick .go { margin-left: auto; color: var(--sun-deep); font-size: 22px; }

/* Progress ring / bar */
.weekbar {
  display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, #fff, #fff4dd);
}
.ring {
  --pct: 68;
  width: 70px; height: 70px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--sun-deep) calc(var(--pct)*1%), #f1e4c9 0);
  display: flex; align-items: center; justify-content: center;
}
.ring span { background:#fff; width:52px;height:52px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;font-weight:800;font-size:16px;}
.weekbar .meta b { display:block; font-size:16px; font-weight:700; }
.weekbar .meta small { color: var(--muted); font-size:13px; }

/* Room block */
.room-head { display:flex; align-items:center; justify-content:space-between; margin: 4px 0 8px; }
.room-head .rtitle { font-weight:700; font-size:16px; display:flex; align-items:center; gap:8px; }
.room-head .rcount { font-size:13px; color:var(--muted); }

.task {
  display:flex; align-items:center; gap:10px;
  padding:12px 4px; border-bottom:1px solid var(--line);
}
.task:last-child { border-bottom:none; }
.check {
  width:26px;height:26px;border-radius:8px;border:2px solid var(--line);
  flex:none; display:flex;align-items:center;justify-content:center;
  cursor:pointer; font-size:15px; color:#fff;
}
.check.done { background:var(--good); border-color:var(--good); }
.task .tname { flex:1; font-size:16px; }
.task.done .tname { text-decoration:line-through; color:var(--muted); }
.assignee { display:flex; align-items:center; gap:6px; font-size:13px; color:var(--muted); }
.assignee .avatar { width:24px;height:24px;font-size:11px; }

/* Per-task room subtitle on the cadence-grouped week view (REQ-025) */
.task .tname .troom { display:block; font-size:12.5px; color:var(--muted); font-weight:400; margin-top:1px; }

/* Frequency pills — distinct colours per cadence (REQ-025) */
.freq {
  flex:none; font-size:12px; font-weight:700; padding:3px 10px; border-radius:20px;
  letter-spacing:.2px; white-space:nowrap;
}
.freq.daily { background:#fff0d6; color:#b97400; }     /* amber  */
.freq.weekly { background:#e3effd; color:#1b66c9; }    /* blue   */
.freq.monthly { background:#efe6fc; color:#7a3fd0; }   /* purple */

/* People list */
.person {
  display:flex; align-items:center; gap:12px; padding:12px 0;
  border-bottom:1px solid var(--line);
}
.person:last-child { border-bottom:none; }
.person .pname { font-weight:700; font-size:16px; }
.person .pstat { font-size:13px; color:var(--muted); }
.person .acts { margin-left:auto; display:flex; gap:8px; }
.iconbtn {
  border:none; background:var(--sky); color:var(--ink);
  width:38px;height:38px;border-radius:10px; font-size:17px; cursor:pointer;
}
.iconbtn.danger { background:#fde8e6; color:var(--bad); }

/* Buttons */
.btn {
  display:block; width:100%; text-align:center;
  background:linear-gradient(135deg,var(--sun),var(--sun-deep));
  color:#fff; border:none; padding:14px; border-radius:14px;
  font-size:16px; font-weight:700; cursor:pointer; box-shadow:var(--shadow);
}
.btn.ghost { background:#fff; color:var(--sun-deep); border:1.5px solid var(--sun); box-shadow:none; }
.btn.danger { background:linear-gradient(135deg,#f0726a,var(--bad)); }
.btn + .btn { margin-top:10px; }

.badge {
  display:inline-flex; align-items:center; gap:5px;
  font-size:12.5px; font-weight:700; padding:4px 10px; border-radius:20px;
}
.badge.ai { background:#ece7ff; color:#5b3fd6; }
.badge.admin { background:#fff0d6; color:var(--sun-deep); }
.badge.pill { background:#eafaef; color:var(--good); }

.ai-note {
  display:flex; gap:10px; align-items:flex-start;
  background:#f4f0ff; border:1px solid #e3dbff; border-radius:14px;
  padding:12px; font-size:14px; color:#43396f;
}
.ai-note .ico { font-size:20px; }

.section-label { font-size:13px; text-transform:uppercase; letter-spacing:.5px;
  color:var(--muted); margin:18px 0 8px; font-weight:700; }

/* Bottom tab bar */
.tabbar {
  position:absolute; bottom:0; left:0; right:0;
  background:#fff; border-top:1px solid var(--line);
  display:flex; padding:8px 4px 22px; z-index:20;
  box-shadow:0 -4px 16px rgba(180,130,30,.08);
}
.tab {
  flex:1; border:none; background:none; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; gap:3px;
  font-size:12px; font-weight:600; color:var(--muted); padding:4px;
}
.tab .ti { font-size:22px; }
.tab.active { color:var(--sun-deep); font-weight:700; }

/* Modal / confirm dialog */
.modal-bg {
  position:absolute; inset:0; background:rgba(40,28,10,.45);
  display:none; align-items:center; justify-content:center; z-index:100; padding:20px;
}
.modal-bg.open { display:flex; }
.modal {
  background:#fff; border-radius:22px; padding:20px; width:100%; max-width:330px;
  box-shadow:0 20px 50px rgba(0,0,0,.3);
}
.modal h3 { font-size:19px; font-weight:700; margin-bottom:6px; display:flex; align-items:center; gap:8px; }
.modal p { font-size:14.5px; color:var(--muted); margin-bottom:12px; }
.preview {
  background:var(--sky); border:1px dashed var(--sun); border-radius:12px;
  padding:12px; font-size:14px; margin-bottom:14px;
}
.preview .row { display:flex; justify-content:space-between; padding:4px 0; }
.preview .row b { color:var(--bad); }
.modal-actions { display:flex; gap:10px; }
.modal-actions .btn { margin:0; }

.form label { display:block; font-size:13px; font-weight:600; color:var(--muted); margin:12px 0 5px; }
.form input, .form select {
  width:100%; padding:13px; border:1.5px solid var(--line); border-radius:12px;
  font-size:16px; background:#fff; color:var(--ink);
}
.swatches { display:flex; gap:8px; margin-top:6px; }
.swatch { width:30px;height:30px;border-radius:50%; cursor:pointer; border:3px solid transparent; }
.swatch.sel { border-color:var(--ink); }

.search { width:100%; padding:13px 15px; border:1.5px solid var(--line);
  border-radius:14px; font-size:16px; margin-bottom:12px; background:#fff; color:var(--ink); }

.fab-row { margin-top:6px; }
.muted-small { font-size:13px; color:var(--muted); margin-top:4px; }

/* ---- P5 additions (real PWA states) ---- */
.muted-center { text-align:center; color:var(--muted); font-size:15px; padding:18px 8px; }
.error-banner {
  background:#fde8e6; color:var(--bad); border:1px solid #f6c9c4;
  border-radius:12px; padding:11px 13px; font-size:14px; font-weight:500; margin-bottom:12px;
}
.spinner {
  width:26px;height:26px;border-radius:50%;
  border:3px solid var(--line); border-top-color:var(--sun-deep);
  animation:spin .8s linear infinite; margin:24px auto;
}
@keyframes spin { to { transform:rotate(360deg); } }
.toast {
  position:absolute; left:50%; bottom:96px; transform:translateX(-50%);
  background:var(--ink); color:#fff; padding:11px 17px; border-radius:20px;
  font-size:14.5px; z-index:200; opacity:0; transition:opacity .2s; pointer-events:none;
  max-width:80%; text-align:center;
}
.toast.show { opacity:.95; }
.form select { appearance:auto; }
