:root {
  --bg: #f4f6fb;
  --bg2: #eef1f8;
  --card: #ffffff;
  --border: #dfe4ee;
  --text: #1f2633;
  --muted: #6b7486;
  --accent: #3b6ef5;
  --accent-dark: #2b55c7;
  --ok: #1f9d55;
  --paid: #9aa1af;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(30, 45, 80, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 26px; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: -0.2px; }
.tag { margin: 2px 0 0; font-size: 12px; color: var(--muted); }

.quota {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 14px;
  box-shadow: var(--shadow);
}
.quota label, .quota span:first-child { font-size: 11px; color: var(--muted); }
.quota strong { font-size: 18px; color: var(--accent); }

.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  min-height: calc(100vh - 68px);
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--bg2);
  overflow-y: auto;
  overscroll-behavior: contain;
  max-height: calc(100vh - 68px);
  position: sticky;
  top: 68px;
}

.search-box { padding: 14px 14px 8px; }
.search-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 14px;
  outline: none;
}
.search-box input:focus { border-color: var(--accent); }

.model-list { padding: 4px 10px 20px; }

.task-group { margin: 10px 0; }
.task-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.task-label .count { margin-left: auto; font-weight: 500; }
.task-label .chev { transition: transform 0.15s; font-size: 10px; }
.task-group.collapsed .task-label .chev { transform: rotate(-90deg); }
.task-group.collapsed .model-items { display: none; }

.model-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px 7px 12px;
  margin: 2px 4px;
  border-radius: 9px;
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 13px;
  line-height: 1.3;
}
.model-item:hover { background: var(--card); border-color: var(--border); }
.model-item.active { background: var(--card); border-color: var(--accent); box-shadow: var(--shadow); }
.model-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.model-item.free .dot { background: var(--ok); }
.model-item.paid .dot { background: var(--paid); }
.model-item .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-item.paid .nm { color: var(--paid); }
.model-item .est { margin-left: auto; font-size: 10px; color: var(--muted); flex-shrink: 0; }

.loading, .empty { color: var(--muted); text-align: center; padding: 30px; }

.content { padding: 26px 30px; max-width: 860px; }
.empty { margin-top: 60px; }
.empty-icon { font-size: 48px; }

.hidden { display: none !important; }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }

.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 20px; }
.model-id { font-size: 12px; color: var(--muted); word-break: break-all; }
.badges { display: flex; gap: 8px; }
.badge { font-size: 11px; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.badge.free { background: #e6f6ec; color: var(--ok); }
.badge.paid { background: #eef0f4; color: var(--paid); }
.badge.task { background: #eef3ff; color: var(--accent); }

.model-desc { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.run-form { margin-top: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 11px; color: var(--muted); font-weight: 400; }
.field textarea, .field input[type="text"], .field input[type="number"], .field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fbfcfe;
  outline: none;
  resize: vertical;
}
.field textarea:focus, .field input:focus, .field select:focus { border-color: var(--accent); background: #fff; }
.field input[type="file"] { font-size: 13px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.actions { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 26px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.run-status { font-size: 13px; color: var(--muted); }

.result { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }
.result-head { display: flex; justify-content: space-between; align-items: center; }
.result-head h3 { margin: 0; font-size: 16px; }
.cost { font-size: 13px; color: var(--accent); font-weight: 600; }
.result-body { margin-top: 12px; }

.result-body pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f7f9fd;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
  max-height: 420px;
  overflow: auto;
  margin: 0;
}
.result-body img {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.result-body audio { width: 100%; margin-top: 4px; }

.dl-row { margin-top: 12px; }
.btn-download {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.btn-download:hover { background: var(--accent-dark); }

.score-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.score-item { display: flex; justify-content: space-between; background: #f7f9fd; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.score-item .lab { color: var(--muted); }
.score-item .val { font-weight: 600; }

.vec-preview { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--muted); background: #f7f9fd; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow: auto; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; max-height: 320px; border-right: none; border-bottom: 1px solid var(--border); }
  .content { padding: 16px; }
  .row { grid-template-columns: 1fr; }
}
