:root {
  --bg: #FAF6EE;
  --surface: #FFFFFF;
  --surface-soft: #F4EFE4;
  --border: #E6DEC8;
  --primary: #2E473B;
  --primary-dark: #1F3229;
  --gold: #C49A45;
  --gold-soft: #F9F2DF;
  --text: #222824;
  --text-muted: #5F6862;
  --danger: #9B3B3B;
  --danger-bg: #FDF2F2;
  --radius: 18px;
  --shadow: 0 6px 20px rgba(46, 71, 59, 0.06);
  --font-sans: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', sans-serif;
  --font-serif: 'Noto Serif KR', Georgia, serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app-shell {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(46, 71, 59, 0.96);
  backdrop-filter: blur(10px);
  color: #fff;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid rgba(242, 215, 138, 0.25);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-cross {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(242, 215, 138, 0.16);
  border: 1px solid rgba(242, 215, 138, 0.4);
  color: #F2D78A;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-sub {
  margin: 0;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.8);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 11px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #F2D78A;
}

.status-badge.online .status-dot {
  background: #7EE2A8;
}

/* Gospel Banner */
.gospel-banner {
  background: linear-gradient(135deg, #F5EEDB 0%, #EFE5CC 100%);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}

.gospel-verse {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 12.5px;
  color: var(--primary-dark);
  text-align: center;
  line-height: 1.55;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 14px 14px calc(86px + env(safe-area-inset-bottom));
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.tab-panel.active {
  display: flex;
}

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

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.section-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 700;
  color: var(--primary-dark);
}

.section-desc {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.pill-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: var(--gold-soft);
  border: 1px solid rgba(196, 154, 69, 0.35);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Chips */
.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.topic-chip,
.filter-chip {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  padding: 6px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.topic-chip.selected,
.filter-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Inputs & Buttons */
.input-wrap textarea,
.followup-input-row input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: #FFFEFA;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.input-wrap textarea:focus,
.followup-input-row input:focus {
  border-color: var(--primary);
}

.input-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.input-actions.end {
  justify-content: flex-end;
}

.primary-btn {
  flex: 1;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  padding: 13px 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(46, 71, 59, 0.22);
  transition: transform 0.12s ease, opacity 0.2s;
}

.primary-btn:active {
  transform: scale(0.98);
}

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

.primary-btn.compact {
  flex: 0 0 auto;
  padding: 10px 16px;
}

.gold-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #D2A850 0%, #B4882E 100%);
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  padding: 13px 16px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(196, 154, 69, 0.3);
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 11px 12px;
  border-radius: 14px;
  cursor: pointer;
  white-space: nowrap;
}

.icon-btn.small {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 10px;
}

.icon-btn.listening {
  background: #FDE8E8;
  border-color: #E07A7A;
  color: #9B2C2C;
}

/* Loading & Error */
.hidden {
  display: none !important;
}

.loading-card {
  text-align: center;
  padding: 28px 18px;
}

.breathing-cross {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  display: grid;
  place-items: center;
  font-size: 24px;
  animation: breathe 2.2s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(196, 154, 69, 0.25); }
  50% { transform: scale(1.08); box-shadow: 0 0 0 14px rgba(196, 154, 69, 0); }
}

.loading-title {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-weight: 600;
  color: var(--primary-dark);
}

.loading-sub {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.inline-loading {
  margin-top: 12px;
  text-align: center;
  font-size: 13.5px;
  color: var(--primary);
}

.error-card {
  background: var(--danger-bg);
  border-color: #ECC8C8;
  color: var(--danger);
  font-size: 13.5px;
}

/* Result Stack */
.result-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.result-top-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.result-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--primary-dark);
}

.empathy-text {
  margin: 0;
  font-size: 14.5px;
  color: var(--text);
}

.verses-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.verse-card {
  background: linear-gradient(180deg, #FFFEFA 0%, #FAF5E8 100%);
  border: 1px solid #E3D6B8;
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 16px;
}

.verse-ref {
  font-size: 12.5px;
  font-weight: 700;
  color: #8E6B23;
  margin-bottom: 6px;
}

.verse-text {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 15.5px;
  color: var(--primary-dark);
  line-height: 1.65;
}

.verse-meditation {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
  border-top: 1px dashed #DFD3B6;
  padding-top: 8px;
}

.sub-heading {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: 15.5px;
  color: var(--primary-dark);
}

/* Perspective Comparison */
.view-compare {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.view-box {
  border-radius: 14px;
  padding: 12px 14px;
}

.view-box p {
  margin: 4px 0 0;
  font-size: 13.8px;
}

.view-label {
  font-size: 11.5px;
  font-weight: 700;
  display: inline-block;
}

.my-view {
  background: #F4F2EE;
  border: 1px solid #E2DDD3;
  color: var(--text-muted);
}

.god-view {
  background: #EEF4F0;
  border: 1px solid #C6DACD;
  color: var(--primary-dark);
}

.view-arrow {
  text-align: center;
  color: var(--gold);
  font-weight: 700;
  font-size: 15px;
}

.insight-text {
  margin: 0;
  font-size: 13.8px;
  color: var(--text);
}

/* Prayer Card */
.prayer-card {
  background: linear-gradient(180deg, #FFFFFF 0%, #F7F4EC 100%);
}

.prayer-text {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: 14.5px;
  line-height: 1.75;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.8);
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.action-step-box {
  background: var(--gold-soft);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 13.5px;
  color: #5C4718;
  margin-bottom: 14px;
}

/* Followup */
.followup-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.chat-bubble {
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 13.8px;
  white-space: pre-wrap;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--primary);
  color: #fff;
  max-width: 86%;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
  max-width: 94%;
}

.followup-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Perspective Tab */
.perspective-output {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mini-verse {
  margin: 0;
  padding: 12px 14px;
  border-left: 3px solid var(--gold);
  background: var(--gold-soft);
  border-radius: 12px;
}

.mini-verse p {
  margin: 0 0 4px;
  font-family: var(--font-serif);
  font-size: 14px;
}

.mini-verse footer {
  font-size: 12px;
  font-weight: 700;
  color: #7D5E1E;
}

.declaration-box {
  background: #EEF4F0;
  border-radius: 12px;
  padding: 12px 14px;
}

.decl-label {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--primary);
}

.declaration-box p {
  margin: 4px 0 0;
  font-weight: 600;
  font-size: 14px;
  color: var(--primary-dark);
}

.truth-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.truth-item {
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 12px 14px;
}

.truth-item strong {
  color: var(--primary-dark);
  font-size: 14px;
}

.truth-item p {
  margin: 4px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* Journal */
.journal-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.journal-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.journal-concern {
  margin: 0 0 8px;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--primary-dark);
}

.journal-verse {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 13.5px;
  color: #6B531F;
  background: var(--gold-soft);
  padding: 8px 10px;
  border-radius: 10px;
}

.journal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.peace-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: #216E45;
  background: #E4F5EC;
  padding: 4px 10px;
  border-radius: 999px;
}

/* Scripture Cards */
.scripture-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.curated-card {
  background: linear-gradient(145deg, #FFFFFF 0%, #F7F1E2 100%);
  border: 1px solid #E2D5B7;
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.curated-theme {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: rgba(46, 71, 59, 0.08);
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.curated-text {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-size: 15.5px;
  color: var(--primary-dark);
  line-height: 1.65;
}

.curated-ref {
  font-size: 12.5px;
  font-weight: 700;
  color: #8E6B23;
  margin-bottom: 10px;
}

.curated-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px dashed #DFD3B6;
  padding-top: 10px;
  gap: 8px;
}

.curated-note {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 540px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 6px max(8px, env(safe-area-inset-bottom));
  z-index: 30;
}

.nav-item {
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px;
  color: var(--text-muted);
  font-family: inherit;
  cursor: pointer;
}

.nav-item.active {
  color: var(--primary-dark);
  font-weight: 700;
}

.nav-icon {
  font-size: 19px;
}

.nav-label {
  font-size: 11px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(78px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31, 50, 41, 0.94);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 50;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  white-space: nowrap;
}
