/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-elevated: #222240;
  --text: #e8e8f0;
  --text-muted: #9898b0;
  --text-dim: #6868a0;
  --accent: #FF6B35;
  --accent-warm: #F7C948;
  --accent-cool: #4ECDC4;
  --border: #2a2a4a;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: 0.2s ease;
}

html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

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

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

.skip-link {
  position: absolute; top: -100px; left: 0;
  background: var(--accent); color: #fff;
  padding: 8px 16px; z-index: 1000; font-weight: 600;
}
.skip-link:focus { top: 0; }

/* ===== HEADER ===== */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(15,15,26,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  height: 60px;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none;
}
.logo:hover, .logo:focus { text-decoration: none; color: var(--text); }
.logo-text { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; }

.main-nav { display: flex; gap: 24px; }
.main-nav a {
  color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
  padding: 4px 0; border-bottom: 2px solid transparent;
  transition: var(--transition);
}
.main-nav a:hover, .main-nav a:focus {
  color: var(--text); border-bottom-color: var(--accent); text-decoration: none;
}

.nav-toggle {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.nav-toggle span {
  display: block; width: 22px; height: 2px;
  background: var(--text); border-radius: 2px;
}

/* ===== 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: 2px solid transparent; transition: var(--transition);
  font-family: var(--font); line-height: 1.4;
}
.btn-primary {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.btn-primary:hover, .btn-primary:focus {
  background: #e55a2b; border-color: #e55a2b; color: #fff; text-decoration: none;
}
.btn-ghost {
  background: transparent; color: var(--text); border-color: var(--border);
}
.btn-ghost:hover, .btn-ghost:focus {
  border-color: var(--accent); color: var(--accent); text-decoration: none;
}
.btn-small { padding: 6px 14px; font-size: 0.82rem; }
.btn-large { padding: 14px 28px; font-size: 1rem; }
.btn-add { background: var(--accent-warm); color: #1a1a2e; border-color: var(--accent-warm); }
.btn-add:hover { background: #e0b83e; border-color: #e0b83e; color: #1a1a2e; }
.btn-danger { background: transparent; color: #ff6b6b; border-color: #ff6b6b; }
.btn-danger:hover { background: #ff6b6b; color: #fff; }

/* ===== HERO ===== */
.hero { padding: 80px 0 60px; }
.hero .container { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; align-items: center; }
.hero-tag {
  display: inline-block; background: rgba(255,107,53,0.15);
  color: var(--accent); padding: 4px 12px; border-radius: 20px;
  font-size: 0.82rem; font-weight: 600; margin-bottom: 16px;
}
.hero h1 { font-size: 2.6rem; line-height: 1.15; font-weight: 800; margin-bottom: 16px; }
.hero-sub { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 28px; max-width: 480px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-visual { display: flex; justify-content: center; }
.hero-wave { width: 100%; max-width: 400px; }

/* ===== SECTIONS ===== */
section { padding: 60px 0; }
.section-header { margin-bottom: 32px; }
.section-header h2 { font-size: 1.8rem; font-weight: 700; margin-bottom: 8px; }
.section-header p { color: var(--text-muted); font-size: 1rem; }

/* ===== TEMPLATE BAR ===== */
.template-bar {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 28px;
}
.template-btn {
  padding: 8px 18px; border-radius: 20px;
  background: var(--bg-card); color: var(--text-muted);
  border: 1px solid var(--border); cursor: pointer;
  font-size: 0.85rem; font-weight: 500; font-family: var(--font);
  transition: var(--transition);
}
.template-btn:hover, .template-btn:focus {
  border-color: var(--accent); color: var(--text);
}
.template-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* ===== BUILDER LAYOUT ===== */
.builder-layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 28px;
}
.timeline-panel, .curve-panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.panel-header h3, .curve-panel h3 { font-size: 1.1rem; font-weight: 600; }

/* ===== PHASES LIST ===== */
.phases-list { display: flex; flex-direction: column; gap: 12px; }
.phase-item {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px;
  transition: var(--transition);
}
.phase-item:hover { border-color: var(--accent); }
.phase-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px;
}
.phase-name {
  background: transparent; border: none; color: var(--text);
  font-size: 1rem; font-weight: 600; font-family: var(--font);
  width: 60%; outline: none; border-bottom: 1px solid transparent;
  padding: 2px 0; transition: var(--transition);
}
.phase-name:focus { border-bottom-color: var(--accent); }
.phase-remove {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 1.2rem; padding: 2px 6px;
  border-radius: 4px; transition: var(--transition);
}
.phase-remove:hover { color: #ff6b6b; background: rgba(255,107,107,0.1); }
.phase-controls {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.phase-control label {
  display: block; font-size: 0.78rem; color: var(--text-dim);
  margin-bottom: 4px; font-weight: 500;
}
.phase-control input[type="number"],
.phase-control input[type="text"] {
  width: 100%; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-family: var(--font);
  font-size: 0.9rem; outline: none; transition: var(--transition);
}
.phase-control input:focus { border-color: var(--accent); }
.energy-slider {
  width: 100%; accent-color: var(--accent); height: 6px;
}
.energy-value {
  display: inline-block; font-size: 0.85rem; font-weight: 600;
  color: var(--accent); margin-left: 8px;
}

/* ===== BUILDER META ===== */
.builder-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border);
  flex-wrap: wrap; gap: 12px;
}
.total-time { font-size: 0.95rem; color: var(--text-muted); }
.total-time strong { color: var(--accent-warm); }
.party-name-field { display: flex; align-items: center; gap: 8px; }
.party-name-field label { font-size: 0.85rem; color: var(--text-dim); }
.party-name-field input {
  padding: 6px 10px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-family: var(--font);
  font-size: 0.9rem; outline: none; width: 200px;
}
.party-name-field input:focus { border-color: var(--accent); }

/* ===== ENERGY CURVE ===== */
.energy-curve-svg { width: 100%; margin-top: 8px; }
.curve-note {
  font-size: 0.8rem; color: var(--text-dim); margin-top: 8px;
  text-align: center;
}

/* ===== GENERATE BAR ===== */
.generate-bar {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
}

/* ===== BLUEPRINT ===== */
.blueprint-section { background: var(--bg-card); }
.blueprint-output { min-height: 200px; }
.empty-state {
  text-align: center; padding: 48px 20px; color: var(--text-dim);
}
.empty-state svg { margin-bottom: 16px; }
.empty-state h3 { font-size: 1.2rem; margin-bottom: 8px; color: var(--text-muted); }

.blueprint-content { padding: 8px 0; }
.blueprint-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 12px;
}
.blueprint-header h3 { font-size: 1.4rem; font-weight: 700; }
.blueprint-header .bp-meta { color: var(--text-dim); font-size: 0.85rem; }

.bp-phase {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 20px; margin-bottom: 16px;
}
.bp-phase-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 12px; flex-wrap: wrap; gap: 8px;
}
.bp-phase-name { font-size: 1.1rem; font-weight: 700; }
.bp-phase-meta {
  display: flex; gap: 16px; font-size: 0.82rem; color: var(--text-dim);
}
.bp-phase-meta span { display: flex; align-items: center; gap: 4px; }
.energy-badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 0.78rem; font-weight: 600;
}
.energy-1 { background: rgba(78,205,196,0.15); color: #4ECDC4; }
.energy-2 { background: rgba(78,205,196,0.1); color: #7EDDD6; }
.energy-3 { background: rgba(247,201,72,0.15); color: #F7C948; }
.energy-4 { background: rgba(255,107,53,0.15); color: #FF6B35; }
.energy-5 { background: rgba(255,107,53,0.25); color: #FF4444; }

.bp-details { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 12px; }
.bp-detail h4 { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.bp-detail p { font-size: 0.9rem; color: var(--text); }
.bp-transition {
  background: rgba(247,201,72,0.08); border-left: 3px solid var(--accent-warm);
  padding: 10px 14px; border-radius: 0 6px 6px 0;
  font-size: 0.88rem; color: var(--text-muted); margin-top: 8px;
}
.bp-transition strong { color: var(--accent-warm); }

.blueprint-actions {
  display: flex; gap: 10px; justify-content: center; margin-top: 24px;
  flex-wrap: wrap;
}

/* ===== ARCHIVE ===== */
.archive-list { display: grid; gap: 12px; }
.empty-archive { color: var(--text-dim); text-align: center; padding: 32px; }
.archive-item {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 16px 20px;
  flex-wrap: wrap; gap: 12px;
}
.archive-info h4 { font-size: 1rem; font-weight: 600; margin-bottom: 2px; }
.archive-info p { font-size: 0.82rem; color: var(--text-dim); }
.archive-actions { display: flex; gap: 8px; }

/* ===== GUIDE ===== */
.guide-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.guide-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.guide-card h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; color: var(--accent); }
.guide-card p, .guide-card li { font-size: 0.92rem; color: var(--text-muted); line-height: 1.7; }
.guide-card ul { padding-left: 20px; }
.guide-card li { margin-bottom: 8px; }
.guide-card dl { display: grid; gap: 12px; }
.guide-card dt { font-weight: 600; color: var(--text); font-size: 0.92rem; }
.guide-card dd { font-size: 0.88rem; color: var(--text-muted); margin-top: 2px; }

/* ===== FOOTER ===== */
.site-footer {
  border-top: 1px solid var(--border); padding: 40px 0 20px;
  margin-top: 40px;
}
.footer-top {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 24px;
  margin-bottom: 24px;
}
.footer-brand .logo-text { font-size: 1.1rem; font-weight: 700; }
.footer-brand p { font-size: 0.85rem; color: var(--text-dim); margin-top: 4px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; align-items: start; }
.footer-links a { font-size: 0.85rem; color: var(--text-muted); }
.footer-links a:hover { color: var(--text); }
.footer-ecosystem { text-align: right; }
.ecosink-link {
  font-size: 0.82rem; color: var(--text-dim);
  padding: 4px 10px; border: 1px solid var(--border);
  border-radius: 6px; display: inline-block;
}
.ecosink-link:hover { color: var(--text); border-color: var(--text-dim); text-decoration: none; }
.footer-bottom { text-align: center; font-size: 0.8rem; color: var(--text-dim); }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text); padding: 12px 20px; border-radius: var(--radius-sm);
  font-size: 0.88rem; z-index: 999;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== PRINT ===== */
@media print {
  .site-header, .site-footer, .builder-section, .archive-section, .guide-section,
  .hero-actions, .template-bar, .generate-bar, .blueprint-actions, .nav-toggle { display: none !important; }
  body { background: #fff; color: #000; }
  .blueprint-section { background: #fff; }
  .bp-phase { border: 1px solid #ccc; break-inside: avoid; }
  .bp-phase-name { color: #000; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .hero .container { grid-template-columns: 1fr; text-align: center; }
  .hero-sub { margin: 0 auto 28px; }
  .hero-actions { justify-content: center; }
  .hero-visual { order: -1; }
  .hero-wave { max-width: 300px; }
  .builder-layout { grid-template-columns: 1fr; }
  .guide-grid { grid-template-columns: 1fr; }
  .footer-top { grid-template-columns: 1fr; text-align: center; }
  .footer-ecosystem { text-align: center; }
  .bp-details { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .main-nav { display: none; }
  .main-nav.open {
    display: flex; flex-direction: column; position: absolute;
    top: 60px; left: 0; right: 0; background: var(--bg-card);
    border-bottom: 1px solid var(--border); padding: 16px 20px; gap: 12px;
  }
  .nav-toggle { display: flex; }
  .hero h1 { font-size: 1.8rem; }
  .hero { padding: 48px 0 36px; }
  section { padding: 40px 0; }
  .template-bar { gap: 6px; }
  .template-btn { padding: 6px 12px; font-size: 0.78rem; }
  .phase-controls { grid-template-columns: 1fr; }
  .builder-meta { flex-direction: column; align-items: flex-start; }
  .party-name-field { flex-direction: column; align-items: flex-start; width: 100%; }
  .party-name-field input { width: 100%; }
  .archive-item { flex-direction: column; align-items: flex-start; }
}

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }


/* 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;
}
