/* ===========================
   ValeKeeper — BASE STYLES
   =========================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  /* Sage Bright — default palette (overridden per-theme by [data-theme] in addStyles) */
  --bg-primary: #F4F1EC;
  --bg-secondary: #EBE7E0;
  --bg-card: #E4DFD7;
  --bg-overlay: #CCC7BF;
  --bubble-companion: #D8D3CB;
  --bubble-companion-alt: #CECAC2;
  --input-bg: #EAE6DF;
  --input-border: #B8B0A6;
  --text-primary: #1E2A30;
  --text-secondary: #445058;
  --text-muted: #6E7E88;
  --accent: #6A9465;
  --accent-soft: #5A8455;
  --accent-text: #F4F1EC;
  --border: #C8C3BB;
  --shadow: 0 4px 16px rgba(0,0,0,0.12);
  --success: #6A9465;
  --warning: #A87830;
  --danger: #A05050;
  --avatar-base: #445058;
  --avatar-highlight: #1E2A30;
  --avatar-shadow-color: #6E7E88;
  --avatar-accent: #6A9465;
  --avatar-accent-soft: rgba(106,148,101,0.4);
  --avatar-bg: transparent;
  --avatar-stroke: rgba(30,42,48,0.25);
  --radius: 16px;
  --radius-sm: 8px;
  --transition: all 0.3s ease;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 16px;
  line-height: 1.6;
}

#app {
  height: 100vh;
  width: 100vw;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ===========================
   SCREENS
   =========================== */

.screen {
  display: none;
  min-height: 100vh;
  padding: 24px 20px;
  flex-direction: column;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===========================
   TYPOGRAPHY
   =========================== */

h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h2 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
}

.text-muted {
  color: var(--text-muted);
  font-size: 13px;
}

.text-accent {
  color: var(--accent);
}

.text-success {
  color: var(--success);
}

/* ===========================
   BUTTONS
   =========================== */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  gap: 8px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:active {
  background: var(--accent-soft);
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:active {
  transform: scale(0.98);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ===========================
   CARDS
   =========================== */

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ===========================
   INPUTS
   =========================== */

.input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 15px;
  transition: var(--transition);
  outline: none;
}

.input:focus {
  border-color: var(--accent);
}

textarea.input {
  resize: none;
  min-height: 120px;
  line-height: 1.6;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
}

/* ===========================
   SPACING UTILITIES
   =========================== */

.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mt-48 { margin-top: 48px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

/* ===========================
   LOGO / BRAND
   =========================== */

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.brand-icon {
  width: 72px;
  height: 72px;
  background: var(--accent);
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent);
}

.brand-name {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.brand-tagline {
  font-size: 14px;
  color: var(--text-muted);
}

@keyframes ellipsis {
  0% { content: '.'; }
  33% { content: '..'; }
  66% { content: '...'; }
  100% { content: '.'; }
}

.loading-ellipsis::after {
  content: '.';
  animation: ellipsis 1.2s infinite;
}

/* ── Spark flash overlay ── */
.spark-flash-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 9999;
  background: transparent;
}

.spark-flash-navy {
  position: absolute;
  width: 120px;
  height: 120px;
  animation:
    spark-scale 1400ms ease-in-out forwards,
    spark-navy-fade 1400ms ease-in-out forwards;
}

.spark-flash-cream {
  position: absolute;
  width: 120px;
  height: 120px;
  animation:
    spark-scale 1400ms ease-in-out forwards,
    spark-cream-fade 1400ms ease-in-out forwards;
}

@keyframes spark-scale {
  0%   { transform: scale(0.3); }
  21%  { transform: scale(1);   }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1.1); }
}

@keyframes spark-navy-fade {
  0%   { opacity: 0; }
  21%  { opacity: 1; }
  64%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes spark-cream-fade {
  0%   { opacity: 0; }
  40%  { opacity: 0; }
  64%  { opacity: 1; }
  100% { opacity: 0; }
}

.spark-flash-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-primary, #f5f0e8);
  opacity: 0;
}

@keyframes spark-dot-drift {
  0%   { transform: translate(0, 0); opacity: 0; }
  12%  { opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)); opacity: 0; }
}