:root {
  --bg: #0b0e14;
  --panel: #12161f;
  --panel-2: #171c27;
  --border: #232a38;
  --text: #e6e9f0;
  --muted: #8b94a7;
  --accent: #5b8cff;
  --accent-2: #7aa2ff;
  --ok: #34d399;
  --err: #f87171;
  --warn: #fbbf24;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
}

.brand .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 10px var(--ok);
}

.wrap { max-width: 1080px; margin: 26px auto; padding: 0 22px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
}

.card.login { max-width: 420px; margin: 40px auto; }

.card.note { background: var(--panel-2); font-size: 13px; color: var(--muted); }
.card.note strong { color: var(--text); }
.card.note code { background: #0b0e14; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); }

h1 { font-size: 20px; margin: 0 0 8px; }
h2 { font-size: 16px; margin: 0 0 6px; }
h3 { font-size: 13px; color: var(--muted); margin: 16px 0 6px; }

.muted { color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

.label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 14px 0 6px; }

.input {
  width: 100%;
  background: #0b0e14;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
}

.input:focus { outline: none; border-color: var(--accent); }

.textarea { resize: vertical; font-family: inherit; min-height: 90px; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

.keyrow { display: flex; gap: 8px; }
.keyrow .input { flex: 1; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #1e2532; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.btn.primary:hover { background: var(--accent-2); }
.btn.secondary { background: transparent; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.block { width: 100%; margin-top: 16px; }

.actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }

.status { font-size: 13px; color: var(--muted); }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.statusline { font-size: 13px; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; background: var(--panel-2); border: 1px solid var(--border); }
.statusline.ok { color: var(--ok); border-color: var(--ok); }
.statusline.warn { color: var(--warn); border-color: var(--warn); }

.error { color: var(--err); font-size: 13px; margin-top: 12px; }
.hidden { display: none !important; }

code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--accent-2); }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
  overflow-x: auto;
}
.tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.panel { display: none; }
.panel.active { display: block; }

/* Provider cards */
.provider-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .provider-grid { grid-template-columns: 1fr; } }
.card h2 .tag { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 6px; }

/* Prompt text */
.prompttext {
  background: #0b0e14;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  white-space: pre-wrap;
  font-size: 14px;
  margin: 8px 0 0;
}

/* Checklist */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 8px 0 8px 26px; position: relative; font-size: 14px; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: none; }
.checklist li::before { content: "·"; position: absolute; left: 8px; color: var(--accent); font-weight: 700; }

/* Prompt list + pager */
.prompt-item { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 14px; background: var(--panel-2); }
.prompt-item .meta { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.prompt-item .query { font-weight: 600; font-size: 14px; }
.prompt-item .prompttext { margin-top: 8px; }

.thumbrow { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.thumb { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); cursor: pointer; }

.pager { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 14px; }
.pager button:disabled { opacity: 0.4; }

/* Gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.gallery-item { position: relative; cursor: pointer; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); aspect-ratio: 1; }
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-item .cap { position: absolute; inset: auto 0 0 0; background: linear-gradient(transparent, rgba(0,0,0,0.75)); color: #fff; font-size: 11px; padding: 8px; }

.empty { color: var(--muted); font-size: 14px; padding: 20px 0; text-align: center; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); }
.modal-box {
  position: relative;
  margin: 40px auto;
  width: min(720px, calc(100vw - 40px));
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}
.modal-close { position: absolute; top: 12px; right: 14px; background: none; border: none; color: var(--muted); font-size: 26px; cursor: pointer; }
.modal-close:hover { color: var(--text); }
.modal-image { width: 100%; border-radius: 10px; border: 1px solid var(--border); }

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }
