/* Heatwave Sleep Survival Guide — Styles */
:root {
  --bg: #0f1221;
  --bg-surface: #161a2e;
  --bg-card: #1c2140;
  --bg-card-hover: #232a50;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #7dd3fc;
  --accent-dim: #38bdf8;
  --accent-warm: #fbbf24;
  --danger: #f87171;
  --success: #4ade80;
  --border: #2a3055;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --max-width: 1120px;
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; height: auto; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(15, 18, 33, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }
.logo svg { color: var(--accent); flex-shrink: 0; }

.main-nav {
  display: flex;
  gap: 20px;
}
.main-nav a {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}
.main-nav a:hover { color: var(--accent); text-decoration: none; }

/* Hero */
.hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 80px 24px 64px;
}

.hero-label {
  display: inline-block;
  background: rgba(125, 211, 252, 0.12);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  margin-bottom: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.hero h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  line-height: 1.2;
  font-weight: 800;
  max-width: 640px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 520px;
  margin-bottom: 28px;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.hero-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  font-family: var(--font);
  text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--accent);
  color: #0f1221;
}
.btn-primary:hover { background: var(--accent-dim); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

/* Sections */
section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 72px;
}

.section-header {
  margin-bottom: 32px;
}
.section-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.section-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Generator */
.generator-section { padding-top: 16px; }

.generator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.generator-controls {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.control-group {
  border: none;
  padding: 0;
}
.control-group legend {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 10px;
  color: var(--text);
}

.radio-cards, .checkbox-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.radio-card, .checkbox-card {
  cursor: pointer;
  position: relative;
}
.radio-card input, .checkbox-card input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.radio-card-body, .checkbox-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  height: 100%;
}
.radio-card-body strong, .checkbox-card-body strong {
  font-size: 0.85rem;
  color: var(--text);
}
.radio-card-body small, .checkbox-card-body small {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.radio-card input:checked + .radio-card-body,
.checkbox-card input:checked + .checkbox-card-body {
  border-color: var(--accent);
  background: rgba(125, 211, 252, 0.08);
}
.radio-card input:focus-visible + .radio-card-body,
.checkbox-card input:focus-visible + .checkbox-card-body {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Generator Output */
.generator-output {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: sticky;
  top: 72px;
  max-height: calc(100vh - 88px);
  overflow-y: auto;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.output-header h3 {
  font-size: 1rem;
  font-weight: 600;
}
.output-actions {
  display: flex;
  gap: 8px;
}

.protocol-content {
  font-size: 0.9rem;
}
.protocol-placeholder {
  color: var(--text-dim);
  font-style: italic;
}

.protocol-step {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.protocol-step:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.protocol-step h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.protocol-step h4 .step-time {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 400;
}
.protocol-step p {
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}
.protocol-step ul {
  margin-top: 6px;
  padding-left: 18px;
}
.protocol-step li {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 2px;
}

.protocol-warning {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--accent-warm);
}

/* Science Grid */
.science-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.science-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.science-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--accent);
}
.science-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Mistakes */
.mistakes-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mistake-item {
  display: flex;
  gap: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.mistake-icon {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(248, 113, 113, 0.15);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.mistake-item h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.mistake-item p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* History Grid */
.history-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.history-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.history-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--accent-warm);
}
.history-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Positioning */
.positioning-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 32px;
  align-items: start;
}

.position-diagram {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.position-tips ol {
  padding-left: 20px;
}
.position-tips li {
  margin-bottom: 12px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}
.position-tips li strong { color: var(--text); }

/* Cheat Sheet */
.cheatsheet-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.cheatsheet-preview {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.cs-card {
  background: #fff;
  color: #1a1a2e;
  border-radius: var(--radius-sm);
  padding: 28px;
}
.cs-card h3 {
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 20px;
  color: #0f1221;
}
.cs-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.cs-col h4 {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e40af;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cs-col ul {
  padding-left: 18px;
}
.cs-col li {
  font-size: 0.82rem;
  margin-bottom: 4px;
  color: #334155;
  line-height: 1.45;
}
.cs-footer {
  text-align: center;
  font-size: 0.7rem;
  color: #94a3b8;
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

/* Emergency */
.emergency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.emergency-card {
  border-radius: var(--radius);
  padding: 20px;
}
.emergency-moderate {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
}
.emergency-severe {
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
}
.emergency-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
}
.emergency-moderate h3 { color: var(--accent-warm); }
.emergency-severe h3 { color: var(--danger); }
.emergency-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 40px 24px;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.footer-about p {
  font-size: 0.85rem;
  color: var(--text-dim);
  max-width: 600px;
  line-height: 1.55;
}

.footer-links {
  display: flex;
  gap: 20px;
}
.footer-links a {
  font-size: 0.85rem;
  color: var(--text-muted);
}
.footer-links a:hover { color: var(--accent); }

.footer-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* Print styles */
@media print {
  .site-header, .site-footer, .hero-actions, .hero-meta,
  .generator-controls, .cheatsheet-actions, .output-actions,
  .emergency-section { display: none !important; }
  body { background: #fff; color: #000; }
  .cheatsheet-preview { border: none; padding: 0; }
  .cs-card { box-shadow: none; }
}

/* Responsive */
@media (max-width: 900px) {
  .generator-layout { grid-template-columns: 1fr; }
  .generator-output { position: static; max-height: none; }
  .science-grid { grid-template-columns: repeat(2, 1fr); }
  .history-grid { grid-template-columns: repeat(2, 1fr); }
  .positioning-layout { grid-template-columns: 1fr; }
  .position-diagram { max-width: 300px; margin: 0 auto; }
}

@media (max-width: 640px) {
  .header-inner { padding: 0 16px; }
  .main-nav { gap: 12px; }
  .main-nav a { font-size: 0.78rem; }
  .hero { padding: 48px 16px 40px; }
  section { padding: 0 16px 56px; }
  .radio-cards, .checkbox-cards { grid-template-columns: 1fr; }
  .science-grid { grid-template-columns: 1fr; }
  .history-grid { grid-template-columns: 1fr; }
  .emergency-grid { grid-template-columns: 1fr; }
  .cs-columns { grid-template-columns: 1fr; }
  .hero-actions { flex-direction: column; }
  .hero-actions .btn { width: 100%; text-align: center; }
}

/* Scrollbar */
.generator-output::-webkit-scrollbar { width: 6px; }
.generator-output::-webkit-scrollbar-track { background: transparent; }
.generator-output::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Focus visible */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
