:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1e293b;
  background: #f4f7fc;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --muted: #64748b;
  --line: #dbe3ef;
  --surface: #fff;
  --danger: #a63434;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .6; cursor: wait; }
.family-panel { padding: 18px; margin-bottom: 18px; }
.family-panel h2 { margin: 0 0 14px; font-size: 1.15rem; }
.family-panel .list-heading { margin-top: 0; }
.family-name-form { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.family-name-form .field { flex: 1 1 180px; margin: 0; }
.family-rows { list-style: none; padding: 0; margin: 0; }
.family-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.family-row > div:first-child { min-width: 0; flex: 1 1 180px; }
.family-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.app-shell { width: min(100%, 780px); min-height: 100vh; margin: 0 auto; padding: 28px 20px calc(32px + env(safe-area-inset-bottom)); }
.loading { color: var(--muted); text-align: center; padding: 64px 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.brand { margin: 0; color: var(--primary); font-size: 1.55rem; letter-spacing: -.04em; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--muted); font-size: .9rem; }
.panel, .list-card, .auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 4px 16px #1e3a5f10; }
.auth-card { width: min(100%, 450px); margin: 8vh auto 0; padding: 28px; }
.auth-card h1 { margin: 0 0 8px; color: var(--primary); }
.subtle { color: var(--muted); line-height: 1.5; margin: 0 0 24px; }
.field { display: grid; gap: 7px; margin: 16px 0; font-size: .92rem; font-weight: 600; }
.field input, .field select, .item-input { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: white; color: inherit; }
.field input:focus, .field select:focus, .item-input:focus { outline: 3px solid #2563eb30; border-color: var(--primary); }
.button { min-height: 42px; border: 0; border-radius: 10px; padding: 10px 15px; background: var(--primary); color: white; font-weight: 650; }
.button:hover { background: var(--primary-dark); }
.button.secondary { color: var(--primary); background: #eaf1ff; }
.button.ghost { color: var(--muted); background: transparent; padding: 8px; }
.button.danger { color: var(--danger); background: #fff0f0; }
.button.full { width: 100%; margin-top: 8px; }
.auth-switch { margin: 20px 0 0; color: var(--muted); text-align: center; }
.text-button { padding: 0; border: 0; background: none; color: var(--primary); font-weight: 700; text-decoration: underline; }
.notice { margin: 14px 0; padding: 11px 13px; border-radius: 10px; background: #fff5df; color: #6c4c0c; }
.notice.error { color: #7c2525; background: #fff0f0; }
.update-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 18px; padding: 13px 15px; border: 1px solid #bfcef5; border-radius: 12px; background: #eff5ff; color: var(--primary-dark); }
.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin: 0 0 20px; }
.toolbar .field { flex: 1 1 150px; margin: 0; }
.list-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 26px 0 12px; }
.list-heading h2 { margin: 0; font-size: 1.2rem; }
.list-card { overflow: hidden; margin: 12px 0; }
.list-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.list-title h3 { margin: 0; font-size: 1rem; }
.list-actions { display: flex; gap: 4px; }
.list-items { list-style: none; margin: 0; padding: 0 16px; }
.list-item { display: flex; align-items: center; gap: 11px; min-height: 49px; border-bottom: 1px solid #edf1f7; }
.list-item:last-child { border-bottom: 0; }
.list-item input[type="checkbox"] { width: 21px; height: 21px; accent-color: var(--primary); flex: 0 0 auto; }
.item-text { overflow-wrap: anywhere; flex: 1; }
.list-item.completed .item-text { color: #64748b; text-decoration: line-through; }
.item-delete { border: 0; background: transparent; color: #64748b; font-size: 1.25rem; padding: 8px; }
.empty { padding: 20px 17px; color: var(--muted); }
.add-item { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.add-item .item-input { min-height: 42px; }
.empty-state { color: var(--muted); text-align: center; padding: 36px 18px; border: 1px dashed #c5d0e2; border-radius: 16px; }
.overlay { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 18px; background: #0f172acc; }
.dialog { width: min(100%, 430px); padding: 22px; border-radius: 16px; background: white; }
.dialog h2 { margin-top: 0; }
.invite-code { padding: 14px; border-radius: 10px; background: #f0f4fc; font: 1.1rem ui-monospace, monospace; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: end; gap: 10px; margin-top: 18px; }

@media (max-width: 500px) {
  .app-shell { padding: 18px 14px calc(24px + env(safe-area-inset-bottom)); }
  .auth-card { margin-top: 5vh; padding: 22px 18px; }
  .user-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { gap: 5px; }
  .topbar { flex-wrap: wrap; }
  .topbar-actions { flex-wrap: wrap; }
}
