:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #eef2ff;
  --text: #0f172a;
  --text-soft: #475569;
  --border: #dbe4ff;
  --accent: #4f46e5;
  --accent-soft: #e0e7ff;
  --accent-strong: #312e81;
  --success: #059669;
  --shadow: 0 18px 45px rgb(15 23 42 / 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans SC', 'PingFang SC', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgb(99 102 241 / 0.18), transparent 28%),
    linear-gradient(180deg, #f5f7ff 0%, var(--bg) 45%, #eef2ff 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

code {
  font-family: 'SFMono-Regular', 'Consolas', 'Liberation Mono', monospace;
}

#app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 20px 72px;
}

.hero-shell,
.panel,
.grid-shell,
.not-found-card {
  background: rgb(255 255 255 / 0.88);
  backdrop-filter: blur(12px);
  border: 1px solid rgb(255 255 255 / 0.7);
  box-shadow: var(--shadow);
}

.hero-topbar,
.section-heading,
.toolbar,
.rule-card-head,
.hero-actions,
.rule-actions,
.stats-grid,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero-shell {
  border-radius: var(--radius-xl);
  padding: 24px;
}

.hero-topbar {
  align-items: center;
  justify-content: space-between;
}

.hero-card {
  margin-top: 20px;
  padding: 28px;
  border-radius: var(--radius-xl);
  background: linear-gradient(135deg, rgb(79 70 229 / 0.08), rgb(139 92 246 / 0.08));
  border: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  max-width: 14ch;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.05;
}

h2 {
  font-size: 1.1rem;
  line-height: 1.5;
}

.subtitle,
.rule-description,
.catalog-footer,
.copy-status {
  color: var(--text-soft);
}

.subtitle {
  max-width: 64ch;
  margin-top: 14px;
  font-size: 1rem;
}

.primary-link,
.secondary-link,
.lang-button,
.chip-button,
.button-reset {
  border: 0;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
}

.primary-link {
  background: var(--accent);
  color: #fff;
}

.secondary-link,
.lang-button,
.chip-button {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.button-reset {
  padding: 0 18px;
}

.lang-toggle {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.92);
  border: 1px solid var(--border);
}

.lang-button {
  padding: 8px 14px;
}

.lang-button.active,
.chip-button.active {
  background: var(--accent-soft);
  border-color: rgb(99 102 241 / 0.25);
  color: var(--accent-strong);
}

.stats-grid {
  margin-top: 22px;
}

.stat-card {
  min-width: 120px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgb(255 255 255 / 0.84);
  border: 1px solid var(--border);
}

.stat-value {
  display: block;
  font-size: 1.6rem;
  font-weight: 700;
}

.stat-label {
  display: block;
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 0.92rem;
}

#filters,
#rule-grid {
  margin-top: 24px;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 24px;
}

.section-heading {
  align-items: center;
  justify-content: space-between;
}

.status-pill,
.file-pill,
.scope-global {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.9rem;
  font-weight: 600;
}

.toolbar {
  margin-top: 18px;
  flex-direction: column;
}

.search-input {
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #fff;
  font: inherit;
}

.chip-row {
  gap: 10px;
}

.chip-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
}

.copy-status {
  margin-top: 14px;
  color: var(--success);
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.rule-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100%;
  padding: 22px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 10px 24px rgb(15 23 42 / 0.05);
}

.rule-card-head {
  align-items: flex-start;
  justify-content: space-between;
}

.rule-card h3 {
  margin-top: 2px;
  font-size: 1.25rem;
  line-height: 1.3;
}

.rule-meta {
  display: grid;
  gap: 14px;
  margin: 0;
}

.rule-meta dt {
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 600;
}

.rule-meta dd {
  margin: 6px 0 0;
}

.scope-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scope-list code,
.rule-meta code {
  padding: 6px 10px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: var(--accent-strong);
  font-size: 0.85rem;
}

.rule-actions {
  margin-top: auto;
}

.catalog-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 0.95rem;
}

.empty-state {
  text-align: center;
}

.not-found {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.not-found-card {
  width: min(620px, 100%);
  padding: 36px;
  border-radius: var(--radius-xl);
  text-align: center;
}

@media (max-width: 720px) {
  #app {
    padding-inline: 16px;
  }

  .hero-shell,
  .panel,
  .not-found-card {
    padding: 18px;
  }

  .hero-card {
    padding: 22px;
  }

  .rule-card-head,
  .hero-topbar,
  .section-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-actions .primary-link,
  .hero-actions .secondary-link,
  .rule-actions .secondary-link,
  .rule-actions .button-reset {
    width: 100%;
  }
}
