/* Theme Variables */
:root {
  --bg-dark: #0B0F19;
  --bg-card: #151C2C;
  --bg-card-hover: #1E283D;
  --bg-input: #101624;
  --border-color: #2A364F;
  --accent-red: #FF3B30;
  --accent-red-glow: rgba(255, 59, 48, 0.4);
  --accent-cyan: #00E5FF;
  --accent-gold: #FFD700;
  --text-main: #F1F5F9;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  --font-family: 'Prompt', 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --border-radius: 16px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-family);
  line-height: 1.7;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ECG Header Line Canvas */
#ecg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 65px;
  z-index: 1000;
  pointer-events: none;
  background: rgba(11, 15, 25, 0.95);
  border-bottom: 1px solid rgba(255, 59, 48, 0.2);
  backdrop-filter: blur(8px);
}

/* Main Container */
.app-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 85px 20px 60px 20px;
}

/* Header & Banner */
header.hero {
  text-align: center;
  padding: 40px 20px;
  background: radial-gradient(circle at center, rgba(255, 59, 48, 0.15) 0%, rgba(11, 15, 25, 0) 70%);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  margin-bottom: 40px;
  position: relative;
  overflow: hidden;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 59, 48, 0.15);
  border: 1px solid rgba(255, 59, 48, 0.4);
  color: var(--accent-red);
  padding: 6px 16px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 20px;
  animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
  0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(255, 59, 48, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

.hero-title {
  font-size: 2.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, #FFFFFF 0%, #FF6B6B 50%, var(--accent-red) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 15px;
  letter-spacing: -0.5px;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 750px;
  margin: 0 auto 25px auto;
  font-weight: 300;
}

.hero-author-box {
  display: inline-flex;
  align-items: center;
  gap: 15px;
  background: var(--bg-card);
  padding: 12px 24px;
  border-radius: 50px;
  border: 1px solid var(--border-color);
  font-size: 0.95rem;
}

.author-avatar {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--accent-red), var(--accent-gold));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  color: #000;
}

/* Audio Control Bar */
.audio-control-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 15px 24px;
  border-radius: var(--border-radius);
  margin-bottom: 35px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card-hover);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--transition);
}

.btn:hover {
  background: var(--border-color);
  transform: translateY(-2px);
}

.btn-primary {
  background: var(--accent-red);
  color: white;
  border-color: var(--accent-red);
}

.btn-primary:hover {
  background: #E03126;
  box-shadow: 0 4px 15px var(--accent-red-glow);
}

.btn-cyan {
  background: rgba(0, 229, 255, 0.15);
  color: var(--accent-cyan);
  border-color: rgba(0, 229, 255, 0.3);
}

.btn-cyan:hover {
  background: rgba(0, 229, 255, 0.25);
  box-shadow: 0 4px 15px rgba(0, 229, 255, 0.2);
}

.btn-active {
  background: var(--accent-red) !important;
  color: white !important;
  border-color: var(--accent-red) !important;
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 10px;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 35px;
  overflow-x: auto;
  padding-bottom: 5px;
}

.tab-btn {
  padding: 12px 24px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}

.tab-btn.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
}

.tab-btn:hover:not(.active) {
  color: var(--text-main);
}

/* Tab Content Areas */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Story Section & Timeline */
.story-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
}

.story-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 30px;
  position: relative;
  transition: var(--transition);
}

.story-card:hover {
  border-color: rgba(0, 229, 255, 0.4);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.story-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-color);
}

.chapter-number {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-cyan);
  letter-spacing: 1px;
}

.chapter-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 4px;
}

.chapter-time {
  background: rgba(255, 255, 255, 0.05);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.story-text {
  font-size: 1.1rem;
  line-height: 1.95;
  color: #E2E8F0;
  white-space: pre-line;
}

.highlight-quote {
  background: rgba(255, 59, 48, 0.1);
  border-left: 4px solid var(--accent-red);
  padding: 18px 24px;
  margin: 20px 0;
  border-radius: 0 12px 12px 0;
  font-style: italic;
  font-size: 1.15rem;
  color: #FFF;
}

.highlight-gold {
  background: rgba(255, 215, 0, 0.1);
  border-left: 4px solid var(--accent-gold);
  padding: 18px 24px;
  margin: 20px 0;
  border-radius: 0 12px 12px 0;
  font-size: 1.1rem;
  color: #FFE600;
}

/* Symptom Visualizer (Anatomy Section) */
.anatomy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
}

@media (max-width: 850px) {
  .anatomy-grid {
    grid-template-columns: 1fr;
  }
}

.anatomy-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 30px;
}

.body-svg-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 380px;
  background: rgba(16, 22, 36, 0.6);
  border-radius: 12px;
  position: relative;
}

.body-hotspot {
  position: absolute;
  width: 28px;
  height: 28px;
  background: rgba(255, 59, 48, 0.4);
  border: 2px solid var(--accent-red);
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse-ring 2s infinite;
}

.body-hotspot:hover, .body-hotspot.active {
  background: var(--accent-red);
  transform: scale(1.3);
  box-shadow: 0 0 20px var(--accent-red);
}

@keyframes pulse-ring {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7); }
  70% { transform: scale(1.15); box-shadow: 0 0 0 10px rgba(255, 59, 48, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

.symptom-info-card {
  background: var(--bg-card-hover);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-top: 20px;
}

.symptom-tag {
  display: inline-block;
  background: var(--accent-red);
  color: white;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 12px;
}

/* 1669 Action Protocol Card */
.protocol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  margin-top: 30px;
}

.protocol-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 25px;
}

.protocol-card.do {
  border-top: 4px solid #10B981;
}

.protocol-card.dont {
  border-top: 4px solid var(--accent-red);
}

.protocol-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 15px;
}

.protocol-list {
  list-style: none;
}

.protocol-list li {
  position: relative;
  padding-left: 28px;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.protocol-list li::before {
  position: absolute;
  left: 0;
  top: 0;
  font-weight: bold;
}

.protocol-card.do li::before {
  content: '✓';
  color: #10B981;
}

.protocol-card.dont li::before {
  content: '✕';
  color: var(--accent-red);
}

/* Quote Builder & Share Section */
.quote-card-display {
  background: linear-gradient(135deg, #1A2338 0%, #0F172A 100%);
  border: 2px solid var(--accent-gold);
  border-radius: var(--border-radius);
  padding: 40px;
  text-align: center;
  position: relative;
  box-shadow: 0 15px 35px rgba(0,0,0,0.5);
  margin-bottom: 25px;
}

.quote-content {
  font-size: 1.4rem;
  font-weight: 600;
  line-height: 1.7;
  color: #FFF;
  margin-bottom: 20px;
}

.quote-author {
  font-size: 1rem;
  color: var(--accent-gold);
  font-weight: 500;
}

/* Modal Popup */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  max-width: 550px;
  width: 90%;
  padding: 30px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Floating Quick Dial Button */
.floating-emergency {
  position: fixed;
  bottom: 25px;
  right: 25px;
  background: var(--accent-red);
  color: white;
  border: none;
  border-radius: 50px;
  padding: 14px 28px;
  font-family: var(--font-family);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 10px 25px var(--accent-red-glow);
  cursor: pointer;
  z-index: 999;
  transition: var(--transition);
  animation: bounce-gentle 3s infinite;
}

.floating-emergency:hover {
  transform: scale(1.08);
  background: #E03126;
}

@keyframes bounce-gentle {
  0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-8px); }
  60% { transform: translateY(-4px); }
}

/* Footer */
footer {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 0.9rem;
  border-top: 1px solid var(--border-color);
  margin-top: 60px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .hero-title { font-size: 2.1rem; }
  .story-card { padding: 20px; }
  .story-text { font-size: 1rem; }
  .quote-content { font-size: 1.15rem; }
  .audio-control-bar { flex-direction: column; align-items: stretch; }
  .floating-emergency { bottom: 15px; right: 15px; padding: 12px 20px; font-size: 0.95rem; }
}
