* { box-sizing: border-box; }
:root {
  --bg: #eef2ed;
  --panel: #ffffff;
  --line: #e5e7eb;
  --muted: #64748b;
  --text: #111827;
  --primary: #183e31;
  --blue: #177553;
  --danger: #dc2626;
  --success: #16a34a;
}
body {
  margin: 0;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.shell {
  width: min(1320px, calc(100% - 28px));
  height: calc(100vh - 44px);
  height: calc(100dvh - 44px);
  margin: 22px auto;
  display: grid;
  grid-template-columns: 350px minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}
.sidebar {
  padding: 20px;
  align-self: start;
  position: sticky;
  top: 22px;
  max-height: calc(100vh - 44px);
  overflow-y: auto;
}
.brand { margin-bottom: 20px; }
.brand h1 { margin: 0 0 6px; font-size: 20px; }
.brand p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.back-home {
  display: inline-block;
  margin-bottom: 15px;
  color: #477064;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.back-home:hover { color: var(--primary); }
.field { margin-bottom: 14px; }
.hidden { display: none !important; }
label { display: block; margin-bottom: 6px; font-size: 12px; font-weight: 600; color: #475569; }
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 11px;
  outline: none;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}
.optional-param-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  cursor: pointer;
}
.optional-param-toggle input {
  width: auto;
  margin: 0;
}
.field-help {
  margin-top: 5px;
  color: #64748b;
  font-size: 11px;
  line-height: 1.5;
}
.secret-input { -webkit-text-security: disc; }
.endpoint {
  padding: 10px 11px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  color: #475569;
  font-size: 12px;
  word-break: break-all;
}
.mode-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.tool-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.tool-btn {
  min-height: 38px;
  padding: 7px 5px;
  border: 1px solid #d6ded9;
  border-radius: 9px;
  background: #f7f9f7;
  color: #52645d;
  font-size: 12px;
  cursor: pointer;
}
.tool-btn.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.mode-btn {
  min-height: 42px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  color: #334155;
  cursor: pointer;
  padding: 8px 7px;
  font-size: 12px;
  line-height: 1.25;
}
.mode-btn.active {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.param-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint {
  margin-top: 14px;
  padding: 11px 12px;
  border-radius: 10px;
  background: #fffbeb;
  color: #92400e;
  font-size: 12px;
  line-height: 1.6;
}
.sidebar-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
button { border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.primary { background: var(--primary); color: #fff; }
.secondary { background: #e2e8f0; color: #1e293b; }
button:disabled { opacity: .55; cursor: not-allowed; }

.main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.topbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.badge {
  display: inline-flex;
  align-items: center;
  height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-size: 12px;
  white-space: nowrap;
}
.status { font-size: 13px; color: var(--muted); white-space: nowrap; }
.status.loading { color: #d97706; }
.status.success { color: var(--success); }
.status.error { color: var(--danger); }
.workspace {
  min-height: 0;
  overflow-y: auto;
  padding: 22px;
  background: linear-gradient(180deg, #fff, #fbfdff);
}
.message { display: flex; margin-bottom: 16px; }
.message.user { justify-content: flex-end; }
.bubble {
  max-width: 82%;
  padding: 12px 15px;
  border-radius: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
}
.user .bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 5px; }
.assistant .bubble { background: #eef2f7; color: #111827; border-bottom-left-radius: 5px; }
.image-result {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.image-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}
.image-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.image-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}
.image-card img { display: block; width: 100%; height: auto; object-fit: contain; background: #f1f5f9; }
.image-meta { padding: 9px 10px; color: #475569; font-size: 12px; word-break: break-all; }
.composer { border-top: 1px solid var(--line); padding: 16px 18px 18px; background: #fff; }
.composer textarea { min-height: 108px; resize: vertical; }
.composer-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.shortcut { color: var(--muted); font-size: 12px; }
.send { min-width: 110px; height: 42px; }
.load-test-view {
  min-height: 0;
  padding: clamp(20px, 3vw, 34px);
  overflow-y: auto;
  background:
    radial-gradient(circle at 100% 0%, rgba(22, 117, 83, .08), transparent 28%),
    linear-gradient(180deg, #fff, #f9fbf9);
}
.load-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.section-kicker {
  color: var(--blue);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .12em;
}
.load-heading h2 { margin: 7px 0 8px; font-size: 26px; }
.load-heading p { max-width: 620px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.65; }
.prompt-presets { display: flex; gap: 7px; flex: 0 0 auto; }
.preset-btn {
  border: 1px solid #ccd8d1;
  background: #fff;
  color: #42534d;
  font-size: 12px;
}
.preset-btn.active { border-color: var(--blue); background: #e5f2ec; color: #125f44; }
.load-prompt { min-height: 180px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.6; }
.prompt-meta {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
}
.progress-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0 14px;
}
.progress-grid div { padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.progress-grid span { display: block; color: var(--muted); font-size: 11px; }
.progress-grid strong { display: block; margin-top: 6px; font-size: 21px; }
.load-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.danger-button { background: #fce8e6; color: #a42c22; }
.load-result {
  min-height: 255px;
  margin: 0;
  padding: 18px;
  overflow: auto;
  border: 1px solid #283d35;
  border-radius: 13px;
  background: #14221d;
  color: #d9e9e2;
  font: 12px/1.75 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}
.score-panel {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid #d5dfd9;
  border-radius: 13px;
  background: #fff;
}
.score-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.score-heading h3 { margin: 4px 0 0; font-size: 17px; }
.score-badge {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 11px;
  border-radius: 999px;
  background: #edf2ef;
  color: #52645d;
  font-size: 12px;
  font-weight: 800;
}
.score-badge.valid { background: #dff2e8; color: #126342; }
.score-badge.invalid { background: #fce8e6; color: #9b2c24; }
.score-result {
  margin: 0;
  overflow-x: auto;
  color: #33433d;
  font: 12px/1.75 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}
.load-errors { margin-top: 12px; color: #713b34; font-size: 12px; }
.load-errors summary { cursor: pointer; font-weight: 700; }
.load-errors pre { max-height: 220px; overflow: auto; white-space: pre-wrap; }
.notice-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  min-width: 250px;
  max-width: min(380px, calc(100% - 32px));
  padding: 14px 17px;
  border: 1px solid rgba(255, 255, 255, .15);
  border-radius: 13px;
  background: #173e31;
  color: #fff;
  box-shadow: 0 18px 48px rgba(14, 35, 28, .24);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.notice-toast.show { opacity: 1; transform: translateY(0); }
.notice-toast.error { background: #842f28; }
.notice-toast strong, .notice-toast span { display: block; }
.notice-toast span { margin-top: 3px; color: rgba(255,255,255,.78); font-size: 12px; }
.main.load-mode { grid-template-rows: auto minmax(0, 1fr); }
@media (max-width: 900px) {
  .shell {
    height: auto;
    grid-template-columns: 1fr;
  }
    .sidebar { position: static; max-height: none; }
  .main {
    height: calc(100vh - 44px);
    height: calc(100dvh - 44px);
  }
}
@media (max-width: 560px) {
  .shell { width: min(100% - 16px, 1220px); margin: 8px auto; gap: 8px; }
  .main {
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
  }
  .mode-tabs { grid-template-columns: 1fr; }
  .sidebar-actions, .param-grid { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
  .composer-footer { align-items: stretch; flex-direction: column; }
    .send { width: 100%; }
    .load-heading { flex-direction: column; }
    .prompt-presets { width: 100%; }
    .preset-btn { flex: 1; }
    .progress-grid { grid-template-columns: 1fr 1fr; }
    .load-actions { align-items: stretch; flex-direction: column; }
    .notice-toast { right: 16px; bottom: 16px; left: 16px; max-width: none; }
  }

@media (prefers-reduced-motion: reduce) {
  .notice-toast { transition: none; }
}
