:root {
  --bg: #0b0a0e;
  --panel: #15131a;
  --panel-2: #1d1a23;
  --line: #2b2632;
  --line-2: #3d3545;
  --text: #f7f3f9;
  --muted: #bcb3c4;
  --faint: #8d8496;
  --accent: #ff2d78;
  --accent-2: #ff5a3c;
  --accent-hover: #ff4f8f;
  --accent-glow: 0 6px 24px rgba(255, 45, 120, 0.35);
  --accent-soft: rgba(255, 45, 120, 0.15);
  --accent-ink: #ffffff;
  --ok: #5ad48a;
  --ok-soft: rgba(90, 212, 138, 0.12);
  --danger: #f2777a;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

/* ---------- layout ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 64px;
  background: rgba(10, 10, 11, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink);
  box-shadow: var(--accent-glow);
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 8px 14px; font-size: 15px; font-weight: 500; border-radius: 8px; color: var(--muted);
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: #fff; background: var(--accent-soft); box-shadow: inset 0 0 0 1px rgba(255,45,120,.35); }

.page { max-width: 1040px; margin: 0 auto; padding: 32px 24px 80px; }
.page-narrow { max-width: 820px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
h1 { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 18px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin: 24px 0 10px; }
.sub { color: var(--muted); margin-top: 4px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }
.mt { margin-top: 16px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* ---------- controls ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 18px; border-radius: 9px;
  border: 1px solid var(--line-2); background: var(--panel-2);
  font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover { background: #202025; border-color: #3a3a42; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--accent-ink); box-shadow: var(--accent-glow); }
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), #ff7352); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.icon-btn { width: 34px; padding: 0; }

.input, .textarea, .select {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--line-2);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { min-height: 80px; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.hint { font-size: 13px; color: var(--faint); margin-top: 6px; }

/* inline-editable inputs that look like text until focused */
.ghost-input {
  width: 100%; background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 6px 8px; margin: -6px -8px; outline: none;
}
.ghost-input:hover { background: var(--panel-2); }
.ghost-input:focus { background: var(--bg); border-color: var(--accent); }

/* ---------- surfaces ---------- */

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 18px; }
.list > * + * { border-top: 1px solid var(--line); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 13px; font-weight: 500;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs button {
  background: none; border: none; padding: 12px 16px; font-size: 15px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom: 2px solid var(--accent); }
.tabs .count { color: var(--muted); margin-left: 6px; font-size: 13px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { height: 36px; padding: 0 14px; font-size: 14px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; color: var(--muted); }
.filters button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.progress { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); box-shadow: 0 0 12px rgba(255,45,120,.6); border-radius: 999px; transition: width .3s; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }

/* ---------- models list ---------- */

.model-row { display: flex; align-items: center; gap: 16px; padding: 14px 18px; transition: background .15s; }
.model-row:hover { background: var(--panel-2); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 600;
  background: linear-gradient(135deg, rgba(255,45,120,.25), rgba(255,90,60,.12)); border: 1px solid rgba(255,45,120,.4); color: #fff;
}
.model-progress { width: 160px; flex: none; }

/* ---------- steps ---------- */

.step { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); transition: border-color .15s; }
.step + .step { margin-top: 8px; }
.step.open { border-color: rgba(255,45,120,.45); box-shadow: 0 0 0 1px rgba(255,45,120,.15), 0 10px 40px rgba(255,45,120,.08); }
.step-head { display: flex; align-items: center; gap: 16px; padding: 16px 18px; cursor: pointer; }
.check {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
  border: 2px solid #5a5063; color: var(--text); background: var(--panel-2); background: transparent;
}
.check.done { background: var(--ok); border-color: var(--ok); color: #06210f; }
.check.current { border-color: var(--accent); color: #fff; background: var(--accent); box-shadow: var(--accent-glow); }
.step.done .step-title { color: var(--muted); }
.step-body { padding: 0 18px 18px 68px; }
.message-box { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }

/* ---------- fields ---------- */

.field-grid { display: grid; grid-template-columns: 220px 1fr auto; }
.field-row > div { padding: 10px 16px; border-top: 1px solid var(--line); display: flex; align-items: center; min-width: 0; }
.field-row:first-of-type > div { border-top: none; }
.field-label { color: var(--muted); }
.field-del { opacity: 0; transition: opacity .15s; }
.field-row:hover .field-del, .field-del:focus { opacity: 1; }
.field-row { display: contents; }

/* ---------- secrets ---------- */

.secret { padding: 16px 18px; }
.secret-grid { display: grid; grid-template-columns: 90px 1fr auto; gap: 6px 12px; align-items: center; margin-top: 10px; font-size: 15px; }
.secret-grid > div > .btn, .secret-grid > div > .row { justify-self: end; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 14px; }

/* ---------- files ---------- */

.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.file-tile { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--panel); position: relative; }
.file-thumb { aspect-ratio: 1; background: var(--panel-2); display: grid; place-items: center; color: var(--faint); font-size: 12px; font-weight: 600; text-transform: uppercase; }
.file-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-meta { padding: 8px 10px; font-size: 13px; }
.file-tile .file-del { position: absolute; top: 6px; right: 6px; opacity: 0; background: rgba(0,0,0,.7); }
.file-tile:hover .file-del { opacity: 1; }
.dropzone { border: 1.5px dashed var(--line-2); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); transition: border-color .15s, background .15s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- timeline ---------- */

.timeline-item { display: flex; gap: 12px; padding: 10px 0; font-size: 14px; }
.timeline-item .ts { color: var(--faint); width: 110px; flex: none; }

/* ---------- modal & toast ---------- */

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 500;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
}

/* ---------- login ---------- */

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; }

/* ---------- mobile ---------- */

@media (max-width: 720px) {
  .topbar { padding: 0 16px; gap: 12px; }
  .brand span { display: none; }
  .nav a { padding: 6px 10px; }
  .page { padding: 20px 16px 80px; }
  .model-progress { display: none; }
  .step-body { padding-left: 16px; }
  .field-grid { grid-template-columns: 1fr auto; }
  .field-grid .field-label { grid-column: 1 / -1; padding-bottom: 0; border-top: 1px solid var(--line); }
  .field-grid .field-label + div { border-top: none; padding-top: 4px; }
  .field-grid .field-label + div + div { border-top: none; }
  .field-del { opacity: 1; }
  .secret-grid { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0; }
  .secret-grid .faint { grid-column: 1 / -1; font-size: 12px; margin-top: 8px; }
  .timeline-item .ts { width: 84px; }
}

@media (max-width: 720px) {
  .page-head + .row .input, .search-input { max-width: none !important; }
  .kbd-hint { display: none; }
  .tabs { -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
}
