:root {
  color-scheme: dark;
  --bg: #0f172a;
  --panel: #111827;
  --panel-soft: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.18);
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --blue: #38bdf8;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.12), transparent 28%),
    radial-gradient(circle at bottom right, rgba(34, 197, 94, 0.1), transparent 24%),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

.page {
  width: min(100%, 1180px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 34px 22px 50px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 34px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text);
  text-decoration: none;
}

.logo {
  display: grid;
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  place-items: center;
  border-radius: 14px;
  color: #020617;
  background: linear-gradient(135deg, var(--blue), var(--green));
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25);
  font-size: 13px;
  font-weight: 900;
}

.brand-copy {
  display: block;
}

.brand-title {
  display: block;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.user-pill {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(15, 23, 42, 0.72);
  font-size: 13px;
  white-space: nowrap;
}

.hero {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(17, 24, 39, 0.72);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}

.hero h1 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat {
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(31, 41, 55, 0.62);
}

.stat strong {
  display: block;
  margin-bottom: 4px;
  font-size: 22px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.section-title {
  margin: 30px 0 14px;
  color: #cbd5e1;
  font-size: 16px;
  font-weight: 700;
}

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

.card {
  position: relative;
  min-height: 214px;
  overflow: hidden;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(17, 24, 39, 0.78);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
}

.card::after {
  position: absolute;
  top: -50px;
  right: -50px;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(56, 189, 248, 0.1);
  content: "";
  pointer-events: none;
}

.card-head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.app-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.app-desc {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #dbeafe;
  background: rgba(15, 23, 42, 0.8);
  font-size: 12px;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.badge-project .dot {
  background: var(--orange);
}

.badge-restricted .dot {
  background: var(--red);
}

.meta {
  position: relative;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 20px;
}

.chip {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #cbd5e1;
  background: rgba(31, 41, 55, 0.78);
  font-size: 12px;
}

.actions {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  background: rgba(31, 41, 55, 0.78);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: filter 160ms ease, transform 160ms ease;
}

.btn:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

.btn-primary {
  border-color: transparent;
  color: #020617;
  background: linear-gradient(135deg, var(--blue), var(--green));
}

.is-disabled {
  cursor: default;
  opacity: 0.62;
  pointer-events: none;
}

.btn-primary.is-disabled {
  opacity: 1;
}

.brand:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
}

.empty-state {
  max-width: 820px;
  padding: clamp(28px, 6vw, 56px);
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(17, 24, 39, 0.78);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.empty-state .badge {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.empty-state h1 {
  margin: 0 0 12px;
  font-size: clamp(28px, 5vw, 42px);
  letter-spacing: -0.03em;
}

.empty-state p:not(.eyebrow) {
  max-width: 650px;
  margin: 0 0 28px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.65;
}

.footer {
  margin-top: 34px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

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

.legal-header {
  margin-bottom: 24px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  color: var(--blue);
}

.legal-header h1 {
  margin: 0 0 8px;
  font-size: clamp(32px, 5vw, 48px);
  letter-spacing: -0.04em;
}

.legal-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.legal-search-panel {
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(17, 24, 39, 0.78);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}

.legal-search-panel h2 {
  margin: 0 0 18px;
  font-size: 18px;
  letter-spacing: -0.02em;
}

.legal-search-form textarea {
  display: block;
  width: 100%;
  min-height: 128px;
  padding: 18px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 16px;
  outline: none;
  color: var(--text);
  background: rgba(15, 23, 42, 0.82);
  font: inherit;
  font-size: 15px;
  line-height: 1.55;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.legal-search-form textarea::placeholder {
  color: #74849b;
}

.legal-search-form textarea:focus {
  border-color: rgba(56, 189, 248, 0.55);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

.legal-filters {
  margin: 20px 0;
  padding: 0;
  border: 0;
}

.legal-filters legend {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filter-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.filter-chip {
  cursor: pointer;
}

.filter-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.filter-chip span {
  display: inline-flex;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #cbd5e1;
  background: rgba(31, 41, 55, 0.68);
  font-size: 12px;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.filter-chip input:checked + span {
  border-color: rgba(56, 189, 248, 0.48);
  color: #dff8ff;
  background: rgba(56, 189, 248, 0.14);
}

.filter-chip input:focus-visible + span {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.search-button {
  min-width: 132px;
  border: 0;
  cursor: pointer;
}

.api-notice {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: 18px 0 30px;
  padding: 14px 16px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 16px;
  background: rgba(56, 189, 248, 0.07);
}

.api-notice-icon {
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border-radius: 50%;
  color: #020617;
  background: var(--blue);
  font-size: 13px;
  font-weight: 900;
}

.api-notice strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.api-notice p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.legal-results {
  margin-top: 34px;
}

.results-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.results-heading .eyebrow {
  margin-bottom: 6px;
}

.results-heading h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.results-count {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.result-list {
  display: grid;
  gap: 14px;
}

.legal-result {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(17, 24, 39, 0.78);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.14);
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

.result-meta span {
  color: var(--blue);
  font-weight: 700;
}

.legal-result h3 {
  margin: 0 0 9px;
  font-size: 18px;
  letter-spacing: -0.015em;
}

.legal-result > p {
  max-width: 850px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.result-actions button {
  cursor: pointer;
}

.no-results {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--muted);
  background: rgba(17, 24, 39, 0.64);
  font-size: 14px;
}

.legal-footer-nav {
  margin-top: 30px;
}

.legal-footer-nav .back-link {
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page {
    padding: 24px 14px 40px;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .user-pill {
    width: fit-content;
  }

  .stats,
  .grid {
    grid-template-columns: 1fr;
  }

  .hero,
  .card,
  .empty-state,
  .legal-search-panel,
  .legal-result {
    border-radius: 18px;
  }
}

@media (max-width: 480px) {
  .brand-title {
    font-size: 22px;
  }

  .subtitle {
    font-size: 13px;
  }

  .hero,
  .card {
    padding: 18px;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .stat {
    padding: 12px 9px;
  }

  .card-head {
    flex-direction: column;
  }

  .legal-search-panel,
  .legal-result {
    padding: 18px;
  }

  .results-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .result-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .result-actions .btn {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
