:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --card: rgba(15, 23, 42, 0.82);
  --muted: rgba(255, 255, 255, 0.7);
  --accent: #f472b6;
  --accent-strong: #fb7185;
  --success: #34d399;
  --warn: #fbbf24;
  --error: #fb7185;
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(circle at top, #1e2337, var(--bg));
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  gap: 14px;
}

body.centered {
  display: grid;
  place-items: center;
}

a {
  color: inherit;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(1.95rem, 4vw, 2.6rem);
  letter-spacing: -0.02em;
}

h2 {
  margin: 0;
  font-size: 1.2rem;
}

p {
  margin: 0;
  line-height: 1.55;
}

p.lead {
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.6;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
}

input,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  outline: none;
  font-size: 1rem;
}

textarea {
  min-height: 160px;
  resize: vertical;
}

input:focus,
textarea:focus {
  box-shadow: 0 0 0 2px rgba(244, 114, 182, 0.45);
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  transition: transform 120ms ease, box-shadow 200ms ease;
  color: #0f172a;
  background: linear-gradient(120deg, var(--accent), var(--accent-strong));
  font-weight: 600;
}

button.secondary {
  background: rgba(255, 255, 255, 0.12);
  color: var(--muted);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button:active {
  transform: translateY(1px);
}

code,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.shell {
  width: min(960px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.shell.narrow {
  width: min(560px, 100%);
}

.shell.wide,
.container {
  width: min(1100px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

main.shell,
main.container {
  width: min(1100px, 100%);
}

.panel,
.card {
  background: var(--card);
  border-radius: 24px;
  padding: clamp(16px, 2.6vw, 24px);
  backdrop-filter: blur(12px);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.5);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar {
  width: min(1100px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 20px;
  background: var(--card);
  backdrop-filter: blur(12px);
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.5);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
}

.topbar-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-page {
  font-weight: 700;
  font-size: 1rem;
}

.topbar-subtitle {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.topbar-nav,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-actions {
  justify-content: flex-end;
}

.topbar-role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.topbar-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #f8fafc;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.topbar-key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar-key input {
  width: min(200px, 46vw);
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.85rem;
}

.topbar-status {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 140px;
}

.topbar button {
  padding: 6px 14px;
  font-size: 0.85rem;
}

.lookup-grid {
  display: grid;
  grid-template-columns: minmax(220px, 420px) auto auto;
  gap: 16px;
  align-items: end;
}

.lookup-input input {
  max-width: 420px;
}

.lookup-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 600;
}

.lookup-toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.lookup-action {
  display: flex;
  justify-content: flex-end;
}

.render-gallery {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.render-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.render-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 4px;
}

.render-block.is-collapsed {
  display: none;
}

.render-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 0;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
}

.render-card img {
  width: 100%;
  height: auto;
  border-radius: 0;
  display: block;
}

.render-card.missing {
  opacity: 0.5;
  border: 1px dashed rgba(255, 255, 255, 0.2);
}

.assets-tree {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  max-height: 420px;
  overflow: auto;
}

.asset-folder details {
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  margin-left: 4px;
  padding-left: 10px;
}

.asset-folder summary {
  padding: 8px 0;
  color: #e2e8f0;
  font-size: 0.86rem;
  letter-spacing: 0.02em;
}

.asset-folder-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-bottom: 8px;
}

.asset-file-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.asset-file-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.44);
}

.asset-file-name {
  font-size: 0.84rem;
  word-break: break-word;
}

.asset-file-meta {
  font-size: 0.74rem;
  white-space: nowrap;
}

.asset-download-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.render-details {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 16px;
  padding: 12px;
}

.render-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}

.image-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.image-modal.is-open {
  display: flex;
}

.image-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 10, 25, 0.75);
  backdrop-filter: blur(6px);
}

.image-modal__content {
  position: relative;
  z-index: 1;
  max-width: min(92vw, 1100px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.image-modal__content img {
  max-width: 100%;
  max-height: 82vh;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  background: rgba(255, 255, 255, 0.06);
}

.is-hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .render-row {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 720px) {
  .lookup-grid {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .lookup-input input {
    max-width: none;
  }

  .lookup-action {
    justify-content: flex-start;
  }

  .asset-file-row {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

.panel-header h2 {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.9rem;
  color: var(--muted);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.between {
  justify-content: space-between;
}

.status {
  min-height: 1.2em;
  font-weight: 600;
  color: var(--muted);
}

.status.ok {
  color: var(--success);
}

.status.warn {
  color: var(--warn);
}

.status.err {
  color: var(--error);
}

.hint,
.subtitle,
.timestamp,
.small {
  color: var(--muted);
}

.subtitle {
  margin-top: 4px;
}

.api-key-panel {
  position: fixed;
  top: 24px;
  right: 24px;
  width: min(280px, calc(100% - 48px));
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  padding: 18px 20px;
  border-radius: 16px;
  box-shadow: 0 25px 80px rgba(15, 23, 42, 0.6);
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 10;
}

.api-key-panel h2 {
  font-size: 1rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.api-key-panel input {
  font-size: 0.95rem;
  border-radius: 12px;
}

.api-key-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

header.hero {
  background: var(--card);
  padding: 40px clamp(24px, 4vw, 48px);
  border-radius: 28px;
  backdrop-filter: blur(18px);
  box-shadow: 0 40px 120px rgba(15, 23, 42, 0.6);
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 32px;
  align-items: center;
}

.hero-title {
  display: flex;
  justify-content: center;
  text-align: center;
}

.logo {
  width: 140px;
  height: 140px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 28px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  font-weight: 600;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 10px currentColor;
}

.status-chip.ok .status-dot {
  background: var(--success);
}

.status-chip.error .status-dot {
  background: var(--error);
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

details.health-details {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 18px;
  padding: 4px 14px 14px;
}

details.health-details[open] {
  background: rgba(255, 255, 255, 0.06);
}

.health-details summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 0;
}

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

.health-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.health-summary-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.health-summary-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.health-summary-endpoint {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.8rem;
  color: #c7d2fe;
}

.health-summary-status {
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.health-summary-status.ok {
  color: var(--success);
  background: rgba(52, 211, 153, 0.2);
}

.health-summary-status.warn {
  color: var(--warn);
  background: rgba(251, 191, 36, 0.2);
}

.health-summary-status.err {
  color: var(--error);
  background: rgba(248, 113, 113, 0.2);
}

.health-summary-status.locked {
  color: var(--warn);
  background: rgba(251, 191, 36, 0.2);
}

.stat {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.stat small {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-size: 0.7rem;
  margin-bottom: 4px;
}

.stat strong {
  font-size: 1.2rem;
  letter-spacing: 0.01em;
}

#endpointList {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

details.group {
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 16px 16px;
}

details.group[open] {
  background: rgba(255, 255, 255, 0.06);
}

summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 0;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fdf2f8;
}

summary::-webkit-details-marker {
  display: none;
}

.route {
  padding: 12px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.4);
  display: grid;
  gap: 6px;
}

.route + .route {
  margin-top: 10px;
}

.route-path {
  font-family: 'JetBrains Mono', 'Fira Code', 'SFMono-Regular', monospace;
  font-size: 0.9rem;
  color: #c7d2fe;
}

.method {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.method.get { background: rgba(52, 211, 153, 0.2); color: #34d399; }
.method.post { background: rgba(129, 140, 248, 0.2); color: #a5b4fc; }
.method.put { background: rgba(251, 191, 36, 0.2); color: #fbbf24; }
.method.delete { background: rgba(248, 113, 113, 0.2); color: #f87171; }
.method.patch { background: rgba(248, 250, 252, 0.2); color: #e2e8f0; }

.route-desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

#healthDetails p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.empty-state {
  padding: 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  line-height: 1.5;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.9rem;
}

.table-scroll {
  width: 100%;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.table th,
.table td {
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 10px;
  vertical-align: top;
}

.table th {
  background: rgba(255, 255, 255, 0.06);
  text-align: left;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(244, 114, 182, 0.15);
  color: #f9a8d4;
  margin-right: 6px;
  margin-bottom: 4px;
  font-size: 0.75rem;
}

.output {
  margin-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 10px;
}

.outputRow {
  display: grid;
  grid-template-columns: 130px 1fr 90px;
  gap: 10px;
  align-items: center;
  margin: 6px 0;
}

.label {
  color: var(--muted);
  font-weight: 700;
}

.value code {
  display: inline-block;
  word-break: break-all;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  width: 100%;
}

.footer {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 960px) {
  body {
    padding-top: 16px;
  }

  header.hero {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .logo {
    margin: 0 auto;
  }

  .topbar {
    justify-content: center;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-key {
    width: 100%;
  }

  .topbar-status {
    width: 100%;
  }
}
