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

:root {
  --color-bg: #f8f9fa;
  --color-surface: #ffffff;
  --color-text: #1a1a2e;
  --color-text-secondary: #6c757d;
  --color-primary: #4361ee;
  --color-primary-hover: #3a56d4;
  --color-danger: #e63946;
  --color-danger-hover: #c1121f;
  --color-success: #2a9d8f;
  --color-overdue: #e63946;
  --color-border: #dee2e6;
  --radius: 6px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
}

nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 48px;
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-primary);
  text-decoration: none;
  margin-right: 0.5rem;
}

.nav-link {
  color: var(--color-text);
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
}

.nav-link:hover { background: var(--color-bg); }

.nav-dropdown {
  position: relative;
  margin-left: auto;
}

.nav-dropdown summary {
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  list-style: none;
  color: var(--color-text-secondary);
}

.nav-dropdown summary:hover { background: var(--color-bg); }

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  min-width: 180px;
  display: flex;
  flex-direction: column;
}

.dropdown-menu a {
  padding: 0.5rem 1rem;
  color: var(--color-text);
  text-decoration: none;
}

.dropdown-menu a:hover { background: var(--color-bg); }

.nav-user {
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.2rem; margin: 1.5rem 0 0.75rem; }
h3 { font-size: 1rem; margin: 1rem 0 0.5rem; color: var(--color-text-secondary); }

p { margin-bottom: 0.75rem; color: var(--color-text-secondary); }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a.chore-link { color: inherit; }
a.chore-link:hover { text-decoration: underline; }

.header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.header-actions p { margin-bottom: 0; }

.filters {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.pill {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--color-bg);
  color: var(--color-text-secondary);
  text-decoration: none;
}

.pill-active { background: var(--color-primary); color: white; }
.pill-assigned { background: #e3f2fd; color: #1565c0; }
.pill-unassigned { background: #f5f5f5; color: #9e9e9e; }
.pill-room { background: #fff3e0; color: #e65100; }
.pill-role { background: #f3e5f5; color: #7b1fa2; }
.pill-role-owner { background: #fff3e0; color: #e65100; }
.pill-role-admin { background: #e3f2fd; color: #1565c0; }
.pill-role-member { background: #f5f5f5; color: #616161; }

.badge {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 500;
}

.badge-overdue { background: #fce4ec; color: var(--color-overdue); }

.list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.list-item.overdue {
  border-left: 3px solid var(--color-overdue);
}

.list-item-main { flex: 1; min-width: 0; }

.list-item-meta {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-top: 0.15rem;
}

.list-item-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
}

.btn:hover { background: var(--color-bg); text-decoration: none; }
.btn-primary { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-danger { background: var(--color-danger); color: white; border-color: var(--color-danger); }
.btn-danger:hover { background: var(--color-danger-hover); }
.btn-done { background: var(--color-success); color: white; border-color: var(--color-success); }
.btn-done:hover { background: #238b7e; }
.btn-secondary { background: var(--color-bg); }
.btn-small { padding: 0.2rem 0.5rem; font-size: 0.8rem; }

.field { margin-bottom: 1rem; }

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--color-text-secondary);
}

.field input[type="text"],
.field input[type="email"],
.field input[type="number"],
.field input[type="date"],
.field textarea,
.field select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
}

.field textarea { min-height: 80px; resize: vertical; }

.input-small { width: 80px !important; }
.input-readonly { background: var(--color-bg); cursor: default; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.checkbox-group label { font-weight: normal; display: flex; align-items: center; gap: 0.3rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.4rem; }

.frequency-fields {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.frequency-fields label { margin-bottom: 0; white-space: nowrap; }
.frequency-fields select { width: auto; }

.actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-secondary);
}

.flash {
  max-width: 800px;
  margin: 0.5rem auto;
  padding: 0.5rem 1rem;
  background: var(--color-success);
  color: white;
  border-radius: var(--radius);
}

dl { display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 1rem; }
dt { font-size: 0.85rem; color: var(--color-text-secondary); font-weight: 600; }
dd { font-size: 0.95rem; }

.rotation-list { padding-left: 1.5rem; }
.rotation-list li { padding: 0.2rem 0; }

.invite-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.invite-form .field { margin-bottom: 0; flex: 1; min-width: 150px; }
.invite-form .field select { width: auto; }

.help-text { font-size: 0.8rem; color: var(--color-text-secondary); margin-top: 0.15rem; }

.inline-form { display: inline; }

.link-button {
  background: none;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  padding: 0.5rem 1rem;
  text-align: left;
  width: 100%;
}

.link-button:hover { background: var(--color-bg); text-decoration: underline; }

.auth-form {
  max-width: 360px;
  margin: 2rem auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.auth-form .field { margin-bottom: 1rem; }

.auth-form label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--color-text-secondary); }

.auth-form input[type="email"] {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 1rem;
}

.auth-form button[type="submit"] {
  width: 100%;
  padding: 0.6rem;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
}

.auth-form button[type="submit"]:hover { background: var(--color-primary-hover); }

.flash.error { background: var(--color-danger); }

.magic-sent {
  max-width: 480px;
  margin: 2rem auto;
  text-align: center;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 2rem;
}

.magic-sent p { margin-bottom: 0.75rem; font-size: 1rem; }

.dropdown-menu hr { border: none; border-top: 1px solid var(--color-border); margin: 0.25rem 0; }

@media (max-width: 600px) {
  .list-item { flex-direction: column; }
  .list-item-actions { width: 100%; justify-content: flex-end; }
}
