/* Faith Bridge Devotional — senior-friendly, offline, one accent */
:root {
  --accent: #1e5a52;
  --accent-hover: #164740;
  --accent-soft: #e6f2f0;
  --accent-mid: #2d7a70;
  --bg: #f6f4f0;
  --surface: #ffffff;
  --text: #1a1f1e;
  --text-muted: #4a5552;
  --border: #d0d8d5;
  --danger: #8b2e2e;
  --danger-hover: #6f2424;
  --danger-soft: #f8eaea;
  --answered: #1e5a52;
  --open-prayer: #7a4a12;
  --open-soft: #faf0e4;
  --scripture: #2c4a6e;
  --reflection: #4a3d6b;
  --shadow: 0 1px 3px rgba(26, 31, 30, 0.08), 0 4px 12px rgba(26, 31, 30, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --space: 1rem;
  --touch: 48px;
  --max: 720px;
}

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

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}

/* Focus */
:focus {
  outline: none;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  background: var(--accent);
  color: #fff;
  padding: 0.75rem 1rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
  left: 0;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem var(--space);
  padding-top: max(0.85rem, env(safe-area-inset-top));
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.35rem;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
  text-wrap: balance;
}

.tagline {
  margin: 0.15rem 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Tabs */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.5rem var(--space);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  max-width: 100%;
  scrollbar-width: thin;
}

.tab-nav::-webkit-scrollbar {
  height: 4px;
}

.tab {
  flex: 1 0 auto;
  min-height: var(--touch);
  min-width: 4.5rem;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  white-space: nowrap;
}

.tab:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.tab.active,
.tab[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
}

/* Main */
#main {
  flex: 1;
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.25rem var(--space) 2rem;
}

.panel[hidden] {
  display: none !important;
}

.panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
  font-weight: 700;
  text-wrap: balance;
  line-height: 1.25;
}

.panel-lead {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  text-wrap: pretty;
}

.panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.25rem;
}

.panel-toolbar .panel-lead {
  margin-bottom: 0;
}

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 520px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
}

.stat-label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-value {
  margin: 0.25rem 0 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem;
  margin-bottom: 1.15rem;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.card-head h3 {
  margin: 0;
}

.card-note {
  margin: -0.35rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.95rem;
  text-wrap: pretty;
}

.card-flat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.65rem 1.15rem;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
  transition: background 0.15s ease-out, color 0.15s ease-out, border-color 0.15s ease-out;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent-soft);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  border-color: var(--danger-hover);
}

.btn-text {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  min-height: 44px;
  padding: 0.4rem 0.6rem;
  font-weight: 600;
}

.btn-text:hover {
  background: var(--accent-soft);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  min-width: var(--touch);
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
}

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

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: #fff;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.btn-secondary .badge {
  background: var(--accent);
  color: #fff;
}

/* Forms */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.9rem;
}

.form-stack .field {
  margin-bottom: 0;
}

.field label {
  font-weight: 600;
  color: var(--text);
}

.optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.field-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 520px) {
  .field-row {
    grid-template-columns: repeat(3, 1fr);
  }

  .filters .field-row {
    grid-template-columns: repeat(3, 1fr);
  }
}

.field-check {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.75rem;
}

.field-check input[type="checkbox"] {
  width: 1.35rem;
  height: 1.35rem;
  min-width: 1.35rem;
  margin-top: 0.2rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.field-check label {
  font-weight: 500;
  cursor: pointer;
}

input[type="text"],
input[type="search"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 0.65rem 0.85rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--surface);
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath fill='%231e5a52' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  padding-right: 2.5rem;
}

textarea {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.5;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--accent-mid);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
  outline-offset: 0;
}

.form-error {
  margin: 0 0 0.75rem;
  padding: 0.75rem 0.9rem;
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.status-msg {
  margin: 0.85rem 0 0;
  padding: 0.65rem 0.85rem;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-weight: 600;
}

/* Lists */
.item-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.item-list.compact {
  gap: 0.55rem;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.item-list.compact .item-card {
  padding: 0.85rem 1rem;
}

.item-card.pinned {
  border-color: var(--accent-mid);
  box-shadow: 0 0 0 1px var(--accent-mid), var(--shadow);
}

.item-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.4rem;
}

.item-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.3;
  text-wrap: balance;
}

.item-meta {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.item-body {
  margin: 0.5rem 0 0;
  color: var(--text);
  text-wrap: pretty;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-body.full {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.item-actions .btn {
  min-height: 48px;
  padding: 0.5rem 0.9rem;
  font-size: 0.95rem;
}

.list-meta {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.empty-state,
.empty-hint {
  margin: 0.5rem 0 0;
  padding: 1.25rem;
  text-align: center;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-wrap: pretty;
}

.empty-state .btn {
  display: flex;
  margin: 1rem auto 0;
  max-width: 16rem;
}

.empty-hint {
  padding: 0.9rem 1rem;
  font-size: 0.95rem;
}

/* Pills */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
}

.pill-prayer {
  background: var(--open-soft);
  color: var(--open-prayer);
}

.pill-reflection {
  background: #eeeaf5;
  color: var(--reflection);
}

.pill-scripture {
  background: #e8eef5;
  color: var(--scripture);
}

.pill-open {
  background: var(--open-soft);
  color: var(--open-prayer);
}

.pill-answered {
  background: var(--accent-soft);
  color: var(--answered);
}

.pill-sample {
  background: #f0eee8;
  color: #5a5548;
}

.pill-pin {
  background: var(--accent-soft);
  color: var(--accent);
}

.scripture-ref {
  margin: 0.4rem 0 0;
  font-style: italic;
  color: var(--scripture);
  font-weight: 600;
}

/* Avatar */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.member-row {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.member-info {
  flex: 1;
  min-width: 0;
}

/* Insights bars */
.bar-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 7rem 1fr 2.5rem;
  gap: 0.65rem;
  align-items: center;
}

.bar-label {
  font-weight: 600;
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  min-width: 0;
  transition: width 0.2s ease-out;
}

.bar-count {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.4rem;
}

.week-day {
  text-align: center;
  padding: 0.65rem 0.25rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.week-day.has-posts {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
}

.week-day .day-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.week-day .day-count {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* Modal */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: min(520px, calc(100vw - 1.5rem));
  width: 100%;
  box-shadow: 0 16px 48px rgba(26, 31, 30, 0.2);
  background: var(--surface);
  color: var(--text);
}

.modal.modal-sm {
  max-width: min(400px, calc(100vw - 1.5rem));
}

.modal::backdrop {
  background: rgba(26, 31, 30, 0.45);
}

.modal-body {
  padding: 1.25rem 1.25rem 1.35rem;
  max-height: min(90dvh, 720px);
  overflow-y: auto;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
  margin-top: 1.15rem;
  padding-top: 0.25rem;
}

.view-content .item-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.view-content .item-body {
  margin-top: 0.85rem;
  font-size: 1.05rem;
  white-space: pre-wrap;
}

.view-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(420px, calc(100vw - 2rem));
  padding: 0.9rem 1.2rem;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  text-align: center;
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 1.25rem var(--space);
  padding-bottom: max(1.25rem, env(safe-area-inset-bottom));
  text-align: center;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.app-footer p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: var(--max);
  margin-inline: auto;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
