:root {
  --bg: #f3efe7;
  --panel: #fffbf4;
  --surface: #ffffff;
  --ink: #171513;
  --muted: #6a6258;
  --line: #ddd3c3;
  --accent: #0f766e;
  --accent-soft: #def3ef;
  --danger: #8b1e3f;
  --shadow: 0 10px 26px rgba(28, 26, 24, 0.08);
  font-family: "Avenir Next", "Segoe UI", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  line-height: 1.45;
  background:
    radial-gradient(circle at 12% 8%, rgba(15, 118, 110, 0.12), transparent 28%),
    radial-gradient(circle at 96% 14%, rgba(183, 137, 76, 0.09), transparent 24%),
    linear-gradient(180deg, #f7f1e7 0%, #f2eadf 100%);
  color: var(--ink);
}

.shell {
  min-height: 100vh;
  width: min(1680px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 300px 1fr;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 249, 239, 0.84);
  backdrop-filter: blur(16px);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.main {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.main > .hero,
.main > .content-grid,
.main > .panel {
  width: min(1280px, 100%);
  margin-inline: auto;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand h1,
.hero h2,
.panel h2,
.rule-card h3,
.rule-editor-head h3,
.rule-focus h3,
.engine-card h3,
.section-head h3 {
  margin: 0;
  font-family: "Iowan Old Style", Georgia, "Times New Roman", serif;
  letter-spacing: -0.03em;
}

.brand-copy,
.hero p,
.panel-note,
.rule-copy,
.rule-sub,
.audit-sub,
.empty-state,
.guide-card p,
.engine-summary,
.engine-issue p {
  color: var(--muted);
  margin: 0;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 10px;
  color: var(--muted);
}

.panel,
.hero {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: fade-up 220ms ease-out both;
}

.hero {
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(300px, 520px);
  gap: 14px;
  align-items: stretch;
}

.hero-intro {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
}

.hero-copy {
  max-width: 64ch;
}

.hero-flow {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6f2e9;
  color: #5d544a;
  font-size: 12px;
  letter-spacing: 0.05em;
  padding: 5px 10px;
  white-space: nowrap;
}

.hero-note {
  margin-top: 2px;
  font-size: 13px;
  color: var(--muted);
}

.audit-form {
  align-content: start;
}

.hero-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.content-grid {
  display: grid;
  gap: 14px;
}

.content-grid-home {
  grid-template-columns: minmax(0, 1fr) 320px;
  align-items: start;
}

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel {
  padding: 14px;
}

.panel-head,
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 10px;
}

.field span {
  color: var(--muted);
}

.field-compact {
  margin-bottom: 0;
}

.field-grow {
  margin-bottom: 0;
  height: 100%;
}

input,
select,
textarea,
button,
a {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
}

textarea {
  min-height: 340px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
}

.button {
  border: none;
  border-radius: 12px;
  padding: 9px 12px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

.button.primary {
  background: var(--accent);
  color: white;
}

.button.subtle {
  background: var(--accent-soft);
  color: #0c4a45;
}

.button.danger {
  background: #f5d8df;
  color: var(--danger);
}

.button-link {
  width: 100%;
}

.audit-form {
  display: grid;
  grid-template-columns: 1fr minmax(150px, 210px);
  gap: 10px;
}

.span-2 {
  grid-column: 1 / -1;
}

.audit-list,
.rule-list,
.findings-wrap,
.engine-list,
.guide-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.audit-list {
  max-height: calc(100vh - 350px);
  overflow: auto;
  padding-right: 4px;
}

.audit-card,
.rule-card,
.summary-grid div,
.proxy-box,
.finding,
.raw-box,
.metric-card,
.rule-focus,
.rule-editor-shell,
.guide-card,
.engine-card,
.engine-issue {
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  padding: 12px;
}

.audit-card.active,
.rule-card.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.15);
}

.audit-card {
  cursor: pointer;
}

.rule-card {
  cursor: pointer;
}

.audit-target,
.rule-id,
.engine-name {
  display: block;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.audit-sub {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.summary-grid span,
.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.value-note {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.metric-card strong {
  font-size: 20px;
  line-height: 1.2;
}

.metric-card-wide {
  background: linear-gradient(135deg, #effaf7 0%, #fff 80%);
}

.rules-overview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.rules-layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.rules-sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 18px;
}

.rule-list {
  max-height: 70vh;
  overflow: auto;
  padding-right: 4px;
}

.rule-card-header,
.rule-head,
.finding-head,
.engine-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.rule-card-header {
  margin-bottom: 8px;
}

.rule-buttons,
.editor-actions,
.rule-actions,
.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rule-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.rule-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.rule-status-dot.off {
  background: #b4aa9b;
}

.rule-subline,
.rule-patterns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rule-subline {
  margin-top: 10px;
}

.rule-patterns {
  margin-top: 10px;
}

.chip,
.pattern-chip,
.guide-label,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 12px;
}

.chip,
.guide-label {
  padding: 5px 9px;
  background: #f1ece2;
  color: #544d44;
}

.pattern-chip {
  padding: 5px 9px;
  background: #e8f5f3;
  color: #0d5c55;
}

.badge {
  min-width: 72px;
  padding: 5px 9px;
  background: #e8f5f3;
  color: #0d5c55;
  text-transform: uppercase;
}

.badge.muted {
  background: #ece7dd;
  color: var(--muted);
}

.rule-workbench {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rule-focus {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.rule-editor-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 10px;
}

.rule-editor-head p,
.engine-card p,
.engine-issue p {
  margin: 6px 0 0;
}

.rule-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.guide-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.section-head h3,
.engine-card h3,
.finding h3,
.engine-issue h4 {
  margin: 0;
}

.engine-section,
.findings-section {
  margin-top: 12px;
}

.engine-issues {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.result-view {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fffdf9;
}

.raw-box pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1280px) {
  .content-grid-home {
    grid-template-columns: 1fr;
  }

  .side-stack {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1100px) {
  .shell,
  .hero,
  .rules-layout {
    grid-template-columns: 1fr;
  }

  .main > .hero,
  .main > .content-grid,
  .main > .panel {
    width: 100%;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .rules-overview,
  .rule-guide,
  .side-stack {
    grid-template-columns: 1fr;
  }

  .rules-sidebar-column {
    position: static;
  }

  .rule-focus,
  .rule-editor-head,
  .hero-actions {
    flex-direction: column;
  }

  .chip-row {
    justify-content: flex-start;
  }

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

  .audit-list,
  .rule-list {
    max-height: none;
  }

  .hero-flow {
    margin-top: 4px;
  }
}
