/* Faithful Gratitude Journal — senior-friendly, offline-first UI */

:root {
  --accent: #7a5012;
  --accent-hover: #5e3d0e;
  --accent-soft: #f5e8d4;
  --accent-mid: #9a6a28;
  --secondary: #2c5f4a;
  --secondary-soft: #e6f0eb;
  --danger: #9b2c2c;
  --danger-soft: #fdecec;
  --ok: #1f6b4a;
  --ok-soft: #e6f4ed;
  --text: #1c1814;
  --text-muted: #5a5248;
  --border: #d9cfc0;
  --surface: #fffbf5;
  --card: #fff3e0;
  --bg: #f7f0e6;
  --scripture-bg: #faf6ef;
  --shadow: 0 2px 12px rgba(28, 24, 20, 0.08);
  --radius: 16px;
  --radius-sm: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --touch: 48px;
  --max: 720px;
}

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

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

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.skip-link:focus {
  left: 0.5rem;
  top: 0.5rem;
}

/* Header */
.app-header {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

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

.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: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.35rem;
  flex-shrink: 0;
}

.brand h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

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

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Tabs */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0.5rem 0.75rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 49;
}

.tab {
  flex: 1 0 auto;
  min-height: var(--touch);
  min-width: 4.5rem;
  padding: 0.5rem 0.75rem;
  border: 2px solid transparent;
  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:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

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

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

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.panel-title {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text);
}

.panel-title:focus {
  outline: none;
}

.panel-lead {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 1rem;
}

.panel-actions {
  margin-bottom: 1rem;
}

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

.prompt-card {
  background: var(--card);
}

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

.card-head h3 {
  margin: 0;
  font-size: 1.15rem;
}

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

.eyebrow {
  margin: 0 0 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.verse-ref {
  margin: 0.25rem 0 0;
  font-weight: 600;
  color: var(--secondary);
  font-size: 1rem;
}

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

@media (min-width: 540px) {
  .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;
  box-shadow: var(--shadow);
}

.stat-label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
}

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

.scripture {
  margin: 0 0 1rem;
  padding: 1.1rem 1.15rem;
  background: var(--scripture-bg);
  border-left: 4px solid var(--secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 1.1rem;
  line-height: 1.65;
  color: var(--secondary);
  font-style: italic;
}

.scripture.compact {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  padding: 0.85rem 1rem;
}

.prompt-text {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.45;
}

.prompt-text.compact {
  font-size: 1.05rem;
  margin-bottom: 1rem;
}

.step-title {
  margin: 0.75rem 0 0.4rem;
  font-size: 1.05rem;
  color: var(--accent);
}

.body-text {
  margin: 0 0 0.75rem;
  color: var(--text);
}

.entry-full {
  white-space: pre-wrap;
  font-size: 1.05rem;
  line-height: 1.65;
}

.entry-preview {
  margin: 0.5rem 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

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

.small {
  font-size: 0.9rem;
}

/* Pills */
.pill {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

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

.pill-done {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill-sample {
  background: var(--secondary-soft);
  color: var(--secondary);
  margin-top: 0.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: var(--touch);
  min-width: var(--touch);
  padding: 0.55rem 1.1rem;
  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;
}

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

.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(--border);
}

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

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

.btn-danger:hover:not(:disabled) {
  background: #7f2424;
}

.btn-text {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  min-width: auto;
  text-decoration: underline;
  text-underline-offset: 2px;
}

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

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.devotion-actions {
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

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

/* Fields */
.field {
  margin-bottom: 1rem;
}

.field.grow {
  flex: 1 1 12rem;
}

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

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

.field-error {
  margin: 0.4rem 0 0;
  color: var(--danger);
  font-weight: 600;
  font-size: 0.95rem;
}

input[type="text"],
input[type="search"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 0.6rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}

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

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

.checkbox-field {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

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

.checkbox-field label {
  margin: 0;
  font-weight: 500;
}

/* Filters */
.filters {
  padding: 0.9rem 1rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.filter-row .field {
  margin-bottom: 0;
  min-width: 8rem;
}

/* Lists */
.item-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.item-card {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  font: inherit;
  color: inherit;
  min-height: var(--touch);
}

.item-card:hover {
  border-color: var(--accent-mid);
  background: var(--card);
}

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

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

.item-date {
  margin: 0;
  font-weight: 700;
  color: var(--text);
  font-size: 1rem;
}

.item-ref {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--secondary);
}

.item-preview {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.item-actions .btn {
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  font-size: 0.95rem;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  margin-top: 0.5rem;
}

.empty-title {
  margin: 0 0 0.4rem;
  font-size: 1.2rem;
  font-weight: 700;
}

.empty-msg {
  margin: 0 0 1rem;
  color: var(--text-muted);
}

/* Month nav */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.month-label {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  flex: 1 1 auto;
  color: var(--text);
}

/* Chips */
.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  display: inline-block;
  padding: 0.4rem 0.75rem;
  background: var(--secondary-soft);
  color: var(--secondary);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Status */
.status-msg {
  margin: 0.5rem 0 0;
  min-height: 1.4em;
  color: var(--secondary);
  font-weight: 600;
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 1.25rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: center;
}

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

/* Dialogs */
.modal {
  border: none;
  border-radius: var(--radius);
  padding: 0;
  max-width: min(560px, calc(100vw - 1.5rem));
  width: 100%;
  box-shadow: 0 12px 40px rgba(28, 24, 20, 0.2);
  background: var(--surface);
  color: var(--text);
}

.modal::backdrop {
  background: rgba(28, 24, 20, 0.45);
}

.modal-inner {
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 720px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

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

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

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 0.9rem 1.15rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.compose-prompt-block {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  background: var(--card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

/* Voice */
.voice-body {
  text-align: center;
}

.voice-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0.5rem auto 1rem;
  width: 88px;
  height: 88px;
}

.voice-pulse {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.85;
}

.voice-indicator.listening .voice-pulse {
  animation: pulse 1.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .voice-indicator.listening .voice-pulse {
    animation: none;
    outline: 4px solid var(--accent-mid);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.12);
    opacity: 1;
  }
}

.voice-label {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}

.voice-transcript {
  margin: 0 0 0.75rem;
  min-height: 3rem;
  padding: 0.85rem;
  background: var(--scripture-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  text-align: left;
  white-space: pre-wrap;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  max-width: min(90vw, 420px);
  padding: 0.85rem 1.15rem;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  box-shadow: var(--shadow);
  text-align: center;
}

.reminder-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
}

.reminder-item h3 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.reminder-item p {
  margin: 0 0 0.65rem;
  color: var(--text-muted);
}

.reminder-item.dismissed {
  opacity: 0.65;
}
