:root {
  --color-bg: #F0EEE6;
  --color-bg-card: #FFFFFF;
  --color-bg-accent: #E0DDD0;
  --color-action: #4A6741;
  --color-amber: #D4A373;
  --color-text: #121212;
  --color-text-muted: #444444;
  --color-success: #2E7D32;
  --color-error: #D32F2F;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0D0D0D;
    --color-bg-card: #222222;
    --color-bg-accent: #333333;
    --color-action: #89A47E;
    --color-amber: #EBC095;
    --color-text: #F0EDE5;
    --color-text-muted: #AAAAAA;
    --color-success: #81C784;
    --color-error: #E57373;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.6);
  }
}

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

body {
  font-family: 'Inter', sans-serif;
  font-size: 18px;
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
}

#tab-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background-color: var(--color-bg-card);
  border-top: 1px solid var(--color-bg-accent);
  padding: 0.5rem 0;
  position: sticky;
  bottom: 0;
}

#tab-bar[hidden] {
  display: none;
}

.tab-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-family: inherit;
}

.tab-btn span:first-child {
  font-size: 1.25rem;
}

.tab-btn--active {
  color: var(--color-action);
  font-weight: 500;
}

#horizon-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 4px;
  background-color: var(--color-action);
  z-index: 9999;
  transition: width 0.3s ease, background-color 0.3s ease;
}

/* Spacer for the bar if needed on scroll */
body {
  padding-top: 4px;
}

#sw-update-banner {
  background-color: var(--color-action);
  color: #fff;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
}

#sw-update-banner[hidden] {
  display: none;
}

#sw-update-banner button {
  background: #fff;
  color: var(--color-action);
  border: none;
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Shared layout */
.view-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 1rem;
}

.view-header h1 {
  text-align: center;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 1.1rem;
}

.version-tag {
  font-size: 0.65rem;
  opacity: 0.5;
  font-weight: 400;
  vertical-align: super;
  margin-left: 0.1rem;
}

.view-header-right {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  z-index: 50;
}


.gear-btn,
.header-icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--color-text-muted);
  padding: 0.25rem;
  font-family: inherit;
}

.view-content {
  padding: 0 1rem 5rem;
}

/* People view */
.search-row {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-input {
  flex: 1;
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.6rem;
  font-size: 1rem;
  background: var(--color-bg-card);
  color: var(--color-text);
  font-family: inherit;
}

.search-input:focus {
  outline: 2px solid var(--color-action);
  outline-offset: 0;
}

.filter-btn {
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  background: var(--color-bg-card);
  color: var(--color-text);
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
}

.contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.contact-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-bg-accent);
  cursor: pointer;
  gap: 0.75rem;
}

.contact-row-info {
  flex: 1;
}

.contact-row-name {
  font-weight: 500;
  margin-bottom: 2px;
}

.contact-row-meta {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.layer-badge {
  background: var(--color-bg-accent);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  border-radius: 999px;
  padding: 2px 8px;
}

.add-contact-fab {
  position: fixed;
  bottom: 5rem;
  right: 1rem;
  width: 48px;
  height: 48px;
  background: var(--color-action);
  color: white;
  border: none;
  font-size: 1.5rem;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.empty-state {
  text-align: center;
  color: var(--color-text-muted);
  padding: 3rem 1rem;
}

.dunbar-warning {
  background: var(--color-amber);
  color: #121212;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  border-radius: 6px;
}

/* Contact form */
.form-view {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-bg-accent);
}

.form-header h1 {
  font-size: 1.1rem;
  font-weight: 500;
}

.form-cancel-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-family: inherit;
  font-size: 1rem;
  padding: 0.25rem;
}

.form-save-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-action);
  font-weight: 500;
  font-family: inherit;
  font-size: 1rem;
  padding: 0.25rem;
}

.form-save-btn[disabled] {
  opacity: 0.4;
  cursor: default;
}

.form-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.form-section {
  margin-bottom: 1.75rem;
}

.form-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.form-field {
  margin-bottom: 0.75rem;
}

.form-field label {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 0.3rem;
  color: var(--color-text-muted);
}

.form-input {
  width: 100%;
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  background: var(--color-bg-card);
  color: var(--color-text);
  font-family: inherit;
}

.form-input:focus {
  outline: 2px solid var(--color-action);
  outline-offset: 0;
}

.form-explainer {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  font-style: italic;
  margin-bottom: 0.6rem;
}

/* Year-unknown date row */
.date-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.year-unknown-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.month-day-row {
  display: flex;
  gap: 0.5rem;
}

.month-day-row select {
  flex: 1;
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  background: var(--color-bg-card);
  color: var(--color-text);
  font-family: inherit;
}

.month-day-row select:focus {
  outline: 2px solid var(--color-action);
  outline-offset: 0;
}

/* Level selector */
.level-selector {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.level-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  min-width: 3.5rem;
  background: var(--color-bg-card);
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  user-select: none;
}

.level-btn.selected {
  border-color: var(--color-action);
  background: var(--color-bg-accent);
  color: var(--color-action);
}

.level-btn-number {
  font-size: 1.1rem;
  font-weight: 600;
}

.level-btn-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.level-btn.selected .level-btn-label {
  color: var(--color-action);
}

/* Tag input */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.5rem;
  background: var(--color-bg-card);
  cursor: text;
}

.tag-pill {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--color-bg-accent);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.85rem;
}

.tag-pill-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0;
  line-height: 1;
  font-size: 0.9rem;
  font-family: inherit;
}

.tag-new-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  color: var(--color-text);
  min-width: 8rem;
  flex: 1;
  font-family: inherit;
}

/* ===================== Phase 3 styles ===================== */

/* Theme overrides */
[data-theme="light"] {
  --color-bg: #F9F7F2;
  --color-bg-card: #FDFCF9;
  --color-bg-accent: #EBE6D9;
  --color-action: #4A6741;
  --color-amber: #D4A373;
  --color-text: #121212;
  --color-text-muted: #555555;
}

[data-theme="dark"] {
  --color-bg: #121212;
  --color-bg-card: #1E1E1E;
  --color-bg-accent: #2A2A2A;
  --color-action: #89A47E;
  --color-amber: #EBC095;
  --color-text: #E5E1D8;
  --color-text-muted: #999999;
}

/* Onboarding */
.onboarding-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem;
  text-align: center;
  gap: 0;
}

.onboarding-title {
  font-family: 'Playfair Display', serif;
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--color-action);
  margin-bottom: 0.5rem;
}

.onboarding-tagline {
  color: var(--color-text-muted);
  margin-bottom: 2rem;
  font-size: 1rem;
}

.onboarding-field {
  max-width: 320px;
  margin-bottom: 1rem;
}

.onboarding-submit-btn {
  width: 100%;
  max-width: 320px;
  background: var(--color-action);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 1rem;
  font-size: 1.1rem;
  cursor: pointer;
  font-family: inherit;
}

.onboarding-submit-btn[disabled] {
  opacity: 0.4;
  cursor: default;
}

.onboarding-picker-list {
  max-width: 100%;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--color-bg-accent);
  border-radius: 12px;
  background: var(--color-bg-card);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.onboarding-picker-item {
  width: 100%;
  padding: 14px 16px;
  text-align: left;
  border: none;
  border-bottom: 1px solid var(--color-bg-accent);
  background: transparent;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: inherit;
  font-size: 1rem;
  color: var(--color-text);
  transition: background 0.1s ease;
}

.onboarding-picker-item:last-child {
  border-bottom: none;
}

.onboarding-picker-item:hover, .onboarding-picker-item:active {
  background: var(--color-bg-accent);
}

/* Home view */
.home-section {
  margin-bottom: 1.5rem;
}

.home-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.health-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.75rem 0.5rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.health-card-count {
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-action);
}

.health-card-label {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.event-row {
  display: flex;
  align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-bg-accent);
  gap: 0.75rem;
  cursor: pointer;
}

.event-emoji {
  font-size: 1.25rem;
}

.event-info {
  flex: 1;
}

.event-name {
  font-weight: 500;
}

.event-date {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.due-row {
  display: flex;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-bg-accent);
  gap: 0.75rem;
}

.due-row-info {
  flex: 1;
}

.due-row-name {
  font-weight: 500;
}

.due-row-meta {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.due-row-log-btn {
  background: var(--color-action);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.gathering-btn {
  background: none;
  border: 1px solid var(--color-action);
  color: var(--color-action);
  border-radius: 999px;
  padding: 0.4rem 1.25rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  margin-top: 0.75rem;
  display: block;
}

.gathering-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-bg-accent);
}

.gathering-row label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  cursor: pointer;
  margin-bottom: 0;
}

/* Journal view */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-card-value {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--color-action);
  word-break: break-word;
}

.stat-card-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.log-day-group {
  margin-bottom: 1.5rem;
}

.log-day-heading {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--color-bg-accent);
}

.log-entry {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-bg-accent);
}

.log-entry-name {
  font-weight: 500;
}

.log-entry-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 2px;
  flex-wrap: wrap;
}

.log-entry-comment {
  font-style: italic;
}

/* Trunk view */
.trunk-section {
  background: var(--color-bg-card);
  border: 1px solid var(--color-bg-accent);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
}

.trunk-section--heritage {
  background: linear-gradient(135deg, var(--color-bg-card) 0%, var(--color-bg-accent) 100%);
  border: 1px solid var(--color-amber);
  position: relative;
  overflow: hidden;
}

.trunk-section--heritage::before {
  content: '🌿';
  position: absolute;
  top: -10px;
  right: -10px;
  font-size: 4rem;
  opacity: 0.1;
  transform: rotate(15deg);
}

.trunk-section-title {
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.trunk-section-meta {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.trunk-nudge {
  background: var(--color-amber);
  color: #121212;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.trunk-btn {
  display: block;
  width: 100%;
  background: var(--color-action);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  margin-bottom: 0.5rem;
  text-align: center;
  text-decoration: none;
}

.trunk-btn--secondary {
  background: var(--color-bg-accent);
  color: var(--color-text);
}

.trunk-import-label {
  display: block;
  width: 100%;
  background: var(--color-bg-accent);
  color: var(--color-text);
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 1rem;
  cursor: pointer;
  text-align: center;
  margin-bottom: 0.5rem;
}

.trunk-diagnostics {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.trunk-share-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  align-items: stretch;
  flex-wrap: wrap;
}

.trunk-share-select {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.6rem;
  font-size: 0.95rem;
  background: var(--color-bg-card);
  color: var(--color-text);
  font-family: inherit;
}

.claim-banner {
  box-shadow: var(--shadow-md);
  border-radius: 12px;
  margin-bottom: 0.75rem;
}
.share-review-meta {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.share-review-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-bg-accent);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.share-review-name {
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.share-review-badge {
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--color-amber);
  color: #121212;
  border-radius: 999px;
  padding: 2px 8px;
}

.share-review-details {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.share-review-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.share-review-diffs {
  background: var(--color-bg);
  border-radius: 8px;
  padding: 0.6rem;
  margin-bottom: 0.75rem;
}

.share-review-diff-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 0.4rem;
}

.share-review-diff-row {
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0;
  flex-wrap: wrap;
}

.diff-field {
  font-weight: 500;
  min-width: 4rem;
}

.diff-old {
  text-decoration: line-through;
  color: var(--color-text-muted);
}

.diff-arrow {
  color: var(--color-text-muted);
}

.diff-new {
  color: var(--color-action);
  font-weight: 500;
}

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

.share-review-tag-input {
  width: 100%;
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.6rem;
  font-size: 0.95rem;
  background: var(--color-bg);
  color: var(--color-text);
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.conflict-row {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: var(--color-bg-accent);
  border-radius: 8px;
}

.conflict-options {
  display: flex;
  gap: 0.5rem;
}

.conflict-option {
  flex: 1;
  padding: 0.6rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--color-bg-card);
  cursor: pointer;
  text-align: center;
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}

.conflict-option:hover {
  background: var(--color-bg);
}

.conflict-option--selected {
  border-color: var(--color-action);
  background: var(--color-bg);
  box-shadow: inset 0 0 0 1px var(--color-action);
}

.conflict-val-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 0.2rem;
}

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

.share-review-smart-merge {
  font-size: 0.85rem;
  color: var(--color-action);
  margin-bottom: 0.75rem;
}

/* Settings view */
.settings-section {
  background: var(--color-bg-card);
  border: 1px solid var(--color-bg-accent);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-md);
}

.settings-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-bg-accent);
  gap: 1rem;
}

.settings-row-label {
  font-size: 0.95rem;
}

.settings-number-input {
  width: 5rem;
  border: 1px solid var(--color-bg-accent);
  border-radius: 6px;
  padding: 0.4rem;
  font-size: 1rem;
  background: var(--color-bg-card);
  color: var(--color-text);
  text-align: center;
  font-family: inherit;
}

.settings-theme-control {
  display: flex;
  gap: 0.25rem;
}

.settings-theme-btn {
  background: var(--color-bg-accent);
  border: 1px solid transparent;
  color: var(--color-text-muted);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
}

.settings-theme-btn--active {
  background: var(--color-bg-card);
  border-color: var(--color-action);
  color: var(--color-action);
  font-weight: 500;
}

.settings-toggle {
  display: flex;
  align-items: center;
}

.settings-toggle input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--color-action);
  cursor: pointer;
}

/* Bottom sheet */
.bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--color-bg-card);
  border-radius: 16px 16px 0 0;
  padding: 1rem;
  max-height: 80dvh;
  overflow-y: auto;
  z-index: 101;
}

.bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--color-bg-accent);
  border-radius: 2px;
  margin: 0 auto 1rem;
}

.bottom-sheet-title {
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: center;
}

.bottom-sheet-section {
  margin-bottom: 1rem;
}

.bottom-sheet-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.bottom-sheet-apply-btn {
  width: 100%;
  background: var(--color-action);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  margin-top: 1rem;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pill-btn {
  border: 1px solid var(--color-bg-accent);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  font-size: 0.85rem;
  background: var(--color-bg-card);
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: inherit;
}

.pill-btn--active {
  border-color: var(--color-action);
  background: var(--color-bg-accent);
  color: var(--color-action);
  font-weight: 500;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 5.5rem;
  left: 1rem;
  right: 1rem;
  background: #333;
  color: white;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 200;
  font-size: 0.95rem;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.toast-undo-btn {
  background: none;
  border: none;
  color: var(--color-amber);
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0;
}

/* People view additions */
.owner-badge {
  font-size: 0.75rem;
  color: var(--color-amber);
  font-weight: 400;
  margin-left: 0.3rem;
}

.filter-btn--active {
  border-color: var(--color-action);
  color: var(--color-action);
}

/* Contact form additions */
.form-footer {
  padding: 1rem;
  border-top: 1px solid var(--color-bg-accent);
}

.form-delete-btn {
  width: 100%;
  background: none;
  border: none;
  color: #E05252;
  font-size: 1rem;
  cursor: pointer;
  font-family: inherit;
  padding: 0.75rem;
}

/* ============================================================
   Phase 4 — Contact action buttons
   ============================================================ */

.contact-action-connected, .contact-action-snooze {
  display: flex !important;
}

body[data-is-owned="false"] .contact-action-connected,
body[data-is-owned="false"] .contact-action-snooze {
  display: none !important;
}

.contact-row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-bg-accent);
  margin-top: 0.4rem;
}

.contact-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
  font-family: inherit;
  background: var(--color-bg-accent);
  color: var(--color-text);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.contact-action-btn:active {
  opacity: 0.7;
}

.contact-action-connected {
  background: var(--color-action);
  color: white;
}

.contact-action-snooze {
  color: var(--color-text-muted);
}

/* ============================================================
   Phase 4 — Due row snooze button
   ============================================================ */

.due-row-btns {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
  flex-shrink: 0;
}

.due-row-snooze-btn {
  background: none;
  border: 1px solid var(--color-bg-accent);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

/* ============================================================
   Phase 4 — Gathering rules banner
   ============================================================ */

.gathering-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-action);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.gathering-banner-btn {
  background: white;
  color: var(--color-action);
  border: none;
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ============================================================
   Phase 4 — Journal search
   ============================================================ */

.journal-search-row {
  margin-bottom: 1rem;
}

/* ============================================================
   Phase 4 — Gathering rules in settings
   ============================================================ */

.gathering-rules-list {
  margin-bottom: 0.75rem;
}

.gathering-rules-empty {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.gathering-rule-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-bg-accent);
}

.gathering-rule-name {
  font-size: 0.9rem;
}

.gathering-rule-delete-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.gathering-rule-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.gathering-rule-form-row {
  display: flex;
  gap: 0.5rem;
}

.gathering-rule-select {
  flex: 1;
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.5rem 0.4rem;
  font-size: 0.875rem;
  background: var(--color-bg-card);
  color: var(--color-text);
  font-family: inherit;
}

/* ============================================================
   Phase 4 — Settings navigation row & danger zone
   ============================================================ */

.settings-nav-row {
  cursor: pointer;
}

.settings-nav-chevron {
  font-size: 1.2rem;
  color: var(--color-text-muted);
}

.settings-danger-zone {
  border-top: 2px solid #E05252;
}

.settings-danger-title {
  color: #E05252;
}

.settings-danger-btn {
  width: 100%;
  background: none;
  border: 1px solid #E05252;
  border-radius: 8px;
  color: #E05252;
  font-size: 0.95rem;
  font-family: inherit;
  padding: 0.65rem 1rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
  text-align: left;
}

.settings-danger-btn:active {
  background: rgba(224, 82, 82, 0.1);
}

/* ============================================================
   Phase 4 — Confirm dialog
   ============================================================ */

.confirm-dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1.5rem;
}

.confirm-dialog {
  background: var(--color-bg-card);
  border-radius: 12px;
  padding: 1.5rem;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-md);
}

.confirm-dialog-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.confirm-dialog-message {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.confirm-dialog-hint {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.confirm-dialog-btns {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  justify-content: flex-end;
}

.confirm-dialog-cancel {
  background: var(--color-bg-accent);
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  color: var(--color-text);
  cursor: pointer;
  font-family: inherit;
}

.confirm-dialog-confirm {
  background: #E05252;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  color: white;
  cursor: pointer;
  font-family: inherit;
}

.confirm-dialog-confirm[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================================
   Phase 4 — About view
   ============================================================ */

.about-body {
  padding: 1rem;
}

.about-section {
  margin-bottom: 2rem;
}

.about-section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.about-text {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.about-layer-item {
  margin-bottom: 0.75rem;
}

.about-layer-name {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

.about-layer-desc {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.about-dedication {
  font-style: italic;
  border-left: 3px solid var(--color-action);
  padding-left: 1rem;
}

.about-version {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* ============================================================
   Phase 4 — Diagnostics toggle
   ============================================================ */

.diag-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.diag-toggle-btn {
  background: none;
  border: none;
  font-size: 0.8rem;
  color: var(--color-action);
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}

.diag-detail {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-bg-accent);
}

/* ============================================================
   Phase 4 — Trunk conflict resolution
   ============================================================ */

.trunk-conflict {
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

.trunk-conflict-btns {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.trunk-conflict-btns .trunk-btn {
  flex: 0 0 auto;
  width: auto;
  padding: 0.5rem 1rem;
  margin-bottom: 0;
}

/* ============================================================
   Phase 4 — Onboarding email match nudge
   ============================================================ */

.onboarding-match-nudge {
  font-size: 0.85rem;
  color: var(--color-action);
  text-align: center;
  margin-top: 1rem;
  padding: 0.75rem;
  background: var(--color-bg-accent);
  border-radius: 8px;
}

/* Human-readable JSON toggle */
.trunk-readable-row {
  margin-top: 0.5rem;
}

.trunk-readable-toggle {
  background: none;
  border: none;
  color: var(--color-action);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0;
}

.trunk-readable-area {
  width: 100%;
  margin-top: 0.75rem;
  height: 8rem;
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 0.75rem;
  font-family: 'Courier New', monospace;
  background: var(--color-bg-card);
  color: var(--color-text);
  resize: vertical;
  white-space: pre;
  overflow: auto;
}

/* Print mode */
.print-contact-list {
  display: none;
}

@media print {
  body > *:not(.print-contact-list) { display: none !important; }

  .print-contact-list {
    display: block;
    font-family: serif;
    color: black;
    padding: 1.5cm;
  }

  .print-contact-list h1 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #ccc;
    padding-bottom: 0.5rem;
  }

  .print-contact-row {
    padding: 0.35rem 0;
    border-bottom: 1px solid #eee;
    page-break-inside: avoid;
  }

  .print-contact-name {
    font-weight: bold;
    font-size: 0.95rem;
  }

  .print-contact-details {
    font-size: 0.8rem;
    color: #444;
    margin-top: 1px;
  }
}

.view-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 1.5rem;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  font-style: italic;
  opacity: 0.8;
}

.view-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-bg-accent);
  border-top: 3px solid var(--color-amber);
  border-radius: 50%;
  animation: view-spin 1s linear infinite;
}

@keyframes view-spin {
  0% { transform: rotate(0deg); }
}

/* Contact Profile Sheet */
.profile-sheet {
  padding: 1rem 0;
}

.profile-action-row {
  display: flex;
  justify-content: space-around;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-bg-accent);
}

.profile-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--color-text);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  min-width: 60px;
}

.profile-action-btn span {
  font-size: 1.75rem;
  transition: transform 0.2s;
}

.profile-action-btn:active span {
  transform: scale(0.9);
}

.profile-action-btn label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.profile-journal-box {
  background: var(--color-bg-card);
  border: 1px solid var(--color-bg-accent);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.profile-section-label {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--color-amber);
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.profile-last-log {
  border-left: 2px solid var(--color-amber);
  padding-left: 1rem;
  margin: 0.5rem 0;
}

.profile-log-meta {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.profile-log-comment {
  font-family: 'Caveat', cursive;
  font-size: 1.25rem;
  color: var(--color-text);
  line-height: 1.4;
}

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

.profile-details-box {
  padding: 0.5rem 0;
}

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

/* Transitions */
.view-fade-in {
  animation: view-fade-in 0.25s ease-out;
}

@keyframes view-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Legacy Styling (Deceased) */
.contact-row--legacy, .due-row--legacy {
  opacity: 0.7;
  border-left: 3px solid #777 !important;
  background-color: var(--color-bg-accent) !important;
}

.legacy-icon {
  font-size: 0.9rem;
  margin-left: 6px;
  vertical-align: middle;
  filter: grayscale(1);
}

/* Settings Tabs */
.settings-tabs {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

.settings-tab-btn {
  flex: 1;
  max-width: 150px;
  padding: 0.6rem;
  border: 1px solid var(--color-bg-accent);
  background: var(--color-bg-card);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s;
}

.settings-tab-btn--active {
  background: var(--color-action);
  color: white;
  border-color: var(--color-action);
  box-shadow: 0 4px 12px rgba(74, 103, 65, 0.2);
}

/* Dunbar Bar Charts */
.dunbar-charts {
  margin: 1.5rem 0;
}

.chart-item {
  margin-bottom: 1.25rem;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
}

.chart-label {
  font-weight: 600;
}

.chart-count {
  color: var(--color-text-muted);
}

.chart-bar-bg {
  height: 8px;
  background: var(--color-bg-accent);
  border-radius: 4px;
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  background: var(--color-action);
  border-radius: 4px;
  transition: width 0.5s ease-out;
}

.chart-bar-fill--warning {
  background: var(--color-amber);
}

.vision-text {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text);
  margin-bottom: 1rem;
}

.vision-quote {
  font-family: 'Caveat', cursive;
  font-size: 1.25rem;
  color: var(--color-text-muted);
  text-align: center;
  margin: 2rem 0;
  padding: 0 1rem;
}

/* Stewardship Mode & Drag-Drop */
.stewardship-toggle {
  background: none;
  border: 1px solid var(--color-bg-accent);
  border-radius: 8px;
  padding: 0.6rem;
  font-size: 1.1rem;
  cursor: pointer;
  background: var(--color-bg-card);
  transition: all 0.2s ease;
}

.stewardship-toggle--active {
  background: var(--color-action);
  color: white;
  border-color: var(--color-action);
}

.group-header {
  position: sticky;
  top: 0;
  background: var(--color-bg);
  padding: 1rem 0 0.5rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-bg-accent);
  z-index: 10;
  margin-top: 0.5rem;
}

.group-header-count {
  background: var(--color-bg-accent);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
}

.group-header.drop-active {
  background: var(--color-bg-accent);
  color: var(--color-action);
  outline: 2px dashed var(--color-action);
}

.contact-row[draggable="true"] {
  cursor: grab;
}

.contact-row.dragging {
  opacity: 0.4;
  background: var(--color-bg-accent);
}

.layer-assign-group {
  display: flex;
  gap: 4px;
}

.layer-assign-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--color-bg-accent);
  background: var(--color-bg-card);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.layer-assign-btn:hover {
  border-color: var(--color-action);
  color: var(--color-action);
}

.layer-assign-btn--active {
  background: var(--color-action);
  color: white;
  border-color: var(--color-action);
}

.contact-row--stewardship {
  padding: 0.5rem 0;
}
