/* ===== CSS Custom Properties ===== */
:root {
  --color-bg: #0f0f12;
  --color-surface: #1a1a20;
  --color-surface-hover: #24242d;
  --color-border: #2e2e3a;
  --color-text: #e4e4ec;
  --color-text-muted: #8b8b9e;
  --color-accent: #7c5ce7;
  --color-accent-glow: rgba(124, 92, 231, 0.35);
  --color-positive: #2dd4bf;
  --color-negative: #f87171;
  --color-edge: #fbbf24;
  --color-code-bg: #16161d;
  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', Consolas, monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --transition: 0.2s ease;
}

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

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

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

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ===== Typography ===== */
h1, h2, h3 {
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

h1 {
  font-size: 2.2rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

h3 {
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

p {
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

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

a:hover {
  color: #a78bfa;
}

strong {
  color: var(--color-text);
  font-weight: 600;
}

/* ===== Header ===== */
.site-header {
  border-bottom: 1px solid var(--color-border);
  background-color: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
  background-color: rgba(26, 26, 32, 0.85);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-text);
  font-weight: 700;
  font-size: 1.15rem;
}

.logo svg {
  color: var(--color-accent);
}

.main-nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

.main-nav a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--color-text-muted);
  transition: color var(--transition);
}

.main-nav a:hover {
  color: var(--color-text);
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 3rem 0 1.5rem;
}

.hero-sub {
  font-size: 1.15rem;
  max-width: 600px;
  margin: 0.5rem auto 0;
  color: var(--color-text-muted);
}

/* ===== Tool Panel ===== */
.tool-panel {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.input-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.regex-input-wrapper {
  display: flex;
  align-items: center;
  background-color: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 0.75rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.regex-input-wrapper:focus-within {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-glow);
}

.regex-delimiter {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--color-accent);
  user-select: none;
}

#regex-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 0.85rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--color-text);
}

#regex-input::placeholder {
  color: #4a4a5e;
}

.flags-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.flags-label {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.flag-check {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--color-text-muted);
  cursor: pointer;
  user-select: none;
}

.flag-check input {
  accent-color: var(--color-accent);
  width: 16px;
  height: 16px;
}

.btn-primary {
  align-self: flex-start;
  background-color: var(--color-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1.75rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition), box-shadow var(--transition);
  margin-top: 0.5rem;
}

.btn-primary:hover {
  background-color: #6d4edb;
  box-shadow: 0 0 18px var(--color-accent-glow);
}

.btn-primary:active {
  transform: scale(0.98);
}

.error-message {
  color: var(--color-negative);
  font-size: 0.9rem;
  margin-top: 0.75rem;
  min-height: 1.2em;
}

/* ===== Results Panel ===== */
.results-panel {
  margin-bottom: 2.5rem;
}

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
  background-color: var(--color-surface);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
}

.empty-state svg {
  margin-bottom: 1rem;
  color: var(--color-border);
}

.result-category {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.category-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-weight: 700;
  font-size: 1rem;
}

.category-header .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-positive { background-color: var(--color-positive); }
.dot-negative { background-color: var(--color-negative); }
.dot-edge { background-color: var(--color-edge); }

.test-item {
  background-color: var(--color-code-bg);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 0.65rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  word-break: break-all;
}

.test-item .string {
  color: var(--color-text);
  font-weight: 500;
}

.test-item .explanation {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 0.3rem;
}

/* ===== Explainer & How It Works ===== */
.explainer,
.how-it-works {
  margin-bottom: 2.5rem;
}

.explainer-content p {
  max-width: 720px;
}

.steps {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.step-number {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  background-color: var(--color-accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
}

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

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.footer-inner nav ul {
  list-style: none;
  display: flex;
  gap: 1.25rem;
}

.footer-inner a {
  color: var(--color-text-muted);
}

.footer-inner a:hover {
  color: var(--color-text);
}

/* ===== Visually Hidden ===== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  h1 {
    font-size: 1.7rem;
  }

  .results-grid {
    grid-template-columns: 1fr;
  }

  .tool-panel {
    padding: 1.25rem;
  }

  .header-inner {
    height: 54px;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }

  .flags-row {
    gap: 0.6rem;
  }

  .btn-primary {
    width: 100%;
    text-align: center;
  }
}



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