/* Color tokens and global reset.
   --sage and --muted are deliberately darker than a first-pass "sage green"
   palette would suggest: at the original values, white button text on
   --sage measured ~3.85:1 contrast and --muted text on --paper measured
   ~3.7:1 — both below WCAG AA's 4.5:1 minimum for normal-size text. These
   shades keep the same hue but pass AA everywhere they're used as text. */
:root {
  --ink: #26332d;
  --muted: #5b6862;
  --paper: #f4f2eb;
  --card: #fffdf8;
  --sage: #5c7669;
  --sage-dark: #46604f;
  --line: #dedfd7;
  --danger: #8a4437;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, sans-serif;
}
main {
  width: min(820px, 100%);
  margin: auto;
  padding: 48px 22px;
}
/* Visible only to assistive tech — used for labels we don't want to show
   twice when the placeholder already communicates the same thing visually. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Page header */
header {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
}
h1, h2 {
  font-family: Georgia, serif;
  font-weight: 500;
  margin: 0;
}
h1 {
  font-size: clamp(42px, 8vw, 68px);
  letter-spacing: -0.04em;
}
.eyebrow {
  margin: 0 0 7px;
  color: var(--sage);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
header > p:last-child, .card p, small, .message {
  color: var(--muted);
}

/* Sticky tab bar switching between the signed-in app's sections (see
   #tabbar in index.html / app.js). Chores is the default/home tab; only one
   tab-panel is visible at a time. */
.tabbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 10px 0;
  margin: 0 -22px 6px;
  padding-inline: 22px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.tab {
  flex-shrink: 0;
  padding: 7px 14px;
  border-radius: 99px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  background: transparent;
}
.tab:hover, .tab:focus-visible {
  background: #e8eee9;
}
.tab.active {
  background: var(--sage);
  color: white;
}

/* Full-page loading state, shown until the initial /api/me request resolves. */
.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 40px 0;
  color: var(--muted);
}
.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--line);
  border-top-color: var(--sage);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Non-blocking toast for confirmations triggered from anywhere on the page
   (join, add/edit/remove chore, assignment). Fixed position so it stays
   visible regardless of scroll position — the old inline #notice paragraph
   could end up off-screen after an action taken far down the page. */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(0);
  max-width: min(92vw, 420px);
  padding: 13px 18px;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 10px 30px rgba(38, 51, 45, 0.25);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.toast.error {
  background: var(--danger);
}
.toast.visible {
  opacity: 1;
}

/* Generic card container, reused for auth, reset-password, household, billing, account */
.card {
  margin: 28px 0;
  padding: 20px;
  border: 1px solid #d7d9d2;
  border-radius: 16px;
  background: #fffdf9;
}
.card h2 {
  font-size: 28px;
}
.card input {
  width: 100%;
  margin: 8px 0 0;
  padding: 13px;
  border: 1px solid #c9cec7;
  border-radius: 10px;
  background: white;
  font-size: 16px;
}
/* Label + input pairing used in the auth/reset forms, so screen readers get
   a real accessible name instead of relying on the placeholder alone. */
.field {
  margin-top: 12px;
}
.field:first-child {
  margin-top: 0;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.field input {
  margin-top: 0;
}
.field-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
}

/* Buttons */
.actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
button {
  border: 0;
  border-radius: 10px;
  background: var(--sage);
  color: white;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
}
button.secondary, .social {
  background: #e8eee9;
  color: var(--ink);
}
button.quiet {
  background: transparent;
  color: var(--sage);
  padding-left: 0;
}
button.full-danger {
  background: var(--danger);
}
/* Busy/disabled state while a request is in flight, to discourage double-clicks
   and give some feedback that something is happening. */
button:disabled {
  opacity: 0.6;
  cursor: default;
}

.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0;
  color: #9da69f;
}
.divider:before, .divider:after {
  content: "";
  height: 1px;
  background: var(--line);
  flex: 1;
}

/* Account bar */
.account {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.account div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Household card. The "switch household" dropdown (#switch-wrap) is styled
   in gamification.css alongside the other member/assignment controls. */
.household {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}
.join {
  display: flex;
  gap: 8px;
}
.join input {
  min-width: 160px;
}

/* Trial banner, shown while a household is inside its 14-day trial and
   hasn't subscribed yet. Non-blocking — just a heads-up. */
.trial-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 22px 0;
  padding: 13px 16px;
  border-radius: 12px;
  background: #eef2ea;
  border: 1px solid #cfdccb;
  font-size: 13px;
  color: var(--ink);
}
.trial-banner a, .trial-banner button {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: 13px;
}

/* Paywall, shown instead of the app once a trial has ended without an
   active subscription. Deliberately reuses .card so it looks native rather
   than like an error state. */
.paywall h2 {
  font-size: 26px;
}

/* Section headers used above the daily/weekly lists, achievements, history */
.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin: 38px 0 12px;
}

/* Chore list rows */
.list {
  border-top: 1px solid var(--line);
}
.chore {
  width: 100%;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 13px 5px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}
.check {
  width: 30px;
  height: 30px;
  border: 1.5px solid #aeb8b0;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.chore.done .check {
  background: var(--sage);
  color: white;
}
.chore.done .label {
  text-decoration: line-through;
  color: var(--muted);
}
.copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
}
.copy small {
  color: var(--sage);
}

/* Inline chore-edit form (owner only), shown in place of a chore row. */
.edit-card {
  margin: 8px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
}
.edit-card .field {
  margin-top: 10px;
}
.edit-card .field:first-child {
  margin-top: 0;
}

/* Completion history */
.history article {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 5px;
  border-top: 1px solid var(--line);
}
.history p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}
.history em {
  font-style: normal;
  color: var(--sage);
  font-size: 13px;
}

.billing {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.message {
  min-height: 18px;
}
.message.error {
  color: var(--danger);
}

/* Inline "delete account" confirmation panel, replacing a native confirm()
   + prompt() pair — a prompt() can't mask a typed password. */
.danger-panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #e3c9c2;
  border-radius: 12px;
  background: #fbf1ee;
}
.danger-panel p {
  color: var(--danger);
  margin: 0 0 10px;
  font-weight: 700;
  font-size: 13px;
}

@media (max-width: 600px) {
  main {
    padding: 28px 16px;
  }
  .tabbar {
    margin: 0 -16px 6px;
    padding-inline: 16px;
  }
  .household, .billing, .trial-banner {
    align-items: stretch;
    flex-direction: column;
  }
  .join {
    flex-direction: column;
  }
  .actions {
    flex-direction: column;
  }
  h1 {
    font-size: 45px;
  }
}
