:root {
  --mock-aside: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #0f1419;
}

main.container-fluid {
  max-width: none;
  padding: 1rem 1.25rem 2rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.topbar h1 {
  margin-bottom: 0.25rem;
  font-size: 1.5rem;
}

.muted {
  color: #9aa4b2;
  margin: 0;
}

.docs-link a {
  color: #58a6ff;
}

.top-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-actions button[disabled] {
  opacity: 0.6;
}

.layout {
  display: grid;
  grid-template-columns: var(--mock-aside) 1fr;
  gap: 1rem;
  min-height: 70vh;
}

.api-list {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 0.75rem;
  padding: 0.75rem;
  overflow: auto;
  max-height: calc(100vh - 8rem);
}

.api-list ul {
  list-style: none;
  padding: 0;
  margin: 0.35rem 0 0.5rem;
}

.category-tree {
  margin-top: 0.75rem;
}

.category-group {
  margin-bottom: 0.35rem;
}

.category-header {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  padding: 0.5rem 0.65rem;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 0.45rem;
  color: #e6edf3;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
}

.category-header.active {
  border-color: #2f81f7;
  background: #1f2a3a;
}

.category-group:not(.open) .chevron {
  transform: rotate(-90deg);
}

.chevron {
  display: inline-block;
  transition: transform 0.15s ease;
  color: #8b949e;
  font-size: 0.7rem;
}

.category-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-count {
  font-size: 0.7rem;
  color: #8b949e;
  font-weight: 500;
}

.api-item {
  width: 100%;
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 0.15rem 0.5rem;
  margin-bottom: 0.3rem;
  padding: 0.5rem 0.65rem;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 0.45rem;
  color: #e6edf3;
}

.api-item.active {
  border-color: #2f81f7;
  box-shadow: 0 0 0 1px #2f81f7 inset;
}

.api-item .method {
  font-size: 0.7rem;
  font-weight: 700;
  color: #3fb950;
}

.api-item .path {
  grid-column: 1 / -1;
  font-size: 0.78rem;
  word-break: break-all;
}

.api-item .badge {
  grid-column: 2;
  justify-self: end;
  font-size: 0.7rem;
  color: #9aa4b2;
}

.detail-controls {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  align-items: stretch;
  min-width: 180px;
}

.detail-controls label {
  margin: 0;
}

.detail-controls select {
  margin-bottom: 0;
}

.detail {
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 0.75rem;
  padding: 1rem;
  overflow: auto;
  max-height: calc(100vh - 8rem);
}

.detail.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9aa4b2;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.detail-header h2 {
  font-size: 1.05rem;
  margin: 0 0 0.35rem;
  word-break: break-all;
}

.enabled-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.scenario-toolbar {
  margin-bottom: 0.75rem;
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.scenario-card {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 0.65rem;
  padding: 0.75rem;
}

.scenario-card.active {
  border-color: #3fb950;
  background: #0f1a14;
  box-shadow:
    0 0 0 1px rgba(63, 185, 80, 0.55) inset,
    0 0 18px rgba(63, 185, 80, 0.14);
}

.scenario-card header {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.35rem;
}

.scenario-card .id {
  font-size: 0.75rem;
}

.scenario-card .meta {
  font-size: 0.8rem;
  margin: 0 0 0.65rem;
}

.scenario-urls {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin: 0.2rem 0 0.65rem;
}

.scenario-url {
  display: block;
  max-width: 100%;
  overflow: hidden;
  padding: 0.3rem 0.4rem;
  border: 1px solid #30363d;
  border-radius: 0.35rem;
  color: #58a6ff;
  background: #161b22;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}

.scenario-url:focus-visible {
  outline: 2px solid #58a6ff;
  outline-offset: 2px;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.card-actions button {
  margin: 0;
  width: auto;
  padding: 0.35rem 0.55rem;
  font-size: 0.8rem;
}

.card-actions .scenario-toggle.active {
  background: #3fb950;
  border-color: #56d364;
  color: #0d1117;
  font-weight: 700;
  box-shadow:
    0 0 0 2px #0d1117,
    0 0 0 4px #56d364,
    0 0 14px rgba(86, 211, 100, 0.45);
}

.card-actions .scenario-toggle.active:hover {
  background: #56d364;
  border-color: #7ee787;
}

.card-actions .scenario-toggle.active:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #238636;
  color: white;
  padding: 0.65rem 0.9rem;
  border-radius: 0.5rem;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

dialog {
  border: none;
  border-radius: 0.75rem;
  padding: 0;
  max-width: 520px;
  width: calc(100% - 2rem);
}

dialog article {
  margin: 0;
  background: #161b22;
  color: #e6edf3;
}

dialog.editor-dialog {
  max-width: min(900px, calc(100% - 2rem));
}

/* JSON editor overlay (replaces native dialog for CodeMirror compatibility) */
[x-cloak] {
  display: none !important;
}

.editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 20, 25, 0.72);
}

.editor-overlay:has(.editor-panel.maximized) {
  padding: 0;
  background: #0f1419;
}

.editor-panel {
  display: flex;
  flex-direction: column;
  width: min(1200px, 96vw);
  max-width: min(1200px, 96vw);
  background: #161b22;
  color: #e6edf3;
  color-scheme: dark;
  border-radius: 0.75rem;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.editor-panel:not(.maximized):not(.dragged) {
  position: relative;
}

.editor-panel.dragged {
  position: fixed;
  margin: 0;
}

.editor-panel.dragging .CodeMirror {
  pointer-events: none;
}

.editor-panel.maximized {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}

.editor-panel > header.editor-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0;
  padding: 0.75rem 1rem;
  background-color: #0d1117;
  background-image: none;
  color: #f0f3f6;
  border-bottom: 1px solid #30363d;
  border-radius: 0.75rem 0.75rem 0 0;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.editor-panel.maximized > header.editor-dialog-header {
  border-radius: 0;
  cursor: default;
}

.editor-panel > header.editor-dialog-header:active {
  cursor: grabbing;
}

.editor-panel.maximized > header.editor-dialog-header:active {
  cursor: default;
}

.editor-panel .editor-dialog-title {
  margin: 0;
  color: #c9d1d9;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-panel .editor-scenario-name {
  color: #79c0ff;
  font-weight: 700;
}

.editor-panel .editor-window-btn {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: 1px solid #30363d;
  border-radius: 0.35rem;
  background: #21262d;
  color: #e6edf3;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.editor-panel .editor-window-btn:hover,
.editor-panel .editor-window-btn:focus {
  background: #30363d;
  border-color: #58a6ff;
  color: #ffffff;
}

.editor-panel .editor-body {
  margin: 0.75rem 1rem;
  padding: 0;
}

.editor-panel footer {
  margin: 0;
  padding: 0.75rem 1rem;
  background: #0d1117;
  border-top: 1px solid #30363d;
  border-radius: 0 0 0.75rem 0.75rem;
}

.editor-panel.maximized footer {
  border-radius: 0;
}

#json-editor {
  height: 420px;
  font-size: 0.9rem;
  border: 1px solid #30363d;
  border-radius: 0.4rem;
}

#json-editor {
  box-sizing: border-box;
  width: 100%;
  resize: vertical;
  padding: 0.75rem;
  border: 1px solid #30363d;
  border-radius: 0.4rem;
  color: #e6edf3;
  background: #0d1117;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  line-height: 1.5;
  tab-size: 2;
}

.editor-panel #json-editor {
  width: 100%;
  border-radius: 0.4rem;
}

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

  .api-list,
  .detail {
    max-height: none;
  }
}
