/* static/style.css */
:root {
  color-scheme: dark;
  --bg: #05070b;
  --bg-panel: #0b0f14;
  --border: #1a2330;
  --accent: #3ea8ff;
  --accent-soft: rgba(62, 168, 255, 0.18);
  --text: #e3ecff;
  --text-muted: #9bacce;
  --radius: 12px;
  --pad: 10px;
  --transition: 0.14s ease;
  font-size: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at top, #09101a 0, #05070b 50%, #020309 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
}

#toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 10px 12px;
  background: linear-gradient(
    180deg,
    rgba(9, 14, 24, 0.98),
    rgba(9, 14, 24, 0.96),
    rgba(9, 14, 24, 0.9)
  );
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(18px);
}

#toolbar-top {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#toolbar-controls {
  margin-top: 10px;
}

#toolbar-controls[hidden] {
  display: none !important;
}

#toolbar .row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: min(360px, 100%);
}

.field.smallfield {
  min-width: min(220px, 100%);
}

.field .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

input[type="text"],
input[type="search"],
select {
  min-width: 260px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #050913;
  color: var(--text);
  outline: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  font-size: 13.5px;
}

input[type="text"]:focus,
input[type="search"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.btn {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #050913;
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13.5px;
  transition: background var(--transition), border-color var(--transition),
    transform var(--transition), box-shadow var(--transition);
}

.btn.primary {
  background: #1b3657;
  border-color: #3ea8ff;
  box-shadow: 0 0 0 1px var(--accent-soft);
}

.btn.subtle {
  opacity: 0.85;
}

.btn:hover {
  background: #0f1925;
  border-color: var(--accent);
}

.btn.primary:hover {
  background: #22446c;
}

.btn:active {
  transform: scale(0.98);
}

#main {
  padding: 18px 14px;
}

.hint {
  margin: 6px 0;
  color: var(--text-muted);
  max-width: 980px;
}

.hint.small {
  font-size: 12px;
  opacity: 0.85;
}

/* ---------------- TAG PILLS ---------------- */

.row-tags {
  align-items: center;
}

.tag-pills {
  display: flex;
  gap: 8px;
  align-items: center;
  overflow: auto;
  padding: 2px 2px;
  min-height: 36px;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable both-edges;
}

.tag-pills::-webkit-scrollbar {
  height: 8px;
}
.tag-pills::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 999px;
}
.tag-pills::-webkit-scrollbar-track {
  background: transparent;
}

.tag-pill {
  flex: none;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(227,236,255,0.88);
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.tag-pill:hover {
  border-color: rgba(62,168,255,0.45);
  background: rgba(62,168,255,0.10);
}

.tag-pill.active {
  border-color: rgba(62,168,255,0.8);
  background: rgba(62,168,255,0.16);
  box-shadow: 0 0 0 1px rgba(62,168,255,0.10) inset;
  color: #eaf4ff;
}

.tag-pill .count {
  font-size: 11px;
  opacity: 0.85;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.18);
}

.tags-menu-btn {
  padding: 10px 12px;
  min-width: 44px;
}

.tags-menu {
  margin-top: 8px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  background: rgba(6, 9, 19, 0.75);
  box-shadow: inset 0 0 20px rgba(255,255,255,0.03);
}

.tags-menu[hidden] {
  display: none !important;
}

.tags-menu-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ---------------- RECENTS ---------------- */

.row-recents {
  align-items: center;
}

.recent-pills {
  display: flex;
  gap: 8px;
  align-items: center;
  overflow: auto;
  padding: 2px 2px;
  min-height: 34px;
  flex: 1;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable both-edges;
}

.recent-pills::-webkit-scrollbar {
  height: 8px;
}
.recent-pills::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 999px;
}
.recent-pills::-webkit-scrollbar-track {
  background: transparent;
}

.recent-pill {
  flex: none;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(227,236,255,0.88);
  padding: 7px 10px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.recent-pill:hover {
  border-color: rgba(62,168,255,0.45);
  background: rgba(62,168,255,0.10);
}

.recent-pill .server {
  font-size: 11px;
  opacity: 0.8;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.18);
}

/* ---------------- PROJECT SWITCHER ---------------- */

#proj-switcher-overlay {
  position: fixed;
  inset: 0;
  z-index: 16000;
  display: none;
  padding: 14px;
  background: rgba(0,0,0,0.48);
}

#proj-switcher-overlay .ps-panel {
  max-width: min(920px, 96vw);
  margin: 7vh auto 0;
  background: rgba(11, 15, 20, 0.98);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.60), inset 0 0 18px rgba(255,255,255,0.03);
  overflow: hidden;
}

#proj-switcher-overlay .ps-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  background: rgba(20, 30, 48, 0.28);
}

#proj-switcher-overlay .ps-title {
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#proj-switcher-overlay .ps-head-right {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

#proj-switcher-overlay .ps-inputwrap {
  padding: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

#proj-switcher-overlay input.ps-input {
  width: 100%;
  min-width: 0;
}

#proj-switcher-overlay .ps-list {
  max-height: min(62vh, 560px);
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#proj-switcher-overlay .ps-item {
  text-align: left;
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.14);
  color: var(--text);
  padding: 10px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
    transform var(--transition), box-shadow var(--transition);
}

#proj-switcher-overlay .ps-item:hover {
  border-color: rgba(62,168,255,0.45);
  background: rgba(62,168,255,0.10);
}

#proj-switcher-overlay .ps-item.active {
  border-color: rgba(62,168,255,0.82);
  background: rgba(62,168,255,0.16);
  box-shadow: 0 0 0 1px rgba(62,168,255,0.10) inset;
}

#proj-switcher-overlay .ps-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

#proj-switcher-overlay .ps-name {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#proj-switcher-overlay .ps-server {
  flex: none;
  font-size: 11px;
  opacity: 0.85;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(227,236,255,0.85);
}

#proj-switcher-overlay .ps-path {
  margin-top: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  font-size: 12px;
  color: rgba(227, 236, 255, 0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#proj-switcher-overlay .ps-foot {
  padding: 8px 10px 10px;
  border-top: 1px solid rgba(255,255,255,0.08);
  color: rgba(155, 172, 206, 0.95);
  font-size: 12px;
}

/* ---------------- HUB ---------------- */

.hub {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(10, 15, 22, 0.5);
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.03);
}

.hub-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.hub-title {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.hub-empty {
  padding: 12px;
  color: var(--text-muted);
  opacity: 0.9;
}

.hub-errors {
  padding: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  background: rgba(255, 90, 120, 0.06);
  margin-bottom: 10px;
}
.hub-errors .remote-error {
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.15);
  border: 1px solid rgba(255,255,255,0.08);
  margin: 6px 0;
}

.remote-group {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(6, 9, 19, 0.6);
  margin-top: 10px;
  overflow: hidden;
}

.remote-head {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(20, 30, 48, 0.35);
}

.remote-left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.remote-title {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.remote-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.remote-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.remote-error,
.remote-empty {
  padding: 10px;
  color: var(--text-muted);
  opacity: 0.9;
}

.remote-list {
  display: flex;
  flex-direction: column;
}

.proj-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-top: 1px dashed rgba(255, 255, 255, 0.06);
}

.proj-row:first-child {
  border-top: none;
}

.proj-row.missing {
  opacity: 0.6;
}

.proj-left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.proj-line1 {
  display: flex;
  gap: 8px;
  align-items: baseline;
  min-width: 0;
  flex-wrap: wrap;
}

.proj-name {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.proj-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(227,236,255,0.85);
  background: rgba(62,168,255,0.08);
}

.proj-badge.current {
  border-color: rgba(62,168,255,0.22);
  background: rgba(62,168,255,0.10);
}

.proj-badge.server {
  border-color: rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(227,236,255,0.82);
}

.proj-host {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.proj-path {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", monospace;
  font-size: 12px;
  color: rgba(227, 236, 255, 0.78);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.proj-tagsline {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.proj-tag {
  border-radius: 999px;
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: rgba(227,236,255,0.86);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  user-select: none;
}

.proj-tag:hover {
  border-color: rgba(62,168,255,0.45);
  background: rgba(62,168,255,0.10);
}

.proj-tag.active {
  border-color: rgba(62,168,255,0.8);
  background: rgba(62,168,255,0.16);
}

.proj-meta {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.proj-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* star button */
.starbtn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #050913;
  color: rgba(227, 236, 255, 0.9);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.starbtn:hover {
  border-color: var(--accent);
  background: #0f1925;
}
.starbtn.filled {
  border-color: rgba(255, 220, 0, 0.35);
  box-shadow: 0 0 0 1px rgba(255, 220, 0, 0.12);
  color: #ffe8a6;
}

/* tag edit button */
.tagbtn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #050913;
  color: rgba(227, 236, 255, 0.9);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tagbtn:hover {
  border-color: rgba(62,168,255,0.75);
  background: rgba(62,168,255,0.10);
}

/* Tighten hub action buttons */
.proj-actions .btn {
  padding: 9px 12px;
}

@media (max-width: 820px) {
  .proj-row {
    grid-template-columns: 1fr;
    gap: 8px;
    align-items: stretch;
  }
  .proj-actions {
    justify-content: flex-start;
  }
  .proj-meta {
    justify-self: start;
  }
}

@media (max-width: 640px) {
  #toolbar {
    padding: 10px 10px 8px;
  }
  .field {
    min-width: 100%;
  }
  input[type="text"],
  input[type="search"],
  select {
    font-size: 16px; /* critical: no iOS zoom */
    padding: 12px 12px;
    min-width: 100%;
  }
  .btn {
    padding: 12px 14px;
    font-size: 15px;
  }
  .starbtn,
  .tagbtn {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
}
