:root {
  --bg: #07111f;
  --bg-soft: rgba(17, 26, 43, 0.82);
  --card: rgba(12, 20, 34, 0.84);
  --card-soft: rgba(20, 35, 58, 0.86);
  --text: #ecf3ff;
  --muted: #9eb0cf;
  --primary: #4f8cff;
  --primary-2: #6d5efc;
  --accent: #7af0d2;
  --danger: #ff8d8d;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.35);
  --panel-soft: rgba(255, 255, 255, 0.04);
  --panel-soft-2: rgba(255, 255, 255, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(79, 140, 255, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(109, 94, 252, 0.15), transparent 25%),
    linear-gradient(180deg, var(--bg) 0%, #09111d 100%);
}

.ads-body {
  min-height: 100vh;
}

.ads-app {
  min-height: 100vh;
  padding: 14px 0 28px;
}

body.light-theme.ads-body {
  --bg: #eef3fb;
  --bg-soft: rgba(255, 255, 255, 0.95);
  --card: #ffffff;
  --card-soft: #f5f9ff;
  --text: #17283e;
  --muted: #4f6783;
  --primary: #2f73cf;
  --primary-2: #4f8cff;
  --accent: #1db9a1;
  --border: rgba(124, 155, 197, 0.34);
  --shadow: 0 14px 36px rgba(24, 56, 97, 0.1);
  --panel-soft: rgba(44, 103, 192, 0.08);
  --panel-soft-2: rgba(44, 103, 192, 0.1);
  background:
    radial-gradient(circle at top left, rgba(63, 125, 214, 0.12), transparent 34%),
    radial-gradient(circle at top right, rgba(83, 178, 227, 0.1), transparent 28%),
    linear-gradient(180deg, #f4f8ff 0%, #eaf1fb 100%);
}

.hidden {
  display: none !important;
}

.ads-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;
}

.ads-compact-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.ads-search-compact {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: min(560px, 100%);
  gap: 10px;
}

.ads-hero {
  min-height: calc(100vh - 150px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.ads-hero-card {
  width: min(1020px, 96%);
  padding: 42px 34px;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.ads-hero-title {
  margin: 0;
  font-size: clamp(2rem, 3.4vw, 3.2rem);
  line-height: 1.1;
  letter-spacing: 0.2px;
}

.ads-hero-desc {
  margin: 12px 0 0;
  color: var(--muted);
  max-width: 760px;
  line-height: 1.7;
}

.ads-search-large {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ads-input {
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: var(--panel-soft-2);
  color: var(--text);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ads-input::placeholder {
  color: #8799b3;
}

.ads-input:focus {
  border-color: rgba(93, 162, 255, 0.8);
  box-shadow: 0 0 0 4px rgba(93, 162, 255, 0.16);
}

.ads-input-large {
  flex: 1 1 560px;
  min-width: 260px;
  height: 56px;
  padding: 0 18px;
  font-size: 1rem;
}

.ads-input-compact {
  width: min(560px, 100%);
  height: 42px;
  padding: 0 14px;
}

.ads-btn {
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.93rem;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.ads-btn:focus-visible {
  outline: 2px solid rgba(122, 240, 210, 0.65);
  outline-offset: 2px;
}

.ads-btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 12px 24px rgba(79, 146, 255, 0.28);
}

.ads-btn-primary:hover {
  transform: translateY(-1px);
}

.ads-btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.ads-btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.ads-btn-large {
  height: 56px;
  padding: 0 22px;
}

.ads-btn:not(.ads-btn-large) {
  height: 42px;
  padding: 0 14px;
}

.ads-btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.ads-feature-grid {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ads-feature-card {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  border-radius: 16px;
  padding: 16px;
}

.ads-feature-card h3 {
  margin: 0;
  font-size: 0.98rem;
}

.ads-feature-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.92rem;
}

.ads-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ads-alert-wrap {
  min-height: 20px;
}

.ads-status-message {
  padding: 13px 15px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(93, 162, 255, 0.08);
}

.ads-status-error {
  background: rgba(255, 141, 141, 0.09);
  border-color: rgba(255, 141, 141, 0.25);
  color: #ffd7d7;
}

.ads-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  padding: 12px 14px;
  border: 1px solid rgba(122, 240, 210, 0.22);
  background: rgba(122, 240, 210, 0.07);
}

.ads-loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: ads-spin 0.8s linear infinite;
}

@keyframes ads-spin {
  to {
    transform: rotate(360deg);
  }
}

.ads-summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 14px;
}

.ads-root-card,
.ads-stat-card,
.ads-graph-panel,
.ads-panel-card {
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow);
}

.ads-root-card {
  padding: 18px;
}

.ads-root-card h3 {
  margin: 0;
  font-size: 0.95rem;
  color: #bad0ef;
}

.ads-root-title {
  margin: 10px 0 0;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
}

.ads-root-meta {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

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

.ads-stat-card {
  padding: 16px;
  background: var(--panel-soft);
}

.ads-stat-label {
  display: block;
  font-size: 0.83rem;
  color: var(--muted);
}

.ads-stat-value {
  display: block;
  margin-top: 6px;
  font-size: 1.5rem;
  font-weight: 800;
}

.ads-main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(340px, 1fr);
  gap: 16px;
}

.ads-panel-header {
  padding: 18px 20px 10px;
}

.ads-panel-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.ads-panel-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.ads-graph-container {
  position: relative;
  height: 640px;
}

#graphSvg {
  width: 100%;
  height: 100%;
  display: block;
}

.ads-side-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ads-panel-card {
  padding: 16px;
}

.ads-cards-list,
.ads-metadata-panel {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow: auto;
}

.ads-paper-card {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  border-radius: 12px;
  padding: 12px;
}

.ads-paper-card button {
  margin-top: 10px;
  width: 100%;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(93, 162, 255, 0.35);
  background: rgba(93, 162, 255, 0.15);
  color: #dceaff;
  font-weight: 700;
  cursor: pointer;
}

.ads-paper-card button:hover {
  background: rgba(93, 162, 255, 0.22);
}

.ads-paper-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.5;
}

.ads-paper-meta {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.ads-meta-item {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  border-radius: 12px;
  padding: 10px 12px;
}

.ads-meta-label {
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 4px;
}

.ads-empty {
  color: var(--muted);
  line-height: 1.6;
}

.ads-link {
  stroke: rgba(170, 191, 220, 0.3);
  stroke-width: 1.3;
}

.ads-node {
  stroke: rgba(255, 255, 255, 0.52);
  stroke-width: 1.2;
  cursor: pointer;
}

.ads-node-label {
  fill: #dce7fa;
  font-size: 12px;
  pointer-events: none;
}

.ads-tooltip {
  position: absolute;
  pointer-events: none;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(6, 15, 27, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #eef5ff;
  font-size: 0.85rem;
  line-height: 1.5;
  max-width: 320px;
  z-index: 20;
}

body.light-theme.ads-body .ads-input {
  border-color: rgba(116, 145, 187, 0.42);
  background: #ffffff;
}

body.light-theme.ads-body .ads-input::placeholder {
  color: #6d86a5;
}

body.light-theme.ads-body .ads-btn-secondary,
body.light-theme.ads-body .ads-paper-card button {
  border-color: rgba(124, 155, 197, 0.42);
  background: #f2f7ff;
  color: #173455;
}

body.light-theme.ads-body .ads-status-message {
  border-color: rgba(108, 146, 199, 0.42);
  background: rgba(47, 113, 207, 0.1);
  color: #1d3d67;
}

body.light-theme.ads-body .ads-status-error {
  border-color: rgba(211, 92, 123, 0.35);
  background: rgba(220, 80, 107, 0.12);
  color: #8b2340;
}

body.light-theme.ads-body .ads-loading {
  border-color: rgba(34, 160, 140, 0.32);
  background: rgba(40, 180, 154, 0.1);
  color: #1a4e48;
}

body.light-theme.ads-body .ads-loading-spinner {
  border-color: rgba(38, 71, 111, 0.28);
  border-top-color: #1f4f85;
}

body.light-theme.ads-body .ads-node {
  stroke: rgba(28, 66, 112, 0.46);
}

body.light-theme.ads-body .ads-link {
  stroke: rgba(72, 110, 154, 0.42);
}

body.light-theme.ads-body .ads-node-label {
  fill: #26476f;
}

body.light-theme.ads-body .ads-tooltip {
  background: rgba(250, 253, 255, 0.98);
  border-color: rgba(124, 155, 197, 0.46);
  color: #183050;
}

@media (max-width: 1180px) {
  .ads-summary-grid,
  .ads-main-grid {
    grid-template-columns: 1fr;
  }

  .ads-graph-container {
    height: 560px;
  }
}

@media (max-width: 820px) {
  .ads-app {
    padding: 14px;
  }

  .ads-search-compact,
  .ads-input-compact {
    width: 100%;
  }

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

  .ads-hero-card {
    padding: 30px 18px;
  }

  .ads-graph-container {
    height: 480px;
  }
}
