:root {
  color-scheme: light dark;
  --bg: #0f0f0f;
  --ink: #f5f5f5;
  --muted: #b9b9b9;
  --line: #2a2a2a;
  --accent: #ffffff;
  --panel: #151515;
  --panel-2: #141414;
  --max-width: min(90vw, 1100px);
  --mono: "Space Mono", "Courier New", monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --ink: #000000;
    --muted: #555555;
    --line: #d0d0d0;
    --accent: #000000;
    --panel: #f5f5f5;
    --panel-2: #eeeeee;
  }
}

[data-theme="light"] {
  --bg: #ffffff;
  --ink: #000000;
  --muted: #555555;
  --line: #d0d0d0;
  --accent: #000000;
  --panel: #f5f5f5;
  --panel-2: #eeeeee;
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --ink: #f5f5f5;
  --muted: #b9b9b9;
  --line: #2a2a2a;
  --accent: #ffffff;
  --panel: #151515;
  --panel-2: #141414;
}

body { caret-color: transparent; }
input, textarea, [contenteditable] { caret-color: auto; }

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--mono);
  background: var(--bg);
  color: var(--ink);
}

main {
  width: 100%;
}

.bot-container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 32px 20px 48px;
}

.section + .section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.file-title {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--muted);
}

h1,
h2,
h3 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  font-weight: 700;
}

p {
  margin: 0 0 10px;
  line-height: 1.5;
}

a {
  color: var(--ink);
  text-decoration: underline;
}

.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.output {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  white-space: pre-wrap;
  font-size: 0.9rem;
}

.json-viewer h1 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  font-weight: 700;
}

.json-meta {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.json-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

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

input[type="text"] {
  flex: 1;
  min-width: 220px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.9rem;
}

button {
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.85rem;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

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

.run-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.run-btn .run-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.7rem;
  line-height: 1;
}

.run-btn.run-btn-table {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.suggestions {
  margin-top: 12px;
  display: grid;
  gap: 6px;
}

.suggestion {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.suggestion.is-active {
  border-color: var(--accent);
}

.suggestion code {
  font-family: var(--mono);
  color: var(--ink);
}

.suggestion span {
  color: var(--muted);
  font-size: 0.8rem;
}

.command-list {
  display: grid;
  gap: 16px;
}

.command-group {
  border: 1px solid var(--line);
  padding: 8px 10px 12px;
}

.command-group summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 8px;
}

.command-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.command-table col.command-col { width: 28%; }
.command-table col.summary-col { width: 40%; }
.command-table col.mode-col { width: 12%; }
.command-table col.output-col { width: 10%; }
.command-table col.run-col { width: 10%; }

.command-table th,
.command-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.command-table tbody tr:last-child td {
  border-bottom: none;
}

.command-table th:last-child,
.command-table td:last-child {
  text-align: right;
}

.command-table th {
  font-size: 0.75rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.command-id {
  padding: 0;
  border: none;
  background: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.command-id:hover {
  text-decoration: underline;
}

.tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree-item {
  margin: 0;
  padding: 0;
}

.tree-details {
  margin: 0;
}

.tree-details > summary {
  list-style: none;
}

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

.tree-children {
  margin: 4px 0 0 14px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.tree-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 8px;
  min-height: 40px;
  cursor: pointer;
  color: var(--ink);
  text-decoration: none;
}

.tree-row:hover {
  background: var(--panel-2);
}

.tree-chevron {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 120ms ease;
  flex: 0 0 auto;
}

.tree-chevron.is-hidden {
  opacity: 0;
}

.tree-details[open] > summary .tree-chevron {
  transform: rotate(45deg);
}

.tree-icon {
  width: 12px;
  height: 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  display: inline-block;
  flex: 0 0 auto;
  background: var(--panel-2);
}

.tree-icon.is-file {
  background: transparent;
}

.tree-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.tree-primary {
  font-size: 0.9rem;
  line-height: 1.2;
}

.tree-secondary {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.2;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

.tree-copy {
  margin-left: auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 0.7rem;
  opacity: 0;
  transition: opacity 120ms ease;
}

.tree-row:hover .tree-copy,
.tree-copy:focus-visible {
  opacity: 1;
}

.sitemap-toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  z-index: 50;
}

.sitemap-toast.is-visible {
  opacity: 1;
}

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

@media (max-width: 720px) {
  .bot-container {
    padding: 24px 16px 40px;
  }

  .command-table th,
  .command-table td {
    padding: 6px 4px;
  }
}

@media (max-width: 640px) {
  .bot-container {
    max-width: 100%;
    padding: 16px 8px 28px;
  }

  .command-runner {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .command-runner input,
  .command-runner button {
    width: 100%;
    box-sizing: border-box;
  }

  .command-runner button {
    min-height: 44px;
  }

  .cmd-table thead {
    display: none;
  }

  .cmd-table,
  .cmd-table tbody,
  .cmd-table tr,
  .cmd-table td {
    display: block;
    width: 100%;
  }

  .cmd-table tr {
    border: none;
    border-radius: 0;
    padding: 8px 0;
    margin: 10px 0;
    background: transparent;
    border-bottom: 1px solid var(--line);
  }

  .cmd-table tr:last-child {
    border-bottom: none;
  }

  .cmd-table td {
    padding: 4px 0;
    overflow-wrap: anywhere;
  }

  .cmd-table td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .cmd-table td.cmd-run[data-label]::before {
    display: none;
  }

  .cmd-table td.cmd-run {
    padding-top: 10px;
    padding-bottom: 6px;
  }

  .cmd-table td.cmd-run button {
    width: 100%;
    min-height: 44px;
    margin-bottom: 6px;
  }

  .command-group {
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
    box-shadow: none;
  }

  .command-group summary {
    padding: 0;
    margin: 0 0 2px;
  }

  .command-group .cmd-table tr:first-child {
    margin-top: 4px;
  }

  .tree-row {
    padding: 10px 4px;
    min-height: 44px;
  }

  .tree-primary {
    display: none;
  }

  .tree-secondary {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: 0.85rem;
    color: var(--ink);
  }

  .tree-copy {
    display: none;
  }
}
