/* Dark theme — keeps the brand's typographic restraint (no rounded
   corners, no gradients, ruled hierarchy) but inverts to warm dark.
   This is a private session-manager surface, not the public blog —
   the no-dark-mode rule lives with the brand, not here. */
:root {
  --bg:        #15120f;   /* deepest — page */
  --bg-elev:   #1e1b18;   /* cards / topbar */
  --bg-elev-2: #26221e;   /* hover / subtle inset */
  --fg:        #ece7df;   /* warm paper-tone text */
  --fg-muted:  #8a8278;   /* slate */
  --rule:      #38322c;   /* hairline borders */
  --subtle:    #2a2520;   /* hover wash */
  --code-bg:   #1a1714;
  --enamel-blue:  #6694c4;
  --enamel-red:   #d65c50;
  --enamel-green: #6cb088;
  --enamel-amber: #d8a35a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
}
input, select, textarea { color-scheme: dark; }

.hidden { display: none !important; }
.muted { color: var(--fg-muted); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--rule);
}
.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--fg);
}
.actions { display: flex; gap: 0.5rem; }
.actions button {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--fg);
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0;
}
.actions button:hover { background: var(--bg-elev-2); }
.actions button:active { background: var(--subtle); }

main { padding: 1rem; max-width: 720px; margin: 0 auto; }

section { margin-bottom: 1.5rem; }
section h2 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 0.25rem;
}

.list { display: flex; flex-direction: column; gap: 0.5rem; }
.empty {
  color: var(--fg-muted);
  font-style: italic;
  padding: 0.75rem 0.25rem;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  padding: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 64px;
}
.card:hover { background: var(--bg-elev-2); }
.card:active { background: var(--subtle); }
.card .body { min-width: 0; flex: 1; }
.card .title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--fg);
}
.card .meta {
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-family: 'Courier Prime', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .preview {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-top: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .actions-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex-shrink: 0;
}
.card .actions-cell button {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--fg);
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
  min-width: 64px;
  min-height: 32px;
}
.card .actions-cell button:hover { background: var(--bg-elev-2); }
.card .actions-cell button.danger { color: var(--enamel-red); }
.card.protected .actions-cell button.danger { display: none; }
@media (min-width: 480px) {
  .card .actions-cell { flex-direction: row; }
  .card .actions-cell button { min-height: 36px; }
}
.card .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.dot.online { background: var(--enamel-green); }
.dot.idle   { background: var(--fg-muted); }
.dot.bad    { background: var(--enamel-red); }

/* Filters — single horizontal row, mobile-first.
   Search flexes; selects shrink to content; hidden-pill clings to the
   right and is only rendered when there are hidden conversations to
   surface. Auto-applied on change/input — no confirm button. */
.filters {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
  min-width: 0;
}
.filters > * {
  height: 38px;
  font-size: 0.85rem;
  line-height: 1;
}
.filters input[type="search"] {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 0.7rem;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  color: var(--fg);
  font-family: 'Source Serif 4', Georgia, serif;
}
.filters input[type="search"]::placeholder { color: var(--fg-muted); }
.filters input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 14px; height: 14px;
  background:
    linear-gradient(45deg, transparent 6px, var(--fg-muted) 6px, var(--fg-muted) 8px, transparent 8px),
    linear-gradient(-45deg, transparent 6px, var(--fg-muted) 6px, var(--fg-muted) 8px, transparent 8px);
  cursor: pointer;
}
.filters select {
  flex: 0 0 auto;
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  color: var(--fg);
  padding: 0 1.5rem 0 0.6rem;
  font-family: 'Courier Prime', monospace;
  font-size: 0.78rem;
  cursor: pointer;
  /* Custom chevron — the OS arrow clashes with the dark theme. */
  appearance: none;
  -webkit-appearance: none;
  background-image:
    linear-gradient(45deg,  transparent 50%, var(--fg-muted) 50%),
    linear-gradient(-45deg, transparent 50%, var(--fg-muted) 50%);
  background-position:
    calc(100% - 11px) calc(50% + 1px),
    calc(100% - 7px)  calc(50% + 1px);
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.filters input[type="search"]:focus,
.filters select:focus {
  outline: none;
  border-color: var(--enamel-amber);
}

/* Pager — Prev / Page X of Y / Next, centered. */
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.25rem 0;
  font-size: 0.85rem;
  font-family: 'Courier Prime', monospace;
  color: var(--fg-muted);
}
.pager.hidden { display: none; }
.pager-btn {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--fg);
  min-width: 84px;
  height: 44px;
  padding: 0 0.9rem;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  white-space: nowrap;
}
.pager-btn:hover:not(:disabled) { background: var(--bg-elev-2); }
.pager-btn:disabled {
  color: var(--rule);
  border-color: var(--rule);
  cursor: not-allowed;
}
.pager-pos { color: var(--fg); white-space: nowrap; }
.pager-pos #page-current { color: var(--enamel-amber); }

/* Modal */
.modal {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal.hidden { display: none; }
.modal-card {
  background: var(--bg-elev);
  border: 1px solid var(--rule);
  padding: 1.25rem;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h3 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--fg);
}
.modal-card p { margin: 0 0 0.75rem; color: var(--fg-muted); }
.modal-card label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--fg-muted);
}
.modal-card input, .modal-card select {
  width: 100%;
  padding: 0.5rem;
  margin-top: 0.25rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--fg);
}
.modal-card input:focus, .modal-card select:focus {
  outline: none;
  border-color: var(--enamel-amber);
}
.modal-card code {
  background: var(--code-bg);
  border: 1px solid var(--rule);
  padding: 0.05rem 0.3rem;
  font-family: 'Courier Prime', monospace;
  font-size: 0.85em;
}
.modal-buttons {
  display: flex; gap: 0.5rem; justify-content: flex-end;
  margin-top: 1rem;
}
.modal-buttons button {
  padding: 0.5rem 1rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  color: var(--fg);
  cursor: pointer;
  min-height: 44px;
}
.modal-buttons button:hover { background: var(--bg-elev-2); }
.modal-buttons button.primary {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  color: var(--fg);
  border: 1px solid var(--rule);
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  z-index: 200;
  max-width: 90vw;
}
.toast.hidden { display: none; }
.toast.error {
  background: var(--enamel-red);
  border-color: var(--enamel-red);
  color: #fff;
}

/* Spawn overlay */
.overlay {
  position: fixed; inset: 0;
  background: rgba(15, 13, 11, 0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 150;
}
.overlay.hidden { display: none; }
.overlay-card {
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  gap: 1rem;
  padding: 2rem;
  color: var(--fg);
}
.spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--rule);
  border-top-color: var(--enamel-amber);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#overlay-msg { color: var(--fg-muted); }
#btn-overlay-cancel {
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--fg);
  padding: 0.5rem 1rem;
  cursor: pointer;
  margin-top: 0.5rem;
  min-height: 44px;
}
#btn-overlay-cancel:hover { background: var(--bg-elev-2); }

/* Checkbox label */
label.checkbox {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
}
label.checkbox input { width: auto; margin-top: 0; }

/* Health strip */
.health-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
  font-family: 'Courier Prime', monospace;
  font-size: 0.78rem;
  color: var(--fg-muted);
  cursor: pointer;
  user-select: none;
}
.health-strip .svc {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}
.health-strip .svc .dot { width: 7px; height: 7px; }
.health-strip .svc.ok { color: var(--fg); }
.health-strip .svc.bad { color: var(--enamel-red); }
.health-strip .metric { color: var(--fg); }
.health-strip .metric.warn { color: var(--enamel-red); }
.health-strip .muted { color: var(--fg-muted); font-style: italic; }
.health-strip .sep { color: var(--rule); }

/* Card title vs tmux-name two-line layout */
.card .subtitle {
  font-size: 0.8rem;
  color: var(--fg-muted);
  font-family: 'Courier Prime', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.15rem;
}
