:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --card-foreground: #09090b;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --border: #e4e4e7;
  --input: #d4d4d8;
  --primary: #18181b;
  --primary-foreground: #fafafa;
  --secondary: #f4f4f5;
  --secondary-foreground: #18181b;
  --accent: #f4f4f5;
  --accent-foreground: #18181b;
  --destructive: #dc2626;
  --ring: #a1a1aa;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

.dark {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #09090b;
  --card-foreground: #fafafa;
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --border: #27272a;
  --input: #3f3f46;
  --primary: #fafafa;
  --primary-foreground: #18181b;
  --secondary: #27272a;
  --secondary-foreground: #fafafa;
  --accent: #27272a;
  --accent-foreground: #fafafa;
  --destructive: #f87171;
  --ring: #71717a;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

svg {
  width: 1rem;
  height: 1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.page-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.container {
  width: min(100% - 2rem, 1280px);
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}

.header-inner {
  display: flex;
  height: 3.5rem;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--foreground);
  font-weight: 600;
  text-decoration: none;
}

.brand svg {
  width: 1.25rem;
  height: 1.25rem;
}

.icon-button {
  position: relative;
  display: inline-grid;
  width: 2.25rem;
  height: 2.25rem;
  place-items: center;
  border: 0;
  border-radius: 0.375rem;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
}

.icon-button:hover,
.button:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.moon-icon {
  position: absolute;
  scale: 0;
  rotate: 90deg;
  transition: scale 160ms ease, rotate 160ms ease;
}

.sun-icon {
  transition: scale 160ms ease, rotate 160ms ease;
}

.dark .moon-icon {
  scale: 1;
  rotate: 0deg;
}

.dark .sun-icon {
  scale: 0;
  rotate: -90deg;
}

.app-frame {
  height: calc(100vh - 3.5rem);
  overflow-y: auto;
  padding: 1.5rem 0;
}

.stack {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  display: flex;
  min-width: 0;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: var(--shadow);
}

.summary-card {
  min-height: 32rem;
  flex: 1;
}

.card-header {
  flex: 0 0 auto;
  padding: 1.5rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}

.card-content {
  padding: 1.5rem;
}

.chat-closed {
  color: var(--muted-foreground);
}

.section-heading {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
}

h1,
h2 {
  margin: 0;
  font-size: 1.125rem;
  line-height: 1.5rem;
  font-weight: 600;
}

p {
  margin: 0;
}

.section-heading p {
  margin-top: 0.25rem;
  color: var(--muted-foreground);
}

.badge-row,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.badge-row {
  margin-top: 0.5rem;
}

.badge {
  display: inline-flex;
  min-height: 1.375rem;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.125rem 0.375rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-secondary {
  border-color: transparent;
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.badge-outline {
  background: transparent;
  color: var(--foreground);
}

.badge-muted {
  background: color-mix(in srgb, var(--muted) 70%, transparent);
  color: var(--muted-foreground);
  font-weight: 500;
}

.badge-row.compact {
  gap: 0.25rem;
  margin-top: 0.375rem;
}

.button {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.375rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease, border-color 140ms ease;
}

.button svg {
  flex: 0 0 auto;
}

.button-sm {
  min-height: 2rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.button-outline {
  border: 1px solid var(--input);
  background: var(--background);
  color: var(--foreground);
  box-shadow: var(--shadow);
}

.button-ghost {
  border: 1px solid transparent;
  background: transparent;
  color: var(--foreground);
}

.button-primary {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.button-primary:hover {
  background: color-mix(in srgb, var(--primary) 90%, transparent);
  color: var(--primary-foreground);
}

.chevron {
  width: 1rem;
  height: 1rem;
}

.collapsible {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.api-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
}

.field-label,
.field label {
  display: flex;
  margin-bottom: 0.5rem;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.field label svg {
  width: 1rem;
  height: 1rem;
}

.input,
.select,
.textarea {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: 0.375rem;
  background: transparent;
  color: var(--foreground);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

.input,
.select {
  min-height: 2.25rem;
  padding: 0.5rem 0.75rem;
}

.textarea {
  display: block;
  min-height: 6rem;
  resize: vertical;
  padding: 0.625rem 0.75rem;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 1px var(--ring);
}

.check-row {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  color: var(--muted-foreground);
  font-size: 0.875rem;
  white-space: nowrap;
}

.help-text {
  margin-top: 0.5rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
}

.prompt-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

#promptName {
  margin-bottom: 0.75rem;
}

.saved-prompts {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.saved-prompt {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  border-radius: 0.375rem;
  background: color-mix(in srgb, var(--muted) 60%, transparent);
  padding: 0.75rem;
}

.saved-prompt strong {
  display: block;
  font-size: 0.875rem;
}

.saved-prompt small {
  display: block;
  color: var(--muted-foreground);
  margin-top: 0.125rem;
}

.chat-panel {
  display: flex;
  min-height: 24rem;
  flex-direction: column;
}

.messages {
  display: flex;
  min-height: 18rem;
  max-height: 38vh;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  padding: 1rem;
}

.message {
  max-width: min(760px, 92%);
  border-radius: 0.5rem;
  padding: 0.75rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: var(--primary);
  color: var(--primary-foreground);
}

.message.assistant {
  align-self: flex-start;
  background: var(--muted);
  color: var(--foreground);
}

.message.pending {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--muted-foreground);
  background:
    linear-gradient(110deg, transparent 0%, color-mix(in srgb, var(--background) 45%, transparent) 42%, transparent 70%),
    var(--muted);
  background-size: 220% 100%, auto;
  animation: pendingShimmer 1.8s ease-in-out infinite;
}

.typing-dots {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
}

.typing-dots i {
  display: block;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.35;
  animation: typingPulse 1.05s ease-in-out infinite;
}

.typing-dots i:nth-child(2) {
  animation-delay: 120ms;
}

.typing-dots i:nth-child(3) {
  animation-delay: 240ms;
}

@keyframes typingPulse {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }

  40% {
    opacity: 1;
    transform: translateY(-0.1875rem);
  }
}

@keyframes pendingShimmer {
  0% {
    background-position: 140% 0, 0 0;
  }

  100% {
    background-position: -80% 0, 0 0;
  }
}

.message.error {
  border: 1px solid color-mix(in srgb, var(--destructive) 35%, transparent);
  color: var(--destructive);
}

.composer {
  display: grid;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  padding: 1rem;
}

.composer-input {
  min-height: 4.5rem;
}

.composer-actions {
  display: flex;
  justify-content: space-between;
}

.filters {
  display: grid;
  grid-template-columns: 220px 180px minmax(0, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

.quick-panel {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.quick-filters label {
  display: inline-flex;
  min-height: 2rem;
  align-items: center;
  gap: 0.375rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
}

.compare-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  color: var(--muted-foreground);
  font-size: 0.75rem;
}

.saved-option-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  margin-top: 0.75rem;
  padding-bottom: 0.125rem;
}

.saved-option-chip {
  display: inline-flex;
  max-width: 18rem;
  min-height: 2rem;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.375rem;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: transparent;
  color: var(--foreground);
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.saved-option-chip span {
  color: var(--muted-foreground);
  font-size: 0.6875rem;
}

.table-region {
  min-height: 0;
  flex: 1;
  overflow: auto;
}

.empty-state {
  display: grid;
  min-height: 20rem;
  place-items: center;
  color: var(--muted-foreground);
  padding: 2rem;
  text-align: center;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--background);
  color: var(--muted-foreground);
  font-size: 0.75rem;
  font-weight: 600;
}

tbody tr.option-row {
  cursor: pointer;
}

tbody tr.option-row:hover {
  background: color-mix(in srgb, var(--muted) 50%, transparent);
}

.cell-category {
  width: 96px;
}

.cell-name {
  width: 220px;
}

.cell-id {
  width: 120px;
}

.cell-actions {
  width: 170px;
}

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

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.6875rem;
}

.muted {
  color: var(--muted-foreground);
}

.small-text {
  font-size: 0.75rem;
  line-height: 1.6;
}

.primary-text {
  font-weight: 600;
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.option-title {
  display: flex;
  min-width: 0;
  gap: 0.5rem;
  align-items: flex-start;
  font-weight: 600;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.option-number {
  flex: 0 0 auto;
  border-radius: 0.375rem;
  background: var(--primary);
  color: var(--primary-foreground);
  padding: 0.125rem 0.375rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.6875rem;
  line-height: 1.4;
}

.line-clamp {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.5;
}

.reason-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.detail-row td {
  background: color-mix(in srgb, var(--muted) 35%, transparent);
  padding: 1rem;
}

.detail-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.detail-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.detail-tab {
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background: transparent;
  color: var(--muted-foreground);
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.detail-tab.active {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--primary-foreground);
}

.detail-tab-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.detail-block.full,
.detail-section.full {
  grid-column: 1 / -1;
}

.detail-block,
.detail-section {
  min-width: 0;
}

.detail-block strong,
.detail-section h3 {
  display: block;
  margin: 0;
  color: var(--foreground);
  font-size: 0.875rem;
  font-weight: 600;
}

.detail-block p,
.detail-section p {
  margin-top: 0.25rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.detail-list {
  display: grid;
  gap: 0.375rem;
  margin: 0.5rem 0 0;
  padding-left: 1rem;
  color: var(--muted-foreground);
  font-size: 0.75rem;
  line-height: 1.55;
}

.detail-list li {
  overflow-wrap: anywhere;
}

.mono-list {
  list-style: none;
  padding-left: 0;
}

.mono-list li {
  display: grid;
  gap: 0.125rem;
}

.mono-list strong,
.mono-list span {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.6875rem;
}

.choice-field {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.choice-field strong {
  font-size: 0.75rem;
}

.choice-field > span {
  color: var(--muted-foreground);
  font-size: 0.6875rem;
}

.choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.choice-list span {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.1875rem 0.375rem;
  color: var(--muted-foreground);
  font-size: 0.6875rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.compare-panel {
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--muted) 30%, transparent);
  padding: 1rem;
}

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

.compare-table-wrap {
  overflow-x: auto;
}

.compare-table {
  min-width: 760px;
  table-layout: fixed;
}

.compare-table th,
.compare-table td {
  vertical-align: top;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.compare-table thead th {
  position: static;
}

.icon-text {
  min-width: 2rem;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  z-index: 20;
  display: grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 10px 24px rgb(0 0 0 / 0.16);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.to-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  .section-heading,
  .prompt-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .filters {
    grid-template-columns: 1fr;
  }

  .quick-panel {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .container {
    width: min(100% - 1rem, 1280px);
  }

  .app-frame {
    padding: 1rem 0;
  }

  .card-header {
    padding: 1rem;
  }

  .api-grid,
  .detail-grid,
  .detail-tab-panel {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .composer-actions {
    justify-content: stretch;
  }

  .button {
    flex: 1 1 auto;
  }
}
