:root {
  --bg: #f4efe6;
  --bg-panel: rgba(255, 251, 244, 0.84);
  --bg-card: rgba(255, 252, 248, 0.96);
  --text: #182028;
  --muted: #655f55;
  --border: rgba(53, 45, 31, 0.12);
  --shadow: 0 18px 40px rgba(26, 22, 15, 0.08);
  --ok: #1f9d72;
  --warn: #d7860c;
  --bad: #d84d3f;
  --unknown: #8f8a80;
  --teal: #0f766e;
  --amber: #b45309;
  --slate: #374151;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151a;
    --bg-panel: rgba(20, 24, 30, 0.92);
    --bg-card: rgba(25, 30, 37, 0.96);
    --text: #edf2f7;
    --muted: #9aa3ad;
    --border: rgba(255, 255, 255, 0.08);
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    --ok: #3dd39f;
    --warn: #ffb648;
    --bad: #ff7a66;
    --unknown: #8c96a3;
    --teal: #14b8a6;
    --amber: #f59e0b;
    --slate: #94a3b8;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.12), transparent 30%),
    radial-gradient(circle at top right, rgba(180, 83, 9, 0.12), transparent 32%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 25%),
    var(--bg);
  font-family: "Noto Sans SC", sans-serif;
}

.page-shell {
  width: min(1500px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.hero,
.summary-grid,
.toolbar,
.source-section,
.group-panel,
.provider-card {
  backdrop-filter: blur(14px);
}

.hero {
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: end;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-family: "IBM Plex Mono", monospace;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1;
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
}

.subtitle {
  max-width: 760px;
  margin: 12px 0 0;
  color: var(--muted);
}

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

.primary-button,
.ghost-link,
.source-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--teal), #2ea3b0);
  color: white;
  border-color: transparent;
  cursor: pointer;
}

.primary-button:disabled {
  opacity: 0.65;
  cursor: progress;
}

.ghost-link,
.source-link {
  background: rgba(255, 255, 255, 0.38);
}

.primary-button:hover,
.ghost-link:hover,
.source-link:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.35);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.summary-card {
  padding: 18px 20px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.summary-card strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.4rem, 3vw, 2rem);
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
}

.toolbar {
  margin-top: 18px;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  align-items: center;
  padding: 18px 20px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.search-shell {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: min(460px, 100%);
}

.search-shell span {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  white-space: nowrap;
  font-size: 13px;
  color: var(--muted);
}

.search-shell input {
  width: 100%;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  color: var(--text);
  font: inherit;
}

.toolbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: end;
  color: var(--muted);
  font-size: 13px;
}

.sources-root {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.source-section {
  padding: 20px;
  border-radius: 28px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.source-section[data-source="openclaudecode"] {
  border-top: 4px solid var(--teal);
}

.source-section[data-source="timicc"] {
  border-top: 4px solid var(--amber);
}

.source-section[data-source="doroai"] {
  border-top: 4px solid var(--slate);
}

.source-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  cursor: pointer;
  list-style: none;
}

.source-header > div:first-child {
  flex: 1;
  min-width: 0;
}

.source-header::-webkit-details-marker {
  display: none;
}

.source-header::after {
  content: "";
  color: color-mix(in srgb, var(--muted) 62%, transparent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 11px;
  height: 11px;
  border-right: 2px solid color-mix(in srgb, var(--muted) 62%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--muted) 62%, transparent);
  opacity: 0.66;
  transition: transform 180ms ease, opacity 180ms ease;
  align-self: center;
  order: 3;
  transform: rotate(45deg);
}

.source-section[open] > .source-header::after {
  transform: rotate(225deg);
}

.source-kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-family: "IBM Plex Mono", monospace;
}

.source-header h2 {
  margin: 6px 0 0;
  font-size: 1.8rem;
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
}

.source-meta {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.source-header-right {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: end;
}

.source-section > .groups-shell {
  margin-top: 16px;
}

.source-state,
.provider-status,
.availability-pill,
.group-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
}

.source-state[data-status="ok"],
.provider-status[data-status="operational"] {
  color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}

.source-state[data-status="stale"],
.provider-status[data-status="degraded"] {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}

.source-state[data-status="error"],
.provider-status[data-status="failed"] {
  color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
}

.provider-status[data-status="unknown"] {
  color: var(--unknown);
  background: color-mix(in srgb, var(--unknown) 12%, transparent);
}

.groups-shell {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-panel {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.25);
}

.group-panel summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  cursor: pointer;
  padding: 16px 18px;
}

.group-panel summary > div {
  flex: 1;
  min-width: 0;
}

.group-panel summary::-webkit-details-marker {
  display: none;
}

.group-panel summary::after {
  content: "";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  border-right: 2px solid color-mix(in srgb, var(--muted) 62%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--muted) 62%, transparent);
  opacity: 0.66;
  transition: transform 180ms ease, opacity 180ms ease;
  transform: rotate(45deg);
}

.group-panel[open] summary::after {
  transform: rotate(225deg);
}

.group-title {
  margin: 0;
  font-size: 1rem;
}

.group-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.group-count {
  margin-left: auto;
}

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

.provider-card {
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--bg-card);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 245px;
  box-shadow: 0 12px 28px rgba(20, 20, 20, 0.05);
}

.provider-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.provider-name {
  margin: 0;
  font-size: 1rem;
}

.provider-model {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-family: "IBM Plex Mono", monospace;
  word-break: break-word;
}

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

.metric-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.3);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-item strong {
  display: block;
  margin-top: 8px;
  font-size: 14px;
  font-family: "IBM Plex Mono", monospace;
}

.availability-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.availability-pill {
  color: var(--text);
  background: rgba(255, 255, 255, 0.42);
}

.history-row {
  display: grid;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  gap: 4px;
  margin-top: auto;
}

.history-bar {
  height: 22px;
  border-radius: 6px;
  opacity: 0.96;
}

.history-bar[data-status="operational"] {
  background: var(--ok);
}

.history-bar[data-status="degraded"] {
  background: var(--warn);
}

.history-bar[data-status="failed"] {
  background: var(--bad);
}

.history-bar[data-status="unknown"] {
  background: var(--unknown);
}

.provider-message {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 18px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.18);
}

@media (max-width: 1180px) {
  .cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .page-shell {
    width: min(100vw - 20px, 100%);
    padding: 16px 0 42px;
  }

  .hero,
  .toolbar,
  .source-section {
    padding: 18px;
  }

  .hero,
  .toolbar,
  .source-header {
    flex-direction: column;
    align-items: stretch;
  }

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

  .search-shell {
    min-width: 0;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-meta,
  .source-header-right {
    justify-content: start;
  }
}
