/* Protocol Droid — R2-Rebel Blend Stylesheet */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f0f4f8;
  --bg-grid: #e2e8f0;
  --surface: #ffffff;
  --panel: #e8edf2;
  --ink: #0a1929;
  --ink-soft: #4a5568;
  --ink-dim: #8896a8;
  --accent: #0066cc;
  --accent-bright: #00aaff;
  --accent-deep: #003d7a;
  --green: #00875a;
  --green-bright: #00cc88;
  --border: #b0bec5;
  --border-light: #d0d8e0;
  --shadow: 0 2px 8px rgba(0,50,100,0.06);
  --shadow-hover: 0 4px 16px rgba(0,102,204,0.10);
  --mono: 'SF Mono', 'Courier New', 'Courier', monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
body {
  font-family: var(--sans);
  background: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
header {
  background: var(--ink);
  color: #fff;
  padding: 0 16px;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 2px solid var(--accent-bright);
  position: relative;
  flex-wrap: nowrap;
}
header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--green-bright), var(--accent-bright), transparent);
}
/* Breadcrumb — two-line header: logo on top, location below */
header .breadcrumb {
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--accent-bright);
  cursor: pointer;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
  line-height: 1.2;
}
.header-logo { width: 32px; height: 32px; flex-shrink: 0; display: block; }
header .breadcrumb .crumb-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}
header .breadcrumb .prompt { color: var(--green-bright); font-weight: normal; }
header .breadcrumb:hover { text-decoration: none; }
header .crumb-path {
  font-size: 11px;
  color: var(--ink-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  cursor: pointer;
}

/* Desktop nav — inline */
header nav {
  margin-left: auto;
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  align-items: center;
}
header nav a {
  color: #8896a8;
  text-decoration: none;
  font-size: 12px;
  font-family: var(--mono);
  padding: 6px 12px;
  border: 1px solid transparent;
  transition: all 0.15s;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
header nav a:hover { color: #fff; border-color: rgba(255,255,255,0.15); }
header nav a.active { color: var(--accent-bright); border-color: rgba(0,170,255,0.3); background: rgba(0,170,255,0.08); }

.auth-area { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.auth-area .user-link {
  color: var(--green-bright);
  font-family: var(--mono);
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}
.auth-area .auth-btn {
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: #fff;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
}
.auth-area .auth-btn:hover { background: rgba(255,255,255,0.1); }

/* Hamburger button — hidden on desktop */
.hamburger {
  display: none;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
  margin-left: auto;
  flex-shrink: 0;
}

/* Mobile dropdown panel */
.mobile-panel {
  display: none;
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  background: var(--ink);
  border-bottom: 2px solid var(--accent-bright);
  padding: 12px 16px;
  z-index: 50;
  flex-direction: column;
  gap: 6px;
}
.mobile-panel.open { display: flex; }
.mobile-panel a {
  color: #8896a8;
  text-decoration: none;
  font-size: 14px;
  font-family: var(--mono);
  padding: 10px 14px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.mobile-panel a:hover { color: #fff; background: rgba(255,255,255,0.08); }
.mobile-panel a.active { color: var(--accent-bright); background: rgba(0,170,255,0.08); }
.mobile-panel .mobile-auth { display: flex; gap: 8px; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,0.1); }
.mobile-panel .mobile-auth .auth-btn {
  font-family: var(--mono); font-size: 12px; padding: 6px 12px;
  border: 1px solid rgba(255,255,255,0.2); background: transparent; color: #fff;
  cursor: pointer; border-radius: 4px; white-space: nowrap;
}
.mobile-panel .mobile-auth .auth-btn:hover { background: rgba(255,255,255,0.1); }
.mobile-panel .mobile-auth .user-link {
  color: var(--green-bright); font-family: var(--mono); font-size: 12px; text-decoration: none; white-space: nowrap;
}

/* Main */
.main { max-width: 920px; margin: 0 auto; padding: 24px 16px; }

/* Tagline under header */
.tagline { color: var(--ink-soft); font-size: 14px; margin-bottom: 20px; }

/* Search */
.search-bar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 8px; padding: 8px 14px; margin-bottom: 20px;
}
.search-bar .prompt { font-family: var(--mono); font-size: 13px; color: var(--green); flex-shrink: 0; }
.search-bar input {
  border: none; outline: none; background: transparent;
  font-family: var(--mono); font-size: 13px; color: var(--ink); flex: 1; min-width: 0;
}
.search-bar input::placeholder { color: var(--ink-dim); }

/* Sort bar */
.sort-bar {
  display: flex; align-items: center; gap: 6px; margin-bottom: 16px;
  font-family: var(--mono); font-size: 11px; color: var(--ink-dim);
}
.sort-label { letter-spacing: 0.5px; }
.sort-option {
  padding: 3px 10px; border-radius: 3px; cursor: pointer;
  border: 1px solid transparent; color: var(--ink-soft); transition: all 0.15s;
}
.sort-option:hover { border-color: var(--border-light); }
.sort-option.active { background: var(--panel); color: var(--ink); border-color: var(--border-light); }
.filter-toggle {
  margin-left: auto; padding: 3px 10px; border-radius: 3px; cursor: pointer;
  color: var(--ink-soft); border: 1px solid transparent; transition: all 0.15s;
}
.filter-toggle:hover { border-color: var(--border-light); }
.filter-toggle.active { background: var(--panel); color: var(--ink); border-color: var(--border-light); }

/* Filter panel — collapsed by default */
.filter-panel { display: none; margin-bottom: 16px; }
.filter-panel.open { display: block; }

/* Filters */
.filters { display: flex; gap: 6px; margin-bottom: 24px; flex-wrap: wrap; }
.filter-pill {
  padding: 5px 12px; font-size: 11px; font-family: var(--mono);
  background: var(--surface); border: 1px solid var(--border-light);
  color: var(--ink-soft); cursor: pointer; transition: all 0.15s;
  border-radius: 3px; letter-spacing: 0.5px; white-space: nowrap;
}
.filter-pill:hover { border-color: var(--accent); color: var(--accent); }
.filter-pill.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Protocol grid */
.protocol-grid { display: flex; flex-direction: column; gap: 10px; }
.protocol-pill {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 16px; padding: 14px 20px; display: flex; align-items: flex-start;
  gap: 14px; cursor: pointer; transition: all 0.15s; box-shadow: var(--shadow);
  text-decoration: none; color: inherit;
}
.protocol-pill:hover { border-color: var(--accent); box-shadow: var(--shadow-hover); transform: translateX(2px); text-decoration: none; }
.protocol-pill .icon {
  width: 38px; height: 38px; border-radius: 10px; background: var(--panel);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-family: var(--mono); color: var(--accent);
  flex-shrink: 0; border: 1px solid var(--border-light);
}
.protocol-pill .info { flex: 1; min-width: 0; }
.protocol-pill .info h3 { font-size: 14px; font-weight: bold; margin-bottom: 2px; font-family: var(--mono); word-break: break-word; }
.protocol-pill .info p {
  font-size: 13px; color: var(--ink-soft); font-family: var(--sans);
  word-break: break-word; line-height: 1.4;
}
.protocol-pill .meta { font-family: var(--mono); font-size: 11px; color: var(--ink-dim); text-align: right; flex-shrink: 0; white-space: nowrap; }
.protocol-pill .meta .steps { color: var(--accent); font-weight: bold; }
.protocol-pill.collection {
  background: var(--ink); color: #fff; border-color: var(--accent-deep);
}
.protocol-pill.collection .icon { background: rgba(0,135,90,0.15); border-color: var(--green-bright); color: var(--green-bright); }
.protocol-pill.collection .info p { color: #8896a8; }
.protocol-pill.collection .meta { color: #8896a8; }
.protocol-pill.collection .meta .steps { color: var(--green-bright); }

/* Detail view */
.back-link { color: var(--accent); text-decoration: none; font-size: 12px; font-family: var(--mono); margin-bottom: 20px; display: inline-block; }
.back-link:hover { text-decoration: underline; }

.detail-header {
  background: var(--surface); border-radius: 16px; padding: 24px 20px;
  margin-bottom: 16px; border: 1px solid var(--border-light); box-shadow: var(--shadow);
}
.detail-header .tag-row { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.detail-header .tag {
  font-family: var(--mono); font-size: 10px; padding: 3px 10px; border-radius: 3px;
  background: var(--panel); color: var(--ink-soft); letter-spacing: 0.5px;
}
.detail-header h1 {
  font-size: 22px; font-weight: bold; margin-bottom: 8px; letter-spacing: -0.3px;
  font-family: var(--mono); word-break: break-word;
}
.detail-header .description { font-size: 15px; color: var(--ink-soft); margin-bottom: 16px; font-family: var(--sans); }
.detail-header .source {
  font-family: var(--mono); font-size: 11px; color: var(--ink-dim);
  border-top: 1px solid var(--border-light); padding-top: 12px;
  word-break: break-all;
}
.detail-header .source a { color: var(--accent); text-decoration: none; }
.detail-header .fork-notice {
  font-family: var(--mono); font-size: 11px; color: var(--green);
  background: rgba(0,135,90,0.06); border: 1px solid rgba(0,135,90,0.15);
  border-radius: 4px; padding: 6px 12px; margin-top: 12px; display: inline-block;
}

.detail-section {
  background: var(--surface); border-radius: 16px; padding: 20px;
  margin-bottom: 12px; border: 1px solid var(--border-light); box-shadow: var(--shadow);
}
.detail-section h2 {
  font-size: 12px; font-family: var(--mono); text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--accent); margin-bottom: 16px;
}
.detail-section h2::before { content: '// '; color: var(--ink-dim); }

.step { display: flex; gap: 14px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border-light); }
.step:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.step .number { font-family: var(--mono); font-weight: bold; font-size: 13px; color: var(--green); flex-shrink: 0; min-width: 32px; padding-top: 1px; }
.step .number::before { content: '> '; color: var(--ink-dim); }
.step .content h4 { font-size: 14px; font-weight: bold; margin-bottom: 3px; font-family: var(--mono); word-break: break-word; }
.step .content p { font-size: 13px; color: var(--ink-soft); font-family: var(--sans); word-break: break-word; }
.outcome, .practice { font-size: 14px; line-height: 1.6; font-family: var(--sans); }

/* Buttons */
.actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.btn {
  padding: 9px 18px; border-radius: 8px; font-family: var(--mono); font-size: 12px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  cursor: pointer; transition: all 0.15s; letter-spacing: 0.5px;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-deep); }
.btn.danger { border-color: #c0392b; color: #c0392b; }
.btn.danger:hover { background: #c0392b; color: #fff; }
.btn.add-step { margin: 12px 0; font-size: 12px; color: var(--green); border-color: var(--green); }
.btn.add-step:hover { background: var(--green); color: #fff; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-family: var(--mono); font-size: 12px; color: var(--ink-soft); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border-light); border-radius: 8px;
  font-family: var(--sans); font-size: 14px; color: var(--ink); background: var(--surface);
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,102,204,0.1);
}
.form-group textarea { resize: vertical; }

/* Step editor */
.step-editor {
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 8px; padding: 16px; margin-bottom: 12px;
}
.step-editor .step-num {
  font-family: var(--mono); font-size: 12px; color: var(--green);
  margin-bottom: 10px; font-weight: bold;
}
.step-editor .step-field { margin-bottom: 10px; }
.step-editor .step-field label {
  display: block; font-family: var(--mono); font-size: 11px;
  color: var(--ink-soft); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.5px;
}
.step-editor .step-field input {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border-light);
  border-radius: 6px; font-family: var(--sans); font-size: 14px; color: var(--ink);
  background: var(--surface);
}
.step-editor .step-field input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,102,204,0.1);
}
.step-editor .remove-step {
  font-size: 11px; color: #c0392b; cursor: pointer; background: none;
  border: none; font-family: var(--mono); margin-top: 4px;
}
.step-editor .remove-step:hover { text-decoration: underline; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 200;
  padding: 20px;
}
.modal { background: var(--surface); border-radius: 16px; padding: 28px; max-width: 400px; width: 100%; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }
.modal h2 { font-family: var(--mono); font-size: 18px; margin-bottom: 20px; }
.auth-toggle { margin-top: 16px; font-size: 12px; font-family: var(--mono); color: var(--ink-soft); }
.auth-toggle a { color: var(--accent); cursor: pointer; text-decoration: none; }
.auth-toggle a:hover { text-decoration: underline; }

/* Toast */
.toast {
  position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 24px; border-radius: 8px;
  font-family: var(--mono); font-size: 13px; z-index: 300;
  border: 1px solid var(--accent-bright); max-width: 90vw; text-align: center;
  animation: toast-in 0.3s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; } }

/* Toolbar — search + create button on one line */
.toolbar {
  display: flex; align-items: center; gap: 10px; margin-bottom: 20px;
}
.toolbar .search-bar { flex: 1; margin-bottom: 0; }
.create-btn {
  font-family: var(--mono); font-size: 13px; padding: 8px 16px;
  border: 1px solid var(--accent); color: var(--accent); background: var(--surface);
  border-radius: 8px; cursor: pointer; transition: all 0.15s; letter-spacing: 0.5px;
  white-space: nowrap; flex-shrink: 0;
}
.create-btn:hover { background: var(--accent); color: #fff; }
.create-plus { display: none; }

/* Profile */
.profile-card {
  background: var(--surface); border-radius: 16px; padding: 24px 20px;
  margin-bottom: 16px; border: 1px solid var(--border-light); box-shadow: var(--shadow);
}
.profile-card h2 { font-family: var(--mono); font-size: 20px; margin-bottom: 8px; }
.profile-card .bio { font-size: 14px; color: var(--ink-soft); margin-bottom: 12px; }

/* Collection detail — inverted header to match collection modules */
#view-collection-detail .detail-header {
  background: var(--ink);
  color: #fff;
  border: 2px solid var(--accent-deep);
  box-shadow: 0 4px 12px rgba(0,50,100,0.12);
}
#view-collection-detail .detail-header h1 { color: var(--accent-bright); }
#view-collection-detail .detail-header .description { color: #a0aec0; }
#view-collection-detail .detail-header .source { border-top-color: rgba(255,255,255,0.1); color: #8896a8; }
#view-collection-detail .detail-header .source a { color: var(--accent-bright); }
#view-collection-detail .detail-section {
  border: 2px solid var(--border);
  box-shadow: 0 3px 10px rgba(0,50,100,0.08);
}
#view-collection-detail .detail-section h2 { color: var(--ink); }
#view-collection-detail .detail-section h2::before { content: '// '; color: var(--ink-dim); }

/* Empty state */
.empty { color: var(--ink-dim); font-family: var(--mono); font-size: 13px; padding: 20px; text-align: center; }
.empty a { color: var(--accent); text-decoration: none; }

/* Tag input with chips */
.tag-input-wrapper { position: relative; }
.tag-chips {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
  min-height: 0;
}
.tag-chips:empty { display: none; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--panel); border: 1px solid var(--border-light);
  border-radius: 4px; padding: 4px 10px;
  font-family: var(--mono); font-size: 12px; color: var(--ink);
}
.tag-remove {
  background: none; border: none; cursor: pointer;
  font-size: 14px; color: var(--ink-dim); padding: 0; line-height: 1;
}
.tag-remove:hover { color: #c0392b; }
#tagInput {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border-light);
  border-radius: 8px; font-family: var(--sans); font-size: 14px;
  color: var(--ink); background: var(--surface);
}
#tagInput:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(0,102,204,0.1); }
.tag-suggestions {
  display: none; position: absolute; top: 100%; left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border-light);
  border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 10; max-height: 200px; overflow-y: auto;
}
.tag-suggestion {
  padding: 8px 14px; font-family: var(--mono); font-size: 13px;
  cursor: pointer; color: var(--ink-soft);
}
.tag-suggestion:hover { background: var(--panel); color: var(--accent); }

/* Tags on protocol pills */
.protocol-pill .tag-row { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.protocol-pill .tag {
  font-family: var(--mono); font-size: 10px; padding: 2px 8px;
  border-radius: 3px; background: var(--panel); color: var(--ink-dim);
}

/* Selected protocols list in collection creator */
.selected-list { margin-bottom: 16px; }
.selected-list:empty { display: none; }
.selected-list-header {
  font-family: var(--mono); font-size: 12px; color: var(--green);
  margin-bottom: 8px; font-weight: bold;
}
.selected-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border: 1px solid var(--border-light); border-radius: 8px;
  margin-bottom: 6px; background: var(--surface); transition: all 0.15s;
}
.selected-item:hover { border-color: var(--green); }
.selected-position {
  font-family: var(--mono); font-size: 12px; color: var(--ink-dim);
  flex-shrink: 0; min-width: 20px; text-align: center;
}
.selected-title {
  flex: 1; min-width: 0; font-size: 13px; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.selected-move {
  background: none; border: 1px solid var(--border-light); border-radius: 4px;
  cursor: pointer; font-size: 10px; color: var(--ink-dim); padding: 2px 6px; line-height: 1;
}
.selected-move:hover { border-color: var(--accent); color: var(--accent); }
.selected-remove {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--ink-dim); padding: 0 4px; line-height: 1;
}
.selected-remove:hover { color: #c0392b; }

/* Protocol picker for collections — click to select, highlight when selected */
.picker-pill { cursor: pointer; transition: all 0.15s; }
.picker-pill:hover { border-color: var(--accent); transform: none; }
.picker-pill.selected { border-color: var(--green); background: rgba(0,135,90,0.06); }
.picker-pill.selected:hover { border-color: var(--green-bright); }

/* Mobile breakpoint */
@media (max-width: 640px) {
  /* Hide desktop nav and auth, show hamburger */
  header nav { display: none; }
  .auth-area { display: none; }
  .hamburger { display: block; }

  /* Create button shows just + on mobile */
  .create-text { display: none; }
  .create-plus { display: inline; }

  .main { padding: 16px 12px; }

  /* Protocol pills: info takes full width, meta goes below */
  .protocol-pill { flex-direction: column; align-items: stretch; padding: 12px 14px; gap: 6px; }
  .protocol-pill .info { width: 100%; }
  .protocol-pill .meta { text-align: left; display: flex; gap: 12px; align-items: center; }
  .protocol-pill .meta .steps { }
  .protocol-pill .meta > div:not(.steps) { font-size: 10px; }

  .detail-header, .detail-section { padding: 16px 14px; border-radius: 12px; }
}