/* === THE FIRES WITHIN — Main Stylesheet === */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a { color: var(--color-gold); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--color-gold-light); }

img { max-width: 100%; height: auto; display: block; }

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-heading);
  color: var(--color-gold);
  line-height: 1.3;
}
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }

p { color: var(--color-text); margin-bottom: var(--space-md); }

/* --- Layout --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.page-content {
  flex: 1;
  padding: var(--space-xl) 0;
}

/* --- Header / Navigation --- */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-md) 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.site-logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-gold);
  letter-spacing: 1px;
  text-transform: uppercase;
  white-space: nowrap;
}

.site-logo img {
  height: 40px;
  width: auto;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  margin-right: auto;
}

.site-nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text);
  transition: color 0.2s;
  white-space: nowrap;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--color-gold);
}

/* Auth button in nav */
.btn-auth {
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.813rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-auth-login {
  background: var(--color-fire);
  color: #fff;
}
.btn-auth-login:hover { background: #E04420; }

.btn-auth-profile {
  background: var(--color-surface-raised);
  color: var(--color-gold);
  border: 1px solid var(--color-border);
}
.btn-auth-profile:hover { background: var(--color-border); }

/* Mobile hamburger */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-sm);
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-gold);
  margin: 5px 0;
  transition: all 0.3s;
}

/* --- Footer --- */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-xl) 0 var(--space-lg);
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-brand {
  font-family: var(--font-heading);
  color: var(--color-gold);
  font-size: 0.875rem;
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
}

.footer-links a {
  font-size: 0.813rem;
  color: var(--color-text-secondary);
}
.footer-links a:hover { color: var(--color-gold); }

.footer-copy {
  width: 100%;
  text-align: center;
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary { background: var(--color-fire); color: #fff; }
.btn-primary:hover { background: #E04420; color: #fff; }

.btn-secondary {
  background: transparent;
  color: var(--color-gold);
  border: 2px solid var(--color-gold);
}
.btn-secondary:hover { background: rgba(212,168,84,0.1); color: var(--color-gold); }

.btn-ghost {
  background: rgba(200,56,24,0.1);
  color: var(--color-fire-light);
}
.btn-ghost:hover { background: rgba(200,56,24,0.2); }

/* --- Cards --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: border-color 0.2s, transform 0.2s;
}

.card:hover {
  border-color: var(--color-gold-dark);
  transform: translateY(-2px);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--color-gold);
  margin-bottom: var(--space-xs);
}

.card-meta {
  font-size: 0.688rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: var(--space-sm);
}

.card-body {
  font-size: 0.875rem;
  color: var(--color-text);
  line-height: 1.6;
}

/* --- Badges --- */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.688rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.badge-risk-high { background: var(--color-risk-high); color: #fff; }
.badge-risk-medium { background: var(--color-risk-medium); color: #fff; }
.badge-risk-low { background: var(--color-risk-low); color: #fff; }
.badge-risk-positive { background: var(--color-risk-positive); color: #fff; }

.badge-level {
  background: var(--color-surface-raised);
  color: var(--color-gold);
  border: 1px solid var(--color-border);
}

.badge-phase {
  font-size: 0.625rem;
  padding: 3px 10px;
}

/* Info tooltip icon — used inline next to headings to explain metadata */
.info-tip {
  display: inline-block;
  margin-left: 6px;
  width: 18px;
  height: 18px;
  line-height: 18px;
  font-size: 11px;
  text-align: center;
  border-radius: 50%;
  background: rgba(212,168,84,0.15);
  border: 1px solid var(--color-gold-dark);
  color: var(--color-gold);
  cursor: help;
  font-weight: normal;
  vertical-align: middle;
  font-style: normal;
}
.info-tip:hover { background: rgba(212,168,84,0.3); }

.badge-phase-1 { background: var(--color-phase-apparent-normalcy); color: #C4C4A0; }
.badge-phase-2 { background: var(--color-phase-buildup); color: #E8A0A0; }
.badge-phase-3 { background: var(--color-phase-actingout); color: #E8C098; }
.badge-phase-4 { background: var(--color-phase-justification); color: #D4B8A0; }
.badge-phase-5 { background: var(--color-phase-pretend-normal); color: #A0B8D4; }

/* --- Search & Filters --- */
.search-bar {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.search-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.938rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input::placeholder { color: var(--color-text-muted); }
.search-input:focus { border-color: var(--color-gold); }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.filter-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover { border-color: var(--color-gold-dark); color: var(--color-gold); }
.filter-btn.active {
  background: var(--color-gold);
  color: var(--color-bg);
  border-color: var(--color-gold);
}

/* --- Grid Layouts --- */
.emotion-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-lg);
}

/* --- Hero Section (Homepage) --- */
.hero {
  text-align: center;
  padding: var(--space-2xl) 0;
  background: radial-gradient(ellipse at center bottom, rgba(140,30,18,0.12) 0%, transparent 70%);
}

.hero h1 {
  font-size: 2.5rem;
  margin-bottom: var(--space-md);
}

.hero p {
  font-size: 1.125rem;
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto var(--space-lg);
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-md);
  flex-wrap: wrap;
}

/* --- Emotion Detail Page --- */
.emotion-header {
  margin-bottom: var(--space-xl);
}

.emotion-name {
  font-size: 2.5rem;
  margin-bottom: var(--space-sm);
}

/* Pronunciation */
.pronounce-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(212,168,84,0.15);
  border: 1px solid var(--color-gold-dark);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  color: var(--color-gold);
  cursor: pointer;
  margin-left: var(--space-sm);
  vertical-align: middle;
  transition: all 0.2s;
}
.pronounce-btn:hover {
  background: rgba(212,168,84,0.3);
  transform: scale(1.1);
}
.pronounce-btn:active { transform: scale(0.95); }

.emotion-phonetic {
  font-family: var(--font-body);
  font-size: 1rem;
  font-style: italic;
  color: var(--color-text-muted);
  margin-bottom: var(--space-md);
  letter-spacing: 0.5px;
}

.emotion-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.emotion-section {
  margin-bottom: var(--space-xl);
}

.emotion-section h2 {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-border);
}

.emotion-definition {
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--color-text);
}

.emotion-example {
  padding: var(--space-lg);
  background: var(--color-surface);
  border-left: 3px solid var(--color-gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: var(--color-text-secondary);
  line-height: 1.7;
}

.related-emotions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.related-link {
  padding: 8px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  transition: all 0.2s;
}
.related-link:hover {
  border-color: var(--color-gold);
  background: var(--color-surface-raised);
}

/* --- Loading & Empty States --- */
.loading {
  display: flex;
  justify-content: center;
  padding: var(--space-2xl);
}

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

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--color-text-secondary);
}

/* --- Offline Indicator --- */
.offline-banner {
  display: none;
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  text-align: center;
  padding: var(--space-sm);
  font-size: 0.75rem;
}

body.is-offline .offline-banner { display: block; }

/* --- Toast Notifications --- */
.toast {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-size: 0.875rem;
  color: var(--color-text);
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
}

.toast.show { transform: translateY(0); opacity: 1; }

/* --- Emotion Face Icons --- */
.emotion-faces-panel {
  background: #2E2014;
  border: 1px solid #4A3828;
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  max-width: 960px;
  margin: 0 auto;
}

.emotion-faces-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  gap: 12px;
}

.emotion-face-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  background: #3A2818;
  border: 1px solid #5A4030;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.25s;
  cursor: pointer;
  min-width: 82px;
  max-width: 100px;
}

.emotion-face-card:hover {
  border-color: var(--color-gold);
  background: #4A3828;
  transform: translateY(-3px);
}

.emotion-face-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.emotion-face-icon svg {
  width: 48px;
  height: 48px;
}

.emotion-face-label {
  font-family: var(--font-heading);
  font-size: 0.78rem;
  font-weight: 600;
  color: #F5EDE4;
  text-align: center;
}

.emotion-face-card:hover .emotion-face-label {
  color: var(--color-gold);
}

/* --- Global Autocomplete Search --- */
.global-search-wrapper {
  position: relative;
  flex: 0 1 260px;
  min-width: 180px;
}

.global-search-input {
  width: 100%;
  padding: 8px 14px 8px 34px;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.813rem;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.global-search-input::placeholder { color: var(--color-text-muted); }
.global-search-input:focus {
  border-color: var(--color-gold);
  background: var(--color-surface);
}

.global-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
  width: 14px !important;
  height: 14px !important;
  max-width: 14px !important;
  max-height: 14px !important;
  min-width: 14px;
  min-height: 14px;
  flex-shrink: 0;
  display: block;
}

.autocomplete-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  max-height: 320px;
  overflow-y: auto;
  z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.autocomplete-dropdown.open { display: block; }

.autocomplete-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--color-text);
  font-size: 0.85rem;
  transition: background 0.15s;
  border-bottom: 1px solid var(--color-border);
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover,
.autocomplete-item.highlighted {
  background: var(--color-surface-raised);
  color: var(--color-gold);
}

.autocomplete-item-name {
  font-weight: 500;
}

.autocomplete-item-name mark {
  background: transparent;
  color: var(--color-gold);
  font-weight: 700;
}

.autocomplete-item-level {
  font-size: 0.688rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.autocomplete-count {
  padding: 6px 14px;
  font-size: 0.688rem;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-raised);
}

/* --- Exit Game Button --- */
.exit-game-btn {
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.75rem;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.exit-game-btn:hover {
  border-color: #D94F4F;
  color: #D94F4F;
}
/* Resume button row (two equal buttons on start screen) */
.resume-button-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  animation: fadeSlideIn 0.4s ease;
}
.resume-button-row .btn {
  font-size: 1rem;
  padding: 14px 32px;
  min-width: 160px;
  justify-content: center;
}
@keyframes resumePulse {
  0%, 100% { box-shadow: 0 0 0 rgba(212,169,84,0); }
  50% { box-shadow: 0 0 14px rgba(212,169,84,0.45); }
}
@media (max-width: 480px) {
  .resume-button-row { flex-direction: column; gap: 10px; }
  .resume-button-row .btn { min-width: 220px; }
}

/* --- Exit Confirmation Modal --- */
.exit-modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(14, 8, 6, 0.92);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}
.exit-modal[hidden] { display: none; }
.exit-modal-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl) var(--space-lg);
  max-width: 400px;
  width: 100%;
  text-align: center;
}
.exit-modal-card h3 {
  color: var(--color-gold);
  margin-bottom: var(--space-sm);
}
.exit-modal-card p {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  margin-bottom: var(--space-lg);
  line-height: 1.5;
}
.exit-modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Resume Banner (on start screen) --- */
.resume-banner {
  background: rgba(212,169,84,0.08);
  border: 1px solid var(--color-gold-dark);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  text-align: center;
  margin-bottom: var(--space-lg);
  animation: fadeSlideIn 0.4s ease;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.resume-banner h3 {
  color: var(--color-gold);
  font-size: 1rem;
  margin-bottom: var(--space-xs);
  font-family: var(--font-heading);
}
.resume-banner p {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  margin-bottom: var(--space-md);
  line-height: 1.4;
}
.resume-banner-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .site-nav { display: none; }
  .site-nav.open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--space-md) var(--space-lg);
  }
  .nav-toggle { display: block; }

  .hero h1 { font-size: 1.75rem; }
  .emotion-name { font-size: 1.75rem; }
  .emotion-grid { grid-template-columns: 1fr; }
  .container { padding: 0 var(--space-md); }

  .header-search-mobile {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 220px;
  }
}

/* =============================================
   QUICK LOG — FAB & Overlay
   ============================================= */

/* --- Floating Action Button --- */
.journal-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--color-fire) 0%, var(--color-gold) 100%);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 9998;
  box-shadow: 0 4px 16px rgba(200, 56, 24, 0.4), 0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}
.journal-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(200, 56, 24, 0.5), 0 3px 10px rgba(0,0,0,0.4);
}
.journal-fab:active {
  transform: scale(0.95);
}
.journal-fab.active {
  transform: rotate(45deg);
  background: var(--color-surface-raised);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.journal-fab-icon {
  line-height: 1;
  pointer-events: none;
}

/* --- Overlay Backdrop --- */
.journal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.journal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* --- Panel (slides up from bottom) --- */
.journal-panel {
  background: var(--color-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 20px 24px 28px;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  border: 1px solid var(--color-border);
  border-bottom: none;
}
.journal-overlay.open .journal-panel {
  transform: translateY(0);
}

/* --- Header --- */
.journal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.journal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  color: var(--color-gold);
  margin: 0;
}
.journal-close {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.75rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s;
}
.journal-close:hover {
  color: var(--color-text);
}

/* --- Step Dots --- */
.journal-steps {
  margin-bottom: 16px;
}
.journal-step-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
}
.step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-border);
  transition: all 0.3s;
}
.step-dot.active {
  background: var(--color-gold);
  color: var(--color-bg);
  border-color: var(--color-gold);
}
.step-dot.completed {
  background: var(--color-gold-dark);
  color: var(--color-bg);
  border-color: var(--color-gold-dark);
}
.step-line {
  width: 40px;
  height: 2px;
  background: var(--color-border);
}

/* --- Prompt Text --- */
.journal-prompt {
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  text-align: center;
  margin-bottom: 16px;
}

/* --- Phase Buttons (Step 1) --- */
.journal-phases {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.journal-phase-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border-radius: var(--radius-md);
  border: 2px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text);
  cursor: pointer;
  transition: all 0.25s;
  font-family: var(--font-body);
}
.journal-phase-btn:hover {
  border-color: var(--phase-color);
  background: rgba(255,255,255,0.05);
  transform: translateY(-2px);
}
.journal-phase-btn.selected {
  border-color: var(--phase-color);
  box-shadow: 0 0 12px color-mix(in srgb, var(--phase-color) 40%, transparent);
}
.phase-icon {
  font-size: 1.5rem;
  line-height: 1;
}
.phase-label {
  font-size: 0.825rem;
  font-weight: 600;
}

/* --- Emotion Chips (Step 2) --- */
.journal-emotion-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}
.journal-emotion-chip {
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-secondary);
  font-family: var(--font-body);
  font-size: 0.813rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.journal-emotion-chip:hover {
  border-color: var(--color-gold);
  color: var(--color-text);
  transform: translateY(-1px);
}
.journal-emotion-chip.selected {
  background: var(--color-gold);
  color: var(--color-bg);
  border-color: var(--color-gold);
  font-weight: 600;
}

/* --- Custom Input --- */
.journal-custom-emotion {
  margin-bottom: 14px;
}
.journal-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: border-color 0.2s;
}
.journal-input:focus {
  outline: none;
  border-color: var(--color-gold);
}
.journal-input::placeholder {
  color: var(--color-text-muted);
}
.journal-textarea {
  resize: vertical;
  min-height: 48px;
}

/* --- Labels --- */
.journal-label {
  display: block;
  font-size: 0.813rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  margin-top: 12px;
}
.optional-tag {
  font-weight: 400;
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

/* --- Intensity (Step 3) --- */
.journal-intensity {
  margin-bottom: 16px;
}
.intensity-track {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 6px;
}
.intensity-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.875rem;
}
.intensity-dot:hover {
  border-color: var(--color-gold);
  transform: scale(1.1);
}
.intensity-dot.active {
  background: var(--color-fire);
  border-color: var(--color-fire);
  color: #fff;
}
.intensity-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  padding: 0 8px;
}

/* --- Optional Fields --- */
.journal-optional {
  margin-bottom: 16px;
}

/* --- Nav Row (Back / Next / Save) --- */
.journal-nav-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}
.journal-back-btn {
  padding: 10px 20px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.813rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.journal-back-btn:hover {
  border-color: var(--color-text-muted);
  color: var(--color-text);
}
.journal-next-btn,
.journal-save-btn {
  padding: 10px 24px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-gold);
  color: var(--color-bg);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}
.journal-next-btn:hover:not(:disabled),
.journal-save-btn:hover {
  background: var(--color-gold-light);
  transform: translateY(-1px);
}
.journal-next-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.journal-skip-btn {
  display: block;
  margin: 0 auto;
  padding: 8px 16px;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: 0.813rem;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s;
}
.journal-skip-btn:hover {
  color: var(--color-text);
}

/* --- Success Screen --- */
.journal-success {
  text-align: center;
  padding: 12px 0;
}
.journal-success .success-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-risk-low);
  color: #fff;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}
.journal-success h4 {
  font-family: var(--font-heading);
  color: var(--color-gold);
  font-size: 1.125rem;
  margin-bottom: 8px;
}
.success-summary {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}
.success-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 8px;
}

/* --- Voice Input --- */
.voice-input-wrap {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}
.voice-input-wrap .journal-input {
  flex: 1;
}
.voice-mic-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-surface-raised);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s;
  flex-shrink: 0;
  margin-top: 1px;
}
.voice-mic-btn:hover {
  border-color: var(--color-gold);
  color: var(--color-gold);
  background: rgba(212, 168, 84, 0.1);
}
.voice-mic-btn.recording {
  background: var(--color-fire);
  border-color: var(--color-fire);
  color: #fff;
  animation: pulse-mic 1.2s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(200, 56, 24, 0.4); }
  50% { box-shadow: 0 0 0 8px rgba(200, 56, 24, 0); }
}
.voice-mic-btn svg {
  pointer-events: none;
}

/* --- Mute detection hint --- */
.voice-mute-hint {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  background: var(--color-surface-raised);
  color: var(--color-fire);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-fire);
  white-space: nowrap;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  animation: muteHintFadeIn 0.3s ease;
}
.voice-mute-hint::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 12px;
  width: 10px;
  height: 10px;
  background: var(--color-surface-raised);
  border-right: 1px solid var(--color-fire);
  border-bottom: 1px solid var(--color-fire);
  transform: rotate(45deg);
}
@keyframes muteHintFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- FAB positioning on mobile --- */
@media (max-width: 600px) {
  .journal-fab {
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
    font-size: 1.25rem;
  }
  .journal-panel {
    padding: 16px 18px 24px;
    max-height: 90vh;
  }
  .journal-phases {
    gap: 8px;
  }
  .journal-phase-btn {
    padding: 12px 8px;
  }
  .intensity-dot {
    width: 36px;
    height: 36px;
  }
}
