/* Nova dashboard — clean white + grey sidebar, mirroring Viktor's layout. */

:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e6e6e6;
  --border-strong: #d0d0d0;
  --text: #1a1a1a;
  --text-subtle: #6b6b6b;
  --text-faint: #999;
  --accent: #1a1a1a;
  --accent-hover: #2a2a2a;
  --danger: #c0392b;
  --danger-bg: #fde8e6;
  --connected: #2e7d32;
  --connected-bg: #e7f3e8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --radius: 8px;
  --radius-lg: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- layout ---- */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  padding: 4px 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
}
.brand-logo {
  /* Hard cap so the wide source PNG can't stretch the sidebar.
   * Drop border-radius — the PNG has its own padding/background and
   * rounding it makes the icon look like a clickable button. */
  width: 28px !important;
  height: 28px !important;
  max-width: 28px;
  max-height: 28px;
  object-fit: contain;
  flex: 0 0 auto;
  display: block;
}
.brand-name { line-height: 1; }

.brand-large {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 8px;
}
.signin-logo {
  width: 64px;
  height: 64px;
  max-width: 64px;
  max-height: 64px;
  object-fit: contain;
  margin-bottom: 14px;
  display: inline-block;
}

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-subtle);
  transition: background 0.1s, color 0.1s;
}
.nav-item:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}
.nav-item.active {
  background: #1a1a1a;
  color: #fff;
}
.nav-item.small { font-size: 13px; padding: 6px 12px; }

.nav-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.user-chip {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 8px 4px;
}
.user-chip-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f0e6d8;
  font-weight: 600;
  color: #6b4f2c;
  flex-shrink: 0;
}
.user-chip-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.user-chip-meta { min-width: 0; flex: 1; }
.user-chip-name { font-weight: 600; font-size: 13px; }
.user-chip-email {
  font-size: 12px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main {
  padding: 32px 40px;
  max-width: 1100px;
}

.main-unauth {
  max-width: 480px;
  margin: 80px auto;
  padding: 40px;
}

/* ---- page header ---- */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}
.subtle { color: var(--text-subtle); }
.success-card { border-color: var(--connected); background: #fcfffc; }

.alert-success {
  background: var(--connected-bg);
  color: var(--connected);
  border-color: var(--connected);
}
.alert-success a { text-decoration: underline; }
.connect-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ---- card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-header h2 { font-size: 16px; margin: 0; }
.card-action { font-size: 13px; color: var(--text-subtle); }

.card.danger { border-color: var(--danger); }
.card.danger h2 { color: var(--danger); }

.grid { display: grid; gap: 20px; }
.two-col { grid-template-columns: 1fr 1fr; }

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a32f23; }
.btn-danger-ghost {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger-ghost:hover { background: var(--danger-bg); }
.btn-small { padding: 4px 10px; font-size: 13px; }

.button-row { display: flex; gap: 8px; }

/* ---- sign-in ---- */
.signin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.signin-card .lede {
  color: var(--text-subtle);
  margin: 8px 0 24px;
}
.signin-card .btn {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
}
.signin-help {
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-subtle);
}
.slack-mark {
  width: 18px;
  height: 18px;
  background:
    linear-gradient(45deg, #36C5F0 0 50%, #ECB22E 50% 100%);
  border-radius: 3px;
  display: inline-block;
}

/* ---- alert ---- */
.alert {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 13px;
}

/* ---- integrations ---- */
.integrations-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.search {
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  width: 320px;
  background: var(--surface);
}
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-subtle);
}

.integrations-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: start;
}

.category-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 8px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.category-sidebar-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 6px 10px 10px;
}
.category-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.category-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  color: var(--text-subtle);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.category-item:hover {
  background: var(--bg);
  color: var(--text);
}
.category-item.active {
  background: #1a1a1a;
  color: #fff;
}
.category-count {
  font-size: 12px;
  color: inherit;
  opacity: 0.7;
  background: rgba(255,255,255,0.08);
  padding: 1px 8px;
  border-radius: 999px;
}
.category-item:not(.active) .category-count {
  background: var(--bg);
}

.tab-group {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.tab {
  padding: 8px 14px;
  border: none;
  background: transparent;
  font-size: 13px;
  color: var(--text-subtle);
  cursor: pointer;
}
.tab + .tab { border-left: 1px solid var(--border); }
.tab.active {
  background: #1a1a1a;
  color: #fff;
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  min-height: 200px;
}
.integration-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.integration-card.connected {
  border-color: var(--connected);
  background: #fcfffc;
}
.integration-card-head { display: flex; gap: 12px; align-items: center; }
.integration-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-weight: 700;
  font-size: 14px;
}
.integration-icon img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.integration-name { font-weight: 600; font-size: 14px; }
.integration-desc {
  font-size: 13px;
  color: var(--text-subtle);
  margin: 0;
  min-height: 36px;
}
.integration-row { display: flex; gap: 8px; flex-wrap: wrap; }
.integration-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 13px;
}
.integration-chip img { width: 16px; height: 16px; border-radius: 3px; }

/* ---- files ---- */
.files-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.files-table th,
.files-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.files-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  background: var(--bg);
}
.files-table tbody tr:last-child td { border-bottom: none; }

.file-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.file-list li {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.file-list li:last-child { border-bottom: none; }

.tool-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tool-list li {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfbfb;
}
.tool-name { font-weight: 600; font-size: 14px; }
.tool-desc { color: var(--text-subtle); font-size: 13px; margin-top: 4px; }
.tool-args {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #555;
  word-break: break-word;
}
.integration-icon-inline {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 6px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-admin       { background: #fde8e6; color: var(--danger); }
.badge-member      { background: var(--bg); color: var(--text-subtle); }
.badge-active      { background: #e7f3e8; color: var(--connected); }
.badge-archived    { background: var(--bg); color: var(--text-faint); }

/* Skill editor */
.skill-form .form-row { margin-bottom: 16px; }
.form-label { font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
}
.form-input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.form-input[readonly] { background: var(--bg); color: var(--text-subtle); cursor: not-allowed; }
.form-help { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
/* Inline edit: fields look like text until you hover/focus. */
/* ---- Langfuse-style skill editor ---- */
.skill-editor {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 24px;
  align-items: start;
}
.skill-versions {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}
.skill-versions-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px 10px;
}
.skill-versions-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 600;
}
.skill-version-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.skill-version-row {
  display: block;
  padding: 10px 12px;
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
}
.skill-version-row:hover { background: var(--bg); text-decoration: none; }
.skill-version-row.active { background: var(--bg); border-color: var(--border-strong); }
.skill-version-row-top { display: flex; align-items: center; gap: 8px; }
.skill-version-meta { font-size: 11px; margin-top: 4px; line-height: 1.4; }

.skill-main { min-width: 0; }
.skill-main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 4px;
}
.skill-main-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.skill-name-input {
  font-size: 22px;
  font-weight: 700;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 8px;
  border-radius: var(--radius);
  color: inherit;
  min-width: 0;
  flex: 1;
}
.skill-name-input:hover:not(:disabled) { background: var(--bg); }
.skill-name-input:focus { background: var(--surface); border-color: var(--border-strong); outline: none; }
.skill-name-input:disabled { color: var(--text); opacity: 1; }

.skill-subhead { margin: 0 0 20px 8px; }

.skill-field { margin-bottom: 20px; }
.skill-field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}
.skill-field-help {
  font-size: 13px;
  color: var(--text-subtle);
  margin: 0 0 8px;
  line-height: 1.5;
}
.skill-input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.skill-input:disabled { background: var(--bg); color: var(--text-subtle); }
.skill-body-editor {
  width: 100%;
  min-height: 420px;
  padding: 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
}
.skill-body-editor:read-only { background: var(--bg); }
.skill-danger-row {
  display: flex;
  gap: 8px;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.inline-edit {
  width: 100%;
  padding: 6px 8px;
  margin: 0;
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  color: inherit;
  border-radius: var(--radius);
  transition: background 0.1s, border-color 0.1s;
}
.inline-edit:hover { background: var(--bg); }
.inline-edit:focus {
  background: var(--surface);
  border-color: var(--border-strong);
  outline: none;
}
.inline-edit-h1 {
  font-size: 24px;
  font-weight: 700;
  padding: 4px 8px;
  margin: -4px -8px 0;
}

.alert-info {
  background: #eaf3ff;
  color: #1a4d8c;
  border-color: #b0d0ee;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  max-width: 90vw;
  width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-subtle);
  text-decoration: none;
}
.modal-body { padding: 20px; overflow: auto; flex: 1; }

/* Side-by-side diff modal */
.modal-wide { max-width: 90vw; width: 1000px; }
.diff-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.diff-pane {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.diff-pane-title {
  background: var(--bg);
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border);
}
.diff-pane-body {
  margin: 0;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 60vh;
  overflow: auto;
}
.diff-eq  { color: var(--text); }
.diff-add { background: #e6ffe6; color: #1a6b1a; padding: 0 2px; display: block; }
.diff-del { background: #ffeaea; color: #8c1a1a; padding: 0 2px; display: block; text-decoration: line-through; opacity: 0.85; }

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.form-textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  line-height: 1.55;
  resize: vertical;
  background: var(--surface);
}

.skill-body {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
}

.version-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.version-list li {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--surface);
}
.version-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.version-body summary { cursor: pointer; margin-top: 6px; font-size: 12px; }
.version-body[open] summary { margin-bottom: 8px; }
.badge-admin-small {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #fde8e6;
  color: var(--danger);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

code {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 6px;
  font-size: 0.9em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* ── Memory section ─────────────────────────────────────────────── */
.memory-toolbar { margin: 4px 0 14px; }
.memory-list { display: flex; flex-direction: column; gap: 12px; }
.memory-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 10px);
  padding: 16px 18px;
}
.memory-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.memory-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-subtle, #6b7280);
  letter-spacing: .02em;
}
.memory-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.memory-body {
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.memory-textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  padding: 10px 12px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: var(--radius, 10px);
  resize: vertical;
}
/* Edit form hidden until the card is in .editing state */
.memory-edit-form { display: none; margin-top: 10px; }
.memory-card.editing .memory-edit-form { display: block; }
.memory-card.editing .memory-body { display: none; }

/* ── Built-by-Parlay skills ─────────────────────────────────────── */
.badge-parlay {
  background: #15233b;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
}
