/* ============================================
   DESIGN TOKENS
   ============================================ */
:root {
  /* Colors — warm, muted, intentional */
  --bg: #f7f6f3;
  --bg-elevated: #ffffff;
  --bg-sunken: #efeee9;
  --bg-overlay: rgba(0, 0, 0, 0.4);
  --text: #2d2a24;
  --text-secondary: #6b6560;
  --text-muted: #9a938c;
  --border: #e2dfd8;
  --border-strong: #ccc7be;
  --primary: #3b6b4f;
  --primary-hover: #2e5540;
  --primary-light: rgba(59, 107, 79, 0.08);
  --primary-ring: rgba(59, 107, 79, 0.2);
  --success: #3b7d4f;
  --success-light: #f0f7f2;
  --error: #b5413a;
  --error-light: #fdf0ef;
  --warning: #a06518;
  --warning-light: #fef8ee;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.8125rem;
  --font-size-base: 0.9375rem;
  --font-size-md: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;
  --line-height: 1.6;
  --line-height-tight: 1.3;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Elevation */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 8px 32px rgba(0, 0, 0, 0.12);

  /* Borders */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Extended spacing (landing page) */
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Extended typography (landing page) */
  --font-size-3xl: 2.5rem;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
  --transition-pane: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --header-height: 56px;
  --pane-width: clamp(480px, 40vw, 640px);
  --toolbar-height: 52px;
}

/* ============================================
   RESET & BASE
   ============================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  line-height: var(--line-height);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: var(--font-size-base);
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-4);
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--font-size-xl);
  font-weight: 600;
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-3);
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-2);
}

p {
  margin-bottom: var(--space-4);
  color: var(--text-secondary);
}

/* ============================================
   LAYOUT: Unauthenticated (centered container)
   ============================================ */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-4);
}

/* ============================================
   LAYOUT: Authenticated workspace
   ============================================ */
.workspace {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.workspace-main {
  flex: 1;
  padding: var(--space-2) var(--space-6) var(--space-6);
  transition: margin-right var(--transition-pane);
  overflow-y: auto;
}

/* Side-by-side: schedule narrows when pane is open */
.workspace.pane-open .workspace-main {
  margin-right: var(--pane-width);
}

/* Overlay: schedule doesn't move */
.workspace.pane-overlay .workspace-main {
  margin-right: 0;
}

.workspace.pane-overlay.pane-open .workspace-main::after {
  content: '';
  position: fixed;
  inset: var(--header-height) 0 0 0;
  background: var(--bg-overlay);
  z-index: 40;
  opacity: 0;
  transition: opacity var(--transition-pane);
  pointer-events: none;
}

.workspace.pane-overlay.pane-open .workspace-main::after {
  opacity: 1;
  pointer-events: auto;
}

/* ============================================
   HEADER
   ============================================ */
.app-header {
  display: flex;
  align-items: center;
  height: var(--header-height);
  padding: 0 var(--space-6);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.app-header .logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-lg);
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  letter-spacing: -0.02em;
}

.app-header .logo:hover {
  color: var(--primary);
}

.logo-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.header-spacer {
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* User dropdown */
.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-menu-trigger:hover {
  background: var(--bg-sunken);
  border-color: var(--border);
}

.user-menu-trigger svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-fast);
}

.user-menu.open .user-menu-trigger svg {
  transform: rotate(180deg);
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-1));
  min-width: 180px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1) 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--transition-fast);
  z-index: 60;
}

.user-menu.open .user-menu-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-menu-dropdown a,
.user-menu-dropdown button {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-4);
  background: transparent;
  border: none;
  text-align: left;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-1) 0;
}

/* ============================================
   SLIDE-OUT PANE
   ============================================ */
.config-pane {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: 0;
  width: var(--pane-width);
  background: var(--bg-elevated);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  z-index: 45;
  transform: translateX(100%);
  transition: transform var(--transition-pane), width var(--transition-pane);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.workspace.pane-open .config-pane {
  transform: translateX(0);
}

.pane-header {
  display: flex;
  align-items: center;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: var(--space-4);
}

.pane-header h2 {
  margin: 0;
  font-size: var(--font-size-lg);
  white-space: nowrap;
}

.pane-header-spacer {
  flex: 1;
}

.pane-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--font-size-xl);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pane-close:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

/* Width preset toggle */
.width-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--bg-sunken);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.width-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.width-toggle-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

.width-toggle-btn.active {
  background: var(--bg-elevated);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.width-toggle-btn svg {
  width: 14px;
  height: 14px;
}

.width-toggle-btn .tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--text);
  color: var(--bg-elevated);
  font-size: 11px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
}

.width-toggle-btn:hover .tooltip {
  display: block;
}

.pane-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-6);
  container-type: inline-size;
  container-name: pane;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  line-height: var(--line-height-tight);
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-sm);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.btn-text {
  background: transparent;
  border: none;
  color: var(--primary);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 500;
  cursor: pointer;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}

.btn-text:hover {
  background: var(--primary-light);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-8);
  font-size: var(--font-size-lg);
}

/* ============================================
   CARDS
   ============================================ */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  margin-bottom: var(--space-6);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--font-size-sm);
}

.alert-error {
  background: var(--error-light);
  border: 1px solid #f5c6c3;
  color: var(--error);
}

.alert-success {
  background: var(--success-light);
  border: 1px solid #b7e4c0;
  color: var(--success);
}

.alert-warning {
  background: var(--warning-light);
  border: 1px solid #fde0a8;
  color: var(--warning);
}

.alert-warning a {
  color: var(--warning);
  font-weight: 500;
}

/* ============================================
   MODALS
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  max-width: 450px;
  width: 90%;
  box-shadow: var(--shadow-xl);
  transform: scale(0.95) translateY(8px);
  transition: transform var(--transition-base);
}

.modal-overlay.show .modal {
  transform: scale(1) translateY(0);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--text);
}

.modal-body {
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
  line-height: var(--line-height);
}

.modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* ============================================
   ERROR BANNER
   ============================================ */
#error-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--error);
  color: white;
  padding: var(--space-4);
  text-align: center;
  font-weight: 500;
  font-size: var(--font-size-sm);
  z-index: 200;
  display: none;
  box-shadow: var(--shadow-lg);
}

#error-banner.show {
  display: block;
}

#error-banner button {
  background: transparent;
  border: none;
  color: white;
  font-size: var(--font-size-xl);
  cursor: pointer;
  position: absolute;
  right: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  padding: 0;
  line-height: 1;
}

/* ============================================
   HTMX INDICATORS
   ============================================ */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline-block;
}

.spinner {
  border: 2px solid var(--border);
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
  display: inline-block;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ============================================
   FORM COMPONENTS (M4.3.2)
   ============================================ */

/* Section containers */
.people-section {
  margin-bottom: var(--space-8);
}

.people-section h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.chores-section {
  margin-bottom: var(--space-8);
}

.chores-section h3 {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.hint-text {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-4);
}

.section-divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-8) 0;
}

/* People list */
.people-section-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  background: transparent;
  border: none;
  padding: var(--space-2) 0;
  font-family: var(--font-family);
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.people-section-toggle:hover {
  color: var(--primary);
}

.people-section-toggle svg {
  width: 16px;
  height: 16px;
  transition: transform var(--transition-base);
  color: var(--text-muted);
}

.people-section-toggle.collapsed svg {
  transform: rotate(-90deg);
}

.people-section-count {
  font-size: var(--font-size-sm);
  font-weight: 400;
  color: var(--text-muted);
  margin-left: var(--space-1);
}

.people-section-body {
  overflow: hidden;
  transition: max-height var(--transition-slow), opacity var(--transition-base);
  max-height: 500px;
  opacity: 1;
}

.people-section-body.collapsed {
  max-height: 0;
  opacity: 0;
}

.person-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.person-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  position: relative;
  margin-bottom: var(--space-2);
}

.person-item input[type="text"] {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.person-item input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.person-item input[type="text"]::placeholder {
  color: var(--text-muted);
}

.person-item .btn-remove {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-size-lg);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.person-item .btn-remove:hover {
  background: var(--error-light);
  color: var(--error);
}

.person-item.person-add input {
  border: 2px dashed var(--border);
  text-align: center;
  color: var(--text-muted);
}
.person-item.person-add input:focus {
  text-align: left;
  color: var(--text);
}

.person-item.error input {
  border-color: var(--error);
}

.person-item .error-text {
  font-size: var(--font-size-xs);
  color: var(--error);
  position: absolute;
  bottom: -1.25rem;
  left: 0;
}

/* Form fields */
.form-field {
  margin-bottom: var(--space-6);
}

.form-field label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: 500;
  font-size: var(--font-size-sm);
}

.form-field input[type="text"],
.form-field input[type="number"],
.form-field textarea,
.form-field select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}

.form-field .field-hint {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-field.error input,
.form-field.error textarea {
  border-color: var(--error);
}

.form-field .error-text {
  font-size: var(--font-size-sm);
  color: var(--error);
  margin-top: var(--space-1);
}

/* Sub-field (conditional fields) */
.sub-field {
  margin-top: var(--space-3);
  padding-left: var(--space-4);
  border-left: 2px solid var(--border);
}

.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;
}

.sub-field.hidden {
  display: none;
}

.sub-field label {
  font-weight: 400;
  font-size: var(--font-size-sm);
}

.sub-field input[type="number"] {
  width: 80px;
}

/* People checkboxes */
.people-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin-top: var(--space-2);
}

.people-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  cursor: pointer;
}

.people-checkboxes input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Assignment mode radios */
.assignment-radios {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.assignment-radios label {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-weight: 400;
  cursor: pointer;
}

.assignment-radios input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* Chore cards */
.chore-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.chore-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow var(--transition-base);
}

.chore-card.expanded {
  box-shadow: var(--shadow-md);
}

.chore-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.chore-header:hover {
  background: var(--bg-sunken);
}

.chore-icon {
  font-size: var(--font-size-lg);
  flex-shrink: 0;
}

/* Drag handle for chore reordering */
.chore-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 28px;
  margin-left: -8px;
  margin-right: -4px;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: -2px;
  cursor: grab;
  flex-shrink: 0;
  transition: color var(--transition-fast), opacity var(--transition-fast);
  user-select: none;
}

.chore-drag-handle:hover {
  color: var(--text);
}

.chore-drag-handle:active {
  cursor: grabbing;
}

/* Hide drag handle on expanded cards */
.chore-card.expanded .chore-drag-handle {
  display: none;
}

/* Disabled state when form is dirty */
.chore-drag-handle.disabled {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}

/* Drag ghost (the card being dragged) */
.chore-card.sortable-ghost {
  opacity: 0.4;
}

/* Drag chosen (the card lifted from original position) */
.chore-card.sortable-chosen {
  box-shadow: var(--shadow-lg);
  transform: scale(1.02);
}

/* Drag fallback for touch devices */
.chore-card.sortable-fallback {
  opacity: 0.9;
}

/* Drag handle for people reordering */
.person-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 28px;
  margin-left: -4px;
  margin-right: -4px;
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  letter-spacing: -2px;
  cursor: grab;
  flex-shrink: 0;
  transition: color var(--transition-fast), opacity var(--transition-fast);
  user-select: none;
}

.person-drag-handle:hover {
  color: var(--text);
}

.person-drag-handle:active {
  cursor: grabbing;
}

.person-drag-handle.disabled {
  opacity: 0.2;
  cursor: default;
  pointer-events: none;
}

.person-item.sortable-ghost {
  opacity: 0.4;
}

.person-item.sortable-chosen {
  background: var(--bg);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
}

.person-item.sortable-fallback {
  opacity: 0.9;
}

.chore-summary {
  flex: 1;
  min-width: 0;
}

.chore-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chore-name.empty {
  color: var(--text-muted);
  font-style: italic;
}

.chore-meta {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.chore-header .btn-remove {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-size-lg);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast), color var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chore-header .btn-remove:hover {
  background: var(--error-light);
  color: var(--error);
}

.chore-expand {
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: transform var(--transition-base);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chore-card.expanded .chore-expand {
  transform: rotate(180deg);
}

/* Chore visibility toggle (eye icon) */
.chore-visibility-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  opacity: 0.35;
  cursor: pointer;
  transition: opacity var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.chore-visibility-btn svg {
  width: 16px;
  height: 16px;
}

.chore-visibility-btn:hover {
  opacity: 0.6;
  background: var(--bg-sunken);
}

.chore-visibility-btn.active {
  opacity: 1;
  color: var(--primary);
  background: var(--primary-light);
}

.chore-details {
  display: none;
  padding: 0 var(--space-4) var(--space-4) var(--space-4);
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
}

.chore-card.expanded .chore-details {
  display: block;
}

.chore-details .form-field {
  margin-bottom: var(--space-4);
}

.chore-details .form-field:last-child {
  margin-bottom: 0;
}

/* Inner wrapper for grid layout */
.chore-details-inner {
  padding-top: var(--space-4);
}

/* 2-column chore details at wide pane widths */
@container pane (min-width: 620px) {
  .chore-details-inner {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 0 var(--space-6);
  }

  .chore-details-inner .form-field.full-width,
  .chore-details-inner .chore-actions {
    grid-column: 1 / -1;
  }

  /* Frequency: sub-field dropdowns flow inline to the right */
  .chore-details-inner .form-field.frequency-field {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    align-items: flex-end;
  }

  .form-field.frequency-field > label {
    flex-basis: 100%;
    align-self: flex-start;
  }

  .form-field.frequency-field > select {
    flex: 1;
    width: auto;
    min-width: 160px;
  }

  /* All sub-fields sit inline in the frequency flex row */
  .form-field.frequency-field .sub-field {
    flex: 1;
    border-left: none;
    padding-left: 0;
    margin-top: 0;
  }

  .form-field.frequency-field .sub-field > label {
    display: none;
  }

  .form-field.frequency-field .sub-field select {
    width: 100%;
    min-width: 140px;
  }

  .form-field.frequency-field .sub-field input[type="number"] {
    width: 72px;
  }

  .form-field.frequency-field .sub-field .field-hint {
    font-size: var(--font-size-xs);
    margin-top: var(--space-1);
    white-space: nowrap;
  }

  /* Ordinal checkboxes get their own line, right-aligned under the dropdowns */
  .form-field.frequency-field .sub-field.ordinal-sub-field {
    flex: 0 0 100%;
    text-align: right;
  }

  .form-field.frequency-field .sub-field.ordinal-sub-field > label {
    display: inline;
  }

  .form-field.frequency-field .sub-field .people-checkboxes {
    margin-top: 0;
    display: inline-flex;
  }
}

/* Effort slider */
.effort-field {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.effort-field input[type="range"] {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  background: var(--border);
  border-radius: 3px;
  cursor: pointer;
}

.effort-field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  transition: box-shadow var(--transition-fast);
}

.effort-field input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 4px var(--primary-ring);
}

.effort-label {
  min-width: 80px;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* Chore actions */
.chore-actions {
  display: flex;
  justify-content: space-between;
  padding-top: var(--space-3);
  margin-top: var(--space-3);
  border-top: 1px solid var(--border);
}

/* Delete button in chore card */
.btn-delete {
  padding: var(--space-1) var(--space-3);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--error);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-delete:hover {
  background: var(--error-light);
}

/* Confirmation state */
.btn-delete.confirming {
  background: var(--error);
  color: white;
}

.btn-delete.confirming:hover {
  background: var(--error);
  opacity: 0.9;
}

/* Add chore button */
.add-chore-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.add-chore-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* Exclusion groups ("Don't double up") */
.exclusion-section {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border);
}
.exclusion-section h3 {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-bottom: var(--space-1);
}
.exclusion-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.exclusion-card .label-hint {
  font-weight: 400;
  color: var(--text-muted);
}
.exclusion-filter {
  margin-bottom: var(--space-2);
}
.exclusion-chore-checkboxes {
  display: block;
  max-height: 200px;
  overflow-y: auto;
  padding: var(--space-2) 0;
}
.exclusion-chore-checkboxes label {
  display: flex;
  padding: var(--space-1) 0;
}
.exclusion-card-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}
.btn-remove-exclusion {
  color: var(--error);
  margin-left: auto;
}
.exclusion-section .add-chore-btn {
  margin-top: var(--space-3);
}

/* Form action buttons row — sticky at bottom of pane scroll area */
.form-actions {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  position: sticky;
  bottom: calc(-1 * var(--space-6));
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: var(--space-3) 0;
  margin-top: var(--space-6);
}

/* Save status indicator (autosave feedback) */
.save-status {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 1.5rem;
  transition: opacity var(--transition-fast);
}

.save-status a {
  color: inherit;
  text-decoration: underline;
}

.save-status-saving {
  color: var(--text-muted);
}

.save-status-saved {
  color: var(--success);
}

.save-status-error {
  color: var(--error);
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mb-4 { margin-bottom: var(--space-4); }

/* ============================================
   FOOTER
   ============================================ */
footer {
  margin-top: var(--space-12);
  padding: var(--space-8) 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

footer a {
  color: var(--text-muted);
  text-decoration: none;
}

footer a:hover {
  color: var(--text-primary);
}

/* ============================================
   LANDING PAGE
   ============================================ */
.landing-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.landing-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}

.landing-nav .logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xl);
  font-weight: 700;
  text-decoration: none;
  color: var(--text);
  letter-spacing: -0.02em;
}

.landing-nav .logo:hover {
  color: var(--primary);
}

.landing-nav .logo-icon {
  width: 32px;
  height: 32px;
}

.landing-hero {
  padding: var(--space-24) 0 var(--space-20);
}

.landing-hero h1 {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-6);
  color: var(--text);
}

.landing-hero .subtitle {
  font-size: var(--font-size-lg);
  max-width: 600px;
  margin: 0 auto var(--space-8);
  color: var(--text-secondary);
  line-height: var(--line-height);
}

.landing-hero .cta-note {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-top: var(--space-4);
}

.landing-hero-image {
  margin-top: var(--space-12);
}

.landing-hero-image img {
  width: 100%;
  max-width: 720px;
  height: auto;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
}

.landing-step-image {
  margin-bottom: var(--space-4);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: box-shadow var(--transition-fast);
}

.landing-step-image:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
}

.landing-step-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.landing-section {
  padding: var(--space-20) 0;
  border-top: 1px solid var(--border);
}

.landing-section-title {
  font-size: var(--font-size-xl);
  font-weight: 600;
  text-align: center;
  margin-bottom: var(--space-12);
  letter-spacing: -0.01em;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-8);
}

.landing-feature {
  border-left: 3px solid var(--primary);
  padding-left: var(--space-5);
}

.landing-feature h3 {
  font-size: var(--font-size-md);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--text);
}

.landing-feature p {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
  line-height: var(--line-height);
  margin-bottom: 0;
}

.landing-step {
  text-align: center;
}

.landing-step-number {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: var(--space-3);
}

.landing-step h3 {
  font-size: var(--font-size-md);
  font-weight: 600;
  margin-bottom: var(--space-2);
}

.landing-step p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: var(--line-height);
  margin-bottom: 0;
}

.landing-pricing {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-8);
  max-width: 680px;
  margin: 0 auto;
}

.landing-price-card {
  text-align: center;
  padding: var(--space-8);
  transition: box-shadow var(--transition-base);
}

.landing-price-card:hover {
  box-shadow: var(--shadow-sm);
}

.landing-price-card.highlighted {
  background: var(--primary-light);
  border-color: var(--primary);
}

.landing-price-card h3 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-4);
}

.landing-price-amount {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-2);
}

.landing-price-card p {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.landing-price-card .btn {
  margin-top: var(--space-4);
}

.landing-quote {
  font-size: var(--font-size-lg);
  font-style: italic;
  color: var(--text-secondary);
  max-width: 560px;
  margin: 0 auto;
  line-height: var(--line-height);
}

.landing-final-cta {
  background: var(--bg-sunken);
  border-radius: var(--radius-lg);
  padding: var(--space-16) var(--space-8);
  margin: var(--space-20) 0;
}

.landing-final-cta h2 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-3);
}

.landing-final-cta p {
  font-size: var(--font-size-md);
  color: var(--text-secondary);
  margin-bottom: var(--space-6);
}

.landing-footer {
  padding: var(--space-8) 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.landing-footer p {
  margin-bottom: var(--space-1);
  color: var(--text-muted);
}

.landing-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.landing-footer a:hover {
  color: var(--text-secondary);
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.85);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: var(--space-8);
  cursor: zoom-out;
}

.lightbox.active {
  display: flex;
}

.lightbox-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  background: none;
  border: none;
  color: white;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.lightbox-close:hover {
  opacity: 1;
}

.lightbox-img {
  max-width: 90vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

.lightbox-caption {
  color: rgba(255, 255, 255, 0.85);
  font-size: var(--font-size-sm);
  margin-top: var(--space-4);
  text-align: center;
  max-width: 600px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  :root {
    --pane-width: 100vw;
  }

  .config-pane {
    border-left: none;
  }

  .width-toggle {
    display: none;
  }

  .landing-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .container {
    padding: var(--space-4) var(--space-3);
  }

  h1 { font-size: var(--font-size-xl); }
  h2 { font-size: var(--font-size-lg); }

  .btn {
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
  }

  .btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--font-size-md);
  }

  .app-header {
    padding: 0 var(--space-4);
  }

  .landing-hero {
    padding: var(--space-16) 0 var(--space-12);
  }

  .landing-hero h1 {
    font-size: var(--font-size-2xl);
  }

  .landing-section {
    padding: var(--space-12) 0;
  }

  .landing-grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  .landing-pricing {
    grid-template-columns: 1fr;
  }

  .landing-final-cta {
    padding: var(--space-12) var(--space-6);
    margin: var(--space-12) 0;
  }
}

/* ============================================
   CONTEXTUAL HELP (? icons + popovers)
   ============================================ */
.help-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: var(--space-1);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: var(--bg-sunken);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  vertical-align: middle;
  transition: all var(--transition-fast);
}

.help-trigger:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.help-popover {
  position: fixed;
  width: 280px;
  padding: var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 150;
  display: none;
}

.help-popover.show {
  display: block;
}

.help-popover-content {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: var(--space-2);
}

.help-popover-link {
  font-size: var(--font-size-xs);
  color: var(--primary);
  text-decoration: none;
}

.help-popover-link:hover {
  text-decoration: underline;
}

/* ============================================
   CHORE HIGHLIGHT BANNER
   ============================================ */
.chore-highlight-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  /* Sticky positioning below toolbar */
  position: sticky;
  top: var(--toolbar-height);
  z-index: 9;
}

.chore-highlight-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.chore-highlight-clear:hover {
  background: var(--border);
  color: var(--text);
}

/* ============================================
   CHORE HIGHLIGHT DIMMING
   When data-highlight-chore is set on schedule-content,
   dim all chores except the matching one.
   ============================================ */

/* Card layout dimming — dim container text color (commas inherit), brighten highlighted */
.schedule-content[data-highlight-chore] .assignment-chores {
  color: rgba(0, 0, 0, 0.1);
  transition: color var(--transition-fast);
}
.schedule-content[data-highlight-chore] .assignment-chores .chore-note {
  color: rgba(0, 0, 0, 0.1);
}

.schedule-content[data-highlight-chore] .assignment-chore.highlighted {
  color: var(--text-secondary);
}
.schedule-content[data-highlight-chore] .assignment-chore.highlighted .chore-note {
  color: var(--text-muted);
}

/* Print preview layout dimming (chore items and notes) */
.schedule-content[data-highlight-chore] .day-print-chore-item,
.schedule-content[data-highlight-chore] .day-print-chore-note {
  opacity: 0.15;
  transition: opacity var(--transition-fast);
}

.schedule-content[data-highlight-chore] .day-print-chore-item.highlighted,
.schedule-content[data-highlight-chore] .day-print-chore-note.highlighted {
  opacity: 1;
}

/* Print: always show full visibility */
@media print {
  .schedule-content[data-highlight-chore] .assignment-chores {
    color: var(--text-secondary) !important;
  }
  .schedule-content[data-highlight-chore] .day-print-chore-item,
  .schedule-content[data-highlight-chore] .day-print-chore-note {
    opacity: 1 !important;
  }

  .chore-highlight-banner {
    display: none !important;
  }
}
