:root {
  color-scheme: light;
  --bg: #f3f7fb;
  --surface: #ffffff;
  --surface-alt: #edf3fb;
  --surface-strong: #0f172a;
  --border: #cfd8e3;
  --border-strong: #94a3b8;
  --text: #102033;
  --text-muted: #526173;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --success: #0f766e;
  --warning-bg: #fff4d6;
  --warning-text: #7c4a03;
  --code-bg: #0b1220;
  --code-text: #dbe7f5;
  --keyword: #7dd3fc;
  --table: #fbbf24;
  --string: #86efac;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --radius: 20px;
  --radius-sm: 14px;
  --font-sans: Inter, Segoe UI, Arial, sans-serif;
  --font-mono: Consolas, Menlo, Monaco, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #08101d;
  --surface: #101a2a;
  --surface-alt: #162235;
  --surface-strong: #e2e8f0;
  --border: #243246;
  --border-strong: #475569;
  --text: #e2e8f0;
  --text-muted: #a8bbcf;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --success: #5eead4;
  --warning-bg: rgba(245, 158, 11, 0.16);
  --warning-text: #fde68a;
  --code-bg: #050b16;
  --code-text: #d8e5f6;
  --keyword: #7dd3fc;
  --table: #fcd34d;
  --string: #86efac;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: radial-gradient(circle at top, rgba(37, 99, 235, 0.1), transparent 24%), var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  min-height: 100vh;
}

a {
  color: var(--accent);
}

a:hover {
  text-decoration-thickness: 2px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.38);
  outline-offset: 2px;
}

.shell {
  width: min(1380px, calc(100% - 24px));
  margin: 0 auto;
  padding: 24px 0 20px;
}

.app-header,
.app-footer,
.sidebar,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.app-header {
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.header-title h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3rem);
}

.header-title p {
  margin: 8px 0 0;
  color: var(--text-muted);
  max-width: 70ch;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-note {
  margin: 0 0 20px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid rgba(245, 158, 11, 0.3);
  font-weight: 600;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 2fr) repeat(2, minmax(180px, 1fr));
  gap: 14px;
}

.control-group {
  display: grid;
  gap: 8px;
}

.control-group label,
.section-label,
.detail-eyebrow {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.search-input,
.filter-select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-alt);
  color: var(--text);
}

.theme-toggle,
.copy-button {
  border: 1px solid var(--border-strong);
  background: var(--surface-alt);
  color: var(--text);
  min-height: 44px;
  border-radius: 999px;
  padding: 0 16px;
  font-weight: 600;
}

.app-main {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.sidebar,
.detail-panel {
  border-radius: var(--radius);
}

.sidebar {
  padding: 18px;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 14px;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.15rem;
}

.sidebar-header p {
  margin: 0;
  color: var(--text-muted);
  font-weight: 600;
}

.technique-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 290px);
  overflow: auto;
}

.technique-card {
  width: 100%;
  text-align: left;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  padding: 14px;
  display: grid;
  gap: 6px;
}

.technique-card:hover,
.technique-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.technique-card__id {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 700;
}

.technique-card__name {
  font-weight: 700;
}

.technique-card__meta,
.technique-card__sources,
.section-subtitle,
.citation-list,
.empty-list-item p,
.empty-detail p {
  color: var(--text-muted);
}

.technique-card__sources {
  font-size: 0.92rem;
}

.empty-list-item {
  border: 1px dashed var(--border);
  border-radius: 16px;
  padding: 14px;
}

.detail-panel {
  padding: 22px;
}

.detail-card {
  display: grid;
  gap: 22px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.detail-header h2 {
  margin: 4px 0 0;
  line-height: 1.2;
  font-size: clamp(1.7rem, 3vw, 2.25rem);
}

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

.text-link {
  font-weight: 700;
}

.detail-meta,
.section-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.detail-meta {
  flex-wrap: wrap;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.tag,
.badge,
.mini-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-weight: 700;
}

.badge {
  border-color: rgba(15, 118, 110, 0.28);
  color: var(--success);
}

.mini-badge {
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

.detail-section {
  display: grid;
  gap: 12px;
}

.kql-block {
  margin: 0;
  padding: 18px;
  border-radius: 18px;
  background: var(--code-bg);
  color: var(--code-text);
  overflow: auto;
  border: 1px solid rgba(125, 211, 252, 0.15);
}

.kql-block code {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.token-keyword {
  color: var(--keyword);
  font-weight: 700;
}

.token-table {
  color: var(--table);
  font-weight: 700;
}

.token-string {
  color: var(--string);
}

.caveat-box {
  border-radius: 18px;
  border: 1px solid rgba(245, 158, 11, 0.28);
  background: var(--warning-bg);
  color: var(--warning-text);
  padding: 18px;
}

.caveat-box p {
  margin: 0;
}

.caveat-box p + p {
  margin-top: 10px;
}

.citation-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

.empty-detail {
  min-height: 320px;
  display: grid;
  place-content: center;
  text-align: center;
}

.app-footer {
  margin-top: 20px;
  border-radius: var(--radius);
  padding: 18px 24px;
  text-align: center;
  color: var(--text-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .toolbar,
  .app-main {
    grid-template-columns: 1fr;
  }

  .technique-list {
    max-height: 360px;
  }

  .detail-header,
  .detail-meta,
  .section-header,
  .header-top {
    flex-direction: column;
  }

  .detail-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100%, calc(100% - 16px));
    padding-top: 16px;
  }

  .app-header,
  .sidebar,
  .detail-panel,
  .app-footer {
    padding: 16px;
    border-radius: 18px;
  }

  .theme-toggle,
  .copy-button,
  .search-input,
  .filter-select {
    width: 100%;
  }

  .detail-header h2 {
    font-size: 1.55rem;
  }
}
