:root {
  --app-line: #d9e4f2;
  --app-ink: #0f172a;
  --app-muted: #42536e;
  --app-surface: #ffffff;
  --app-surface-2: #f6f9ff;
  --app-ok: #0f766e;
  --app-warn: #b45309;
  --app-err: #b91c1c;
}

.app-shell {
  width: min(1160px, calc(100% - 32px));
  margin: 14px auto 0;
}

.app-page .nav,
.app-page .ai-main,
.app-page .app-foot {
  width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.app-page .nav {
  margin-top: 0;
}

.ai-main {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 14px 32px;
  display: grid;
  gap: 14px;
}

.app-page .ai-main {
  padding-left: 0;
  padding-right: 0;
}

.ai-hero h1 {
  margin-bottom: 10px;
  font-size: clamp(30px, 4vw, 46px);
}

.ai-card {
  border: 1px solid var(--app-line);
  background: var(--app-surface);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.ai-label {
  display: inline-block;
  margin-bottom: 8px;
  font-weight: 700;
}

.ai-model-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ai-model-label {
  color: var(--app-muted);
  font-size: 13px;
  font-weight: 600;
}

.ai-select {
  min-width: 190px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--app-line);
  background: #fff;
  color: var(--app-ink);
  font: inherit;
}

.ai-select:focus {
  outline: none;
  border-color: #7aa7da;
  box-shadow: 0 0 0 3px rgba(122, 167, 218, 0.18);
}

#aiPrompt {
  width: 100%;
  min-height: 170px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--app-line);
  background: var(--app-surface-2);
  color: var(--app-ink);
  font: inherit;
  resize: vertical;
}

#aiPrompt:focus {
  outline: none;
  border-color: #7aa7da;
  box-shadow: 0 0 0 3px rgba(122, 167, 218, 0.18);
}

.ai-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.ai-toolbar.right {
  margin-top: 0;
}

.ai-status {
  margin: 12px 0 0;
  color: var(--app-muted);
  font-size: 14px;
}

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

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

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

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

.ai-out-head h2 {
  margin: 0;
}

.ai-summary {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--app-line);
  background: var(--app-surface-2);
  color: var(--app-muted);
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.ai-summary .dot {
  opacity: 0.5;
}

.ai-summary .warn {
  color: var(--app-warn);
}

.ai-cards {
  margin-top: 12px;
}

.ai-table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  background: #fff;
}

.ai-result-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1180px;
  font-size: 12px;
}

.ai-result-table th,
.ai-result-table td {
  border-bottom: 1px solid #e6edf7;
  border-right: 1px solid #edf2fa;
  padding: 10px 10px;
  text-align: left;
  vertical-align: top;
}

.ai-result-table th:last-child,
.ai-result-table td:last-child {
  border-right: 0;
}

.ai-result-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f6faff;
  color: #29496c;
  font-weight: 700;
}

.ai-result-table tbody tr:hover {
  background: #fafcff;
}

.ai-cell-lines {
  white-space: pre-line;
  line-height: 1.5;
  color: var(--app-muted);
}

.ai-result-table td:nth-child(1) .ai-cell-lines {
  color: #0f4f86;
  font-weight: 600;
}

.ai-empty {
  border: 1px dashed var(--app-line);
  border-radius: 12px;
  background: var(--app-surface-2);
  color: var(--app-muted);
  padding: 16px;
}

.ai-case {
  border: 1px solid var(--app-line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.ai-case-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.ai-case h3 {
  margin: 0;
  font-size: 16px;
}

.ai-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-badge {
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 8px;
  border: 1px solid #bfd3ea;
  background: #eff7ff;
  color: #1d4f80;
}

.ai-badge.prio {
  border-color: #f5c2a5;
  background: #fff3ea;
  color: #9a3412;
}

.ai-badge.type {
  border-color: #bfd3ea;
  background: #eff7ff;
  color: #1d4f80;
}

.ai-desc {
  margin: 8px 0;
  color: var(--app-muted);
  font-size: 14px;
}

.ai-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--app-muted);
  font-size: 13px;
}

.ai-meta code {
  background: #eef4ff;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid #d3dff1;
}

.ai-tags {
  margin-top: 8px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-tag {
  font-size: 12px;
  border: 1px solid #bfd3ea;
  border-radius: 999px;
  padding: 3px 8px;
  color: #1d4f80;
  background: #eff7ff;
}

.ai-tag.muted {
  color: var(--app-muted);
  border-color: var(--app-line);
  background: #f7f9fd;
}

.ai-steps {
  margin-top: 9px;
  font-size: 13px;
  color: var(--app-muted);
  line-height: 1.5;
}

.ai-section {
  margin-top: 12px;
}

.ai-section h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #1f3655;
}

.ai-list {
  margin: 0;
  padding-left: 18px;
  color: var(--app-muted);
  font-size: 13px;
}

.ai-list li + li {
  margin-top: 5px;
}

.ai-empty-inline {
  color: var(--app-muted);
  font-size: 13px;
}

.ai-step-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--app-line);
  border-radius: 10px;
}

.ai-step-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
  font-size: 12px;
}

.ai-step-table th,
.ai-step-table td {
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #e6edf7;
  padding: 8px 10px;
}

.ai-step-table th {
  background: #f7fbff;
  color: #315277;
  font-weight: 700;
}

.ai-step-table tr:last-child td {
  border-bottom: 0;
}

.ai-expected {
  margin: 0;
  font-size: 13px;
  color: var(--app-muted);
  line-height: 1.5;
}

.ai-pre {
  margin: 12px 0 0;
  border: 1px solid var(--app-line);
  border-radius: 12px;
  padding: 12px;
  background: #0f172a;
  color: #dbeafe;
  overflow: auto;
  max-height: 420px;
}

.app-foot {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 14px 28px;
  color: var(--app-muted);
  font-size: 13px;
}

.app-page .app-foot {
  padding-left: 0;
  padding-right: 0;
}

.sep {
  margin: 0 9px;
  opacity: 0.6;
}

@media (max-width: 980px) {
  .ai-out-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .ai-case-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .ai-result-table {
    min-width: 860px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: calc(100% - 20px);
    margin-top: 10px;
  }
}
