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

:root {
  --storm-purple: #3a0ca3;
  --storm-purple-light: #5e3bb3;
  --bulldogs-blue: #0038a8;
  --bulldogs-blue-light: #1e5bc6;
  --red-accent: #e63946;
  --red-accent-light: #f4a261;
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-muted: #5a5a7a;
  --border: #dde1e7;
  --border-light: #eef0f4;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --radius: 10px;
  --radius-sm: 6px;
  --max-width: 1100px;
  --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

/* Header */
.site-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.6rem 1.2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
}
.logo-text { white-space: nowrap; }
.main-nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}
.main-nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.2s;
}
.main-nav a:hover,
.main-nav a[aria-current="page"] { color: var(--storm-purple); }

.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  flex-direction: column;
  gap: 5px;
}
.hamburger-line {
  display: block;
  width: 24px;
  height: 2.5px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 0.2s;
}

/* Main */
main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1.2rem 3rem;
  width: 100%;
}

/* Hero */
.hero-section {
  display: flex;
  gap: 2rem;
  align-items: center;
  justify-content: space-between;
  padding: 2rem 0 2.5rem;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 2rem;
}
.hero-content { max-width: 580px; }
.hero-content h1 {
  font-size: 2.2rem;
  line-height: 1.2;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 0.8rem;
}
.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.hero-note {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}
.hero-visual { flex-shrink: 0; }

/* Section titles */
.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 1.2rem;
  color: var(--text);
  padding-bottom: 0.5rem;
  border-bottom: 3px solid var(--red-accent);
  display: inline-block;
}
.section-intro {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  max-width: 700px;
}

/* Decoder Section */
.decoder-section { margin-bottom: 3rem; }
.decoder-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}
.decoder-controls {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.control-group { display: flex; flex-direction: column; gap: 0.35rem; }
.control-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.control-group select {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-sans);
}
.control-group select:focus {
  outline: 2px solid var(--storm-purple);
  outline-offset: 2px;
}
.view-toggle-group { flex-direction: row; align-items: center; gap: 0.8rem; }
.toggle-label { font-weight: 600; font-size: 0.9rem; }
.toggle-switch {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.toggle-option {
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  border: none;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}
.toggle-option.active {
  background: var(--storm-purple);
  color: #fff;
}
.toggle-option:focus-visible { outline: 2px solid var(--storm-purple); outline-offset: -2px; }
.primary-btn {
  padding: 0.75rem 1.5rem;
  background: var(--red-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.2s;
}
.primary-btn:hover { background: #c62828; }
.primary-btn:focus-visible { outline: 3px solid var(--storm-purple); outline-offset: 2px; }
.secondary-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: background 0.2s;
}
.secondary-btn:hover { background: var(--border-light); }

/* Result panel */
.decoder-result {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  min-height: 300px;
}
.result-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  height: 100%;
  min-height: 260px;
  gap: 0.6rem;
}
.empty-hint { font-size: 0.85rem; }

.result-active { display: none; }
.result-active.visible { display: block; }
.result-empty.hidden { display: none; }

.result-card { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.result-card h3 {
  font-size: 1.15rem;
  margin-bottom: 0.6rem;
  color: var(--storm-purple);
}
.result-card .rule-ref {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  display: block;
}
.result-card .rule-explanation {
  background: #f0f4ff;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
  border-left: 4px solid var(--storm-purple);
}
.result-card .advantage-box {
  background: #fff5f5;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
  border-left: 4px solid var(--red-accent);
}
.result-card .historical-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* History Section */
.history-section { margin-bottom: 3rem; }
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
}
.history-card {
  background: var(--bg-card);
  padding: 1.2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.history-card h3 { font-size: 1rem; margin-bottom: 0.8rem; }
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}
.bar {
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  padding-left: 0.6rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  min-width: 50px;
}
.storm-bar { background: var(--storm-purple); }
.bulldogs-bar { background: var(--bulldogs-blue); }
.card-note { font-size: 0.82rem; color: var(--text-muted); }

/* Supporting Content */
.supporting-content { margin-bottom: 3rem; }
.support-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}
.support-block h3 {
  font-size: 1.1rem;
  margin-bottom: 0.6rem;
  color: var(--text);
}
.support-block p {
  color: var(--text-muted);
  margin-bottom: 0.8rem;
  font-size: 0.95rem;
}
.mistakes-list {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.mistakes-list li {
  font-size: 0.9rem;
  color: var(--text-muted);
  padding-left: 1.2rem;
  position: relative;
}
.mistakes-list li::before {
  content: '✗';
  position: absolute;
  left: 0;
  color: var(--red-accent);
  font-weight: 700;
}

/* FAQ */
.faq-section { margin-bottom: 2rem; }
.faq-list { display: flex; flex-direction: column; gap: 0.6rem; }
.faq-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.faq-item summary {
  padding: 0.9rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+';
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--storm-purple);
  transition: transform 0.2s;
}
.faq-item[open] summary::after { content: '−'; }
.faq-item p {
  padding: 0 1.2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Footer */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.2rem;
  margin-top: auto;
}
.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.footer-tagline { font-size: 0.85rem; color: var(--text-muted); }
.footer-tagline a { color: var(--storm-purple); text-decoration: underline; }
.footer-nav {
  display: flex;
  gap: 1.5rem;
  justify-content: center;
  flex-wrap: wrap;
}
.footer-nav a { font-size: 0.85rem; color: var(--text-muted); text-decoration: none; }
.footer-nav a:hover { color: var(--storm-purple); text-decoration: underline; }
.footer-version { font-size: 0.75rem; color: var(--text-muted); }

/* About page */
.about-page { max-width: 700px; margin: 0 auto; }
.about-page h1 { font-size: 1.8rem; margin-bottom: 1rem; }
.about-page p { color: var(--text-muted); margin-bottom: 1rem; }

/* Responsive */
@media (max-width: 800px) {
  .decoder-layout { grid-template-columns: 1fr; }
  .hero-section { flex-direction: column; text-align: center; }
  .hero-content h1 { font-size: 1.7rem; }
  .hero-visual { display: none; }
  .main-nav { display: none; }
  .main-nav.open { display: flex; flex-direction: column; position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-card); border-bottom: 1px solid var(--border); padding: 1rem; gap: 0.8rem; box-shadow: var(--shadow-md); }
  .nav-toggle { display: flex; }
  .history-grid { grid-template-columns: 1fr 1fr; }
  .support-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .history-grid { grid-template-columns: 1fr; }
  .hero-content h1 { font-size: 1.4rem; }
  .section-title { font-size: 1.25rem; }
  .decoder-controls { padding: 1rem; }
  .toggle-switch { flex-direction: column; }
}



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