/* SerenPath Prompt Editor — clean, clinical, attentive */

:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-muted: #f3efe8;
  --border: #e1dbcf;
  --border-strong: #c9c1b1;
  --text: #2c3e40;
  --text-muted: #6e766d;
  --primary: #4a7c8c;
  --primary-hover: #3d6b7a;
  --success: #5a8f5e;
  --warning: #b87333;
  --danger: #a64b3f;
  --pill-active-bg: #d4e5dd;
  --pill-active-fg: #2f5944;
  --diff-add: #e5f3e9;
  --diff-remove: #fbe8e4;
}

* { box-sizing: border-box; }

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand-name { font-weight: 600; font-size: 16px; }
.brand-sep { margin: 0 8px; color: var(--text-muted); }
.brand-tool { color: var(--text-muted); font-size: 14px; }

.header-meta { display: flex; align-items: center; gap: 12px; }

.pill {
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  background: var(--surface-muted);
  color: var(--text-muted);
}
.pill-active {
  background: var(--pill-active-bg);
  color: var(--pill-active-fg);
  font-weight: 500;
}

.auth-status { font-size: 12px; color: var(--text-muted); }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 56px);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px;
}

.sidebar-section { margin-bottom: 24px; }
.sidebar-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin: 0 0 8px 0;
  font-weight: 600;
}

.version-list, .audit-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0 0;
}

.version-list li {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 2px;
  font-size: 13px;
}
.version-list li:hover { background: var(--surface-muted); }
.version-list li.selected { background: var(--pill-active-bg); }
.version-list .v-name { font-weight: 500; }
.version-list .v-active-badge {
  font-size: 10px;
  background: var(--success);
  color: white;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
}
.version-list .v-archived-badge {
  font-size: 10px;
  background: var(--text-muted);
  color: white;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 6px;
}
.version-list .v-date { font-size: 11px; color: var(--text-muted); }
.version-list .v-message {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-list li {
  padding: 6px 0;
  font-size: 11px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.audit-list li:last-child { border-bottom: none; }
.audit-list .audit-action {
  display: inline-block;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
  background: var(--surface-muted);
  color: var(--text);
}
.audit-list .audit-activate { background: var(--success); color: white; }
.audit-list .audit-archive { background: var(--warning); color: white; }
.audit-list .audit-edit { background: var(--primary); color: white; }

.editor {
  overflow-y: auto;
  padding: 24px 32px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
  gap: 16px;
}

.detail-header h2 { margin: 0 0 4px 0; font-size: 22px; }

.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.changelog-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 20px;
}
.changelog-block label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.changelog-block textarea {
  width: 100%;
  border: none;
  background: transparent;
  resize: vertical;
  font: inherit;
  color: var(--text);
  outline: none;
}

.sections-container { display: flex; flex-direction: column; gap: 12px; margin-bottom: 80px; }

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.section-card.modified { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface-muted);
  cursor: pointer;
  user-select: none;
}
.section-header:hover { background: #ece6dc; }
.section-header h4 { margin: 0; font-size: 13px; font-weight: 600; }
.section-header .section-desc { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.section-header .section-meta { font-size: 11px; color: var(--text-muted); display: flex; gap: 10px; align-items: center; }
.section-header .applies-pill {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface);
  color: var(--text-muted);
}
.section-header .modified-dot {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  display: none;
}
.section-card.modified .modified-dot { display: inline-block; }

.section-body { padding: 0; display: none; }
.section-card.open .section-body { display: block; }

.section-body textarea {
  width: 100%;
  border: none;
  padding: 14px;
  font: 13px/1.6 ui-monospace, "SF Mono", Menlo, monospace;
  resize: vertical;
  min-height: 120px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.section-body textarea[readonly] { background: var(--surface-muted); }

.save-bar {
  position: fixed;
  bottom: 0;
  left: 280px;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 10;
}

/* Buttons */
.btn {
  font: inherit;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 8px 14px;
  font-weight: 500;
  font-size: 13px;
  transition: background 0.15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-small { padding: 6px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-muted); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: #e6dfd2; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #4a7d4d; }
.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover:not(:disabled) { background: #9c6029; }

/* Utility */
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.hidden { display: none !important; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-content {
  background: var(--surface);
  border-radius: 12px;
  width: min(800px, 92vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
}
.modal-wide { width: min(1100px, 96vw); }
.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }

.preview-stats { font-size: 11px; color: var(--text-muted); margin-bottom: 8px; display: flex; gap: 16px; }
.preview-output {
  background: var(--surface-muted);
  padding: 16px;
  border-radius: 8px;
  font: 12px/1.55 ui-monospace, "SF Mono", Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 64vh;
  overflow-y: auto;
}

/* Diff */
.diff-section { margin-bottom: 18px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.diff-section-header { padding: 8px 12px; background: var(--surface-muted); font-weight: 600; font-size: 12px; }
.diff-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); }
.diff-cell { background: var(--surface); padding: 12px; font: 12px/1.5 ui-monospace, "SF Mono", Menlo, monospace; white-space: pre-wrap; max-height: 320px; overflow-y: auto; }
.diff-cell.diff-a.changed { background: var(--diff-remove); }
.diff-cell.diff-b.changed { background: var(--diff-add); }
.diff-label { font-size: 10px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; font-family: -apple-system, BlinkMacSystemFont, sans-serif; }

/* Toast */
.toast {
  position: fixed;
  top: 80px;
  right: 24px;
  padding: 12px 18px;
  background: var(--text);
  color: white;
  border-radius: 6px;
  z-index: 200;
  max-width: 320px;
  font-size: 13px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}
.toast.toast-success { background: var(--success); }
.toast.toast-error { background: var(--danger); }
.toast.toast-warning { background: var(--warning); }
