:root {
  --bg: #f6f8fc;
  --bg-2: #eef3fb;
  --surface: #ffffff;
  --surface-muted: #f8fbff;
  --surface-soft: #f2f6fc;
  --border: #dbe4f0;
  --border-strong: #c8d5e6;
  --text: #0f172a;
  --text-2: #52607a;
  --text-3: #8a96ab;
  --accent: #2080f0;
  --accent-2: #1767c6;
  --accent-soft: rgba(32, 128, 240, 0.1);
  --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.05);
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #15803d;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(246, 248, 252, 0.98)),
    radial-gradient(circle at top left, rgba(32, 128, 240, 0.08), transparent 32%);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
}
button, textarea, select, input { font: inherit; }
a { color: inherit; }

#review-app {
  max-width: 1800px;
  margin: 0 auto;
  padding: 16px 20px 18px;
}

#review-topbar {
  min-height: 62px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  padding: 0 4px 14px;
  border-bottom: 1px solid rgba(219, 228, 240, 0.9);
}

.topbar-brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ffffff, #eef5ff);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  font-size: 22px;
}

.brand-copy { min-width: 0; }
.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

h1 {
  font-size: 26px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: 0;
}

.version-pill,
.workspace-chip,
.risk-chip,
#review-badge {
  border-radius: 999px;
  border: 1px solid var(--border-strong);
}

.version-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  background: var(--surface-soft);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

#review-subtitle {
  margin-top: 6px;
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.5;
}

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

#review-main {
  display: grid;
  grid-template-columns: minmax(760px, 1.45fr) minmax(480px, 0.95fr);
  gap: 16px;
  align-items: stretch;
  margin-top: 14px;
  min-height: calc(100vh - 112px);
}

.panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  min-height: 0;
}

.input-panel,
.result-panel {
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 16px 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,251,255,0.94));
  border-bottom: 1px solid var(--border);
}

.panel-kicker {
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.2;
  margin-bottom: 4px;
}

.panel-head h2 {
  font-size: 20px;
  line-height: 1.2;
}

#review-user-line,
#review-status {
  color: var(--text-2);
  font-size: 13px;
}

#review-status.error { color: var(--danger); }

.workspace-strip {
  display: flex;
  gap: 8px;
  padding: 10px 18px 0;
  flex-wrap: wrap;
}

.workspace-chip {
  min-height: 30px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  background: var(--surface-soft);
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 600;
}

#review-form {
  padding: 12px 18px 18px;
  display: grid;
  gap: 14px;
  flex: 1;
  min-height: 0;
}

.field,
.editor-card,
.hint-card {
  display: grid;
  gap: 8px;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 12px;
}

.url-import-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

label {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.input {
  width: 100%;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  outline: none;
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}

.input:hover {
  border-color: var(--border-strong);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(32, 128, 240, 0.12);
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

.hint-card {
  align-content: center;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(250, 252, 255, 0.98), rgba(242, 246, 252, 0.98));
  border: 1px solid var(--border);
  border-radius: 12px;
}

.hint-title {
  font-size: 13px;
  font-weight: 700;
}

.hint-copy {
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.editor-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  min-height: 0;
}

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

.editor-head {
  padding: 13px 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(248,251,255,0.92));
  border-bottom: 1px solid var(--border);
}

.editor-meta,
.editor-footer {
  color: var(--text-3);
  font-size: 12px;
}

.editor-textarea {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none !important;
  min-height: 0;
}

.problem-input {
  min-height: 128px;
}

.code-card { flex: 1; }

.code-input {
  min-height: 420px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  background:
    linear-gradient(90deg, rgba(242, 246, 252, 0.9) 0, rgba(242, 246, 252, 0.9) 48px, transparent 48px),
    linear-gradient(180deg, #ffffff, #fcfdff);
}

.editor-footer {
  padding: 10px 16px 12px;
  border-top: 1px solid var(--border);
}

.review-toolbar {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.primary,
.secondary,
.link-btn {
  min-height: 40px;
  border-radius: 10px;
  padding: 0 16px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .14s ease, background .14s ease, color .14s ease, border-color .14s ease, box-shadow .14s ease;
}

.primary {
  background: linear-gradient(180deg, #2f94ff, var(--accent));
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 10px 24px rgba(32, 128, 240, 0.2);
}

.primary:hover {
  background: linear-gradient(180deg, #2386ef, var(--accent-2));
  transform: translateY(-1px);
}

.secondary {
  background: #ffffff;
  color: var(--text);
}

.secondary:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
  transform: translateY(-1px);
}

.secondary:disabled,
.primary:disabled {
  opacity: 0.64;
  cursor: default;
  transform: none;
  box-shadow: none;
}

.risk-chip-row {
  display: flex;
  gap: 8px;
  padding: 12px 18px 0;
  flex-wrap: wrap;
}

.risk-chip {
  min-height: 30px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-2);
}

.risk-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 8px;
}

.risk-tle::before { background: #ef4444; }
.risk-mle::before { background: #f59e0b; }
.risk-ub::before { background: #8b5cf6; }
.risk-uninit::before { background: #3b82f6; }
.risk-overflow::before { background: #2563eb; }
.risk-wa::before { background: #14b8a6; }

.result-panel { min-height: 0; }

#review-empty,
#review-result {
  flex: 1;
}

#review-empty {
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-3);
  text-align: center;
}

.empty-illustration {
  width: 66px;
  height: 66px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #ffffff, #eff5ff);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  font-size: 34px;
}

.empty-title {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
}

.empty-copy {
  max-width: 420px;
  line-height: 1.6;
  font-size: 14px;
}

#review-result {
  padding: 16px 18px 18px;
  display: grid;
  gap: 16px;
  overflow: auto;
}

.result-section {
  display: grid;
  gap: 12px;
}

.result-section h3 {
  font-size: 16px;
  line-height: 1.2;
}

.result-section h4 {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 6px;
}

.hidden { display: none !important; }

#review-badge {
  min-height: 34px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
}

#review-badge.low {
  background: rgba(21, 128, 61, 0.1);
  border-color: rgba(21, 128, 61, 0.22);
  color: var(--ok);
}

#review-badge.medium {
  background: rgba(217, 119, 6, 0.1);
  border-color: rgba(217, 119, 6, 0.22);
  color: var(--warn);
}

#review-badge.high,
#review-badge.critical {
  background: rgba(220, 38, 38, 0.1);
  border-color: rgba(220, 38, 38, 0.22);
  color: var(--danger);
}

.meta-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.meta-card,
.summary-card,
.finding-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 14px;
}

.meta-card,
.summary-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.98), rgba(248,251,255,0.96));
}

.meta-label,
.summary-label {
  color: var(--text-3);
  font-size: 12px;
  margin-bottom: 5px;
}

.meta-value,
.summary-value {
  font-size: 15px;
  font-weight: 700;
  word-break: break-word;
}

.finding-list {
  display: grid;
  gap: 10px;
}

.finding-item {
  border-left: 4px solid #d8e4f5;
}

.finding-item.low { border-left-color: #84cc16; }
.finding-item.medium { border-left-color: #f59e0b; }
.finding-item.high,
.finding-item.critical { border-left-color: #dc2626; }

.finding-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.finding-title {
  font-weight: 700;
  line-height: 1.4;
}

.finding-severity {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
}

.finding-detail {
  color: var(--text-2);
  line-height: 1.58;
  font-size: 14px;
}

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

.log-box {
  min-height: 132px;
  max-height: 240px;
  overflow: auto;
  background: #0f172a;
  color: #e5eefc;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 12px;
  padding: 12px;
  font-size: 12px;
  line-height: 1.5;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 1280px) {
  #review-main {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .code-input {
    min-height: 320px;
  }
}

@media (max-width: 860px) {
  #review-app {
    padding: 12px;
  }

  #review-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .field-grid,
  .url-import-row,
  .meta-grid,
  .summary-grid,
  .log-grid {
    grid-template-columns: 1fr;
  }

  .review-toolbar {
    align-items: stretch;
  }

  .form-actions,
  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .form-actions > *,
  .topbar-actions > * {
    flex: 1;
  }
}
