:root {
  --bg: #0b0f14;
  --panel: #121820;
  --panel-hover: #182030;
  --text: #e8edf5;
  --muted: #8b9bb3;
  --accent: #3d8bfd;
  --border: #243044;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --danger: #e85d5d;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(61, 139, 253, 0.18), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(120, 80, 255, 0.12), transparent 55%),
    var(--bg);
}
body.theme-rose {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(232, 93, 150, 0.16), transparent 60%),
    radial-gradient(900px 500px at 90% 0%, rgba(180, 80, 200, 0.1), transparent 55%),
    var(--bg);
}
.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}
header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* Big chat entry under header (always visible) */
.chat-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin: 0 0 1.5rem;
  padding: 0.9rem 1.1rem;
  border-radius: 14px;
  border: 1px solid rgba(61, 139, 253, 0.45);
  background: linear-gradient(90deg, rgba(61, 139, 253, 0.18), rgba(61, 139, 253, 0.05));
  box-shadow: var(--shadow);
}
.chat-cta.stacy {
  border-color: rgba(232, 122, 168, 0.5);
  background: linear-gradient(90deg, rgba(232, 122, 168, 0.22), rgba(180, 80, 200, 0.08));
}
.chat-cta .chat-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 1.35rem;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1.05rem;
  text-decoration: none;
  color: #fff;
  background: #3d8bfd;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(61, 139, 253, 0.35);
}
.chat-cta.stacy .chat-cta-btn {
  background: #d4568a;
  color: #1a0a12;
  box-shadow: 0 4px 14px rgba(212, 86, 138, 0.35);
}
.chat-cta .chat-cta-btn:hover { filter: brightness(1.08); }
.chat-cta .chat-cta-note {
  color: var(--muted);
  font-size: 0.9rem;
  flex: 1;
  min-width: 12rem;
}
.layout-sidebar .chat-cta {
  margin-bottom: 1.25rem;
}
h1 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  letter-spacing: -0.03em;
}
.sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}
.header-meters {
  display: flex;
  align-items: flex-end;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.clock {
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.clock .time {
  font-size: 1.6rem;
  color: var(--text);
  font-weight: 600;
}
.badge {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.75rem;
  color: #9fd0ff;
  background: rgba(61, 139, 253, 0.08);
}
.theme-rose .badge {
  color: #ffb8d0;
  background: rgba(232, 93, 150, 0.1);
}
section { margin-bottom: 2rem; }
.section-title {
  margin: 0 0 0.9rem;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.85rem;
}
.card-wrap {
  position: relative;
}
.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 0.75rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  height: 100%;
}
.card:hover {
  transform: translateY(-2px);
  background: var(--panel-hover);
  border-color: #35507a;
}
.card-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: var(--danger);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.card-wrap:hover .card-remove,
.card-wrap:hover .card-edit { opacity: 1; }
.card-edit {
  position: absolute;
  top: 6px;
  right: 32px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.55);
  color: var(--accent);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.card-wrap:has(.card-remove) .card-edit { right: 32px; }
.card-wrap:not(:has(.card-remove)) .card-edit { right: 6px; }
.edit-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.65);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.edit-modal {
  width: min(420px, 100%);
  padding: 1.25rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel);
  display: grid;
  gap: 0.75rem;
}
.edit-modal h3 {
  margin: 0;
  font-size: 1rem;
}
.edit-modal label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.edit-modal input {
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0a0e13;
  color: var(--text);
  font-size: 0.9rem;
}
.edit-modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.25rem;
}
.edit-modal-actions button {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-weight: 600;
}
.edit-cancel {
  background: transparent;
  color: var(--muted);
}
.edit-save {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}
.theme-rose .edit-save { background: #d4568a; }
.edit-modal-status {
  margin: 0;
  font-size: 0.82rem;
  min-height: 1.1em;
}
.edit-modal-status.ok { color: #7ddea8; }
.edit-modal-status.err { color: var(--danger); }
.icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #0a0e13;
  border: 1px solid #2a3548;
}
.icon svg { width: 26px; height: 26px; display: block; }
.name {
  text-align: center;
  font-size: 0.88rem;
  line-height: 1.25;
  font-weight: 600;
}
.host {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
  word-break: break-all;
}
.add-panel {
  margin-top: 2rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.add-panel h2 {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 600;
}
.add-panel p.hint {
  margin: 0 0 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}
.add-form {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr auto;
  gap: 0.65rem;
  align-items: end;
}
@media (max-width: 700px) {
  .add-form { grid-template-columns: 1fr; }
}
.add-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.78rem;
  color: var(--muted);
}
.add-form input, .add-form select {
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0a0e13;
  color: var(--text);
  font-size: 0.9rem;
}
.add-form button {
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.theme-rose .add-form button { background: #d4568a; }
.add-form button:hover { filter: brightness(1.08); }

/* Stacy → Edward message panel */
.message-edward {
  border: 1px solid rgba(232, 93, 150, 0.35);
  background: linear-gradient(180deg, rgba(232, 93, 150, 0.08), transparent 70%);
}
/* Edward → Stacy one-shot */
.message-stacy {
  border: 1px solid rgba(61, 139, 253, 0.4);
  background: linear-gradient(180deg, rgba(61, 139, 253, 0.1), transparent 70%);
}
.message-stacy a { color: #8bb8ff; }
/* Banner on Stacy favorites when Edward messaged */
.edward-banner {
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(61, 139, 253, 0.45);
  background: rgba(30, 50, 90, 0.95);
  color: var(--text);
  display: none;
}
.edward-banner.show { display: block; }
.edward-banner strong { color: #9ec5ff; }
.edward-banner .banner-actions { margin-top: 0.5rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.edward-banner button {
  border: none; border-radius: 8px; padding: 0.4rem 0.75rem; cursor: pointer; font-weight: 600;
  background: #3d8bfd; color: #fff;
}
.edward-banner button.secondary { background: #2a3548; color: var(--text); }
.edward-banner .banner-body { white-space: pre-wrap; margin-top: 0.35rem; }
.msg-form {
  grid-template-columns: 1fr 1fr;
}
.msg-form .msg-body {
  grid-column: 1 / -1;
}
.msg-form textarea {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0e141c;
  color: var(--text);
  padding: 0.65rem 0.75rem;
  font: inherit;
  resize: vertical;
  min-height: 72px;
}
.msg-form button {
  grid-column: 1 / -1;
  justify-self: start;
}
.add-status.ok { color: #8fd4a0; }
.add-status.err { color: #f0a0a0; }
@media (max-width: 700px) {
  .msg-form { grid-template-columns: 1fr; }
}
.add-status {
  margin-top: 0.65rem;
  font-size: 0.82rem;
  min-height: 1.2em;
}
.add-status.ok { color: #7ddea8; }
.add-status.err { color: var(--danger); }
footer {
  margin-top: 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}
footer code {
  color: #b8c7dc;
  background: #10151d;
  padding: 0.1rem 0.35rem;
  border-radius: 6px;
}
.nav-other {
  margin-top: 0.5rem;
  font-size: 0.82rem;
}
.nav-other a { color: var(--accent); }
.theme-rose .nav-other a { color: #f08bb8; }

/* Edward: dashboard left, links right */
body.layout-sidebar .wrap {
  max-width: 1680px;
}
.page-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 300px;
  gap: 1.25rem;
  align-items: start;
}
.tracker-sidebar {
  position: sticky;
  top: 1.25rem;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.tracker-sidebar h2 {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.page-main {
  min-width: 0;
}
.links-sidebar {
  position: sticky;
  top: 1.25rem;
  max-height: calc(100vh - 2.5rem);
  overflow-y: auto;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.links-sidebar section {
  margin-bottom: 1.15rem;
}
.links-sidebar section:last-of-type {
  margin-bottom: 0.75rem;
}
.links-sidebar .section-title {
  margin-bottom: 0.55rem;
  font-size: 0.72rem;
}
.links-sidebar .grid {
  grid-template-columns: 1fr;
  gap: 0.45rem;
}
.links-sidebar .card {
  display: grid;
  grid-template-columns: 40px 1fr;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 0.6rem;
  row-gap: 0.08rem;
  padding: 0.5rem 0.55rem;
}
.links-sidebar .icon {
  grid-row: 1 / 3;
  width: 40px;
  height: 40px;
  border-radius: 10px;
}
.links-sidebar .icon svg {
  width: 22px;
  height: 22px;
}
.links-sidebar .name {
  text-align: left;
  font-size: 0.8rem;
  align-self: end;
  line-height: 1.2;
}
.links-sidebar .host {
  text-align: left;
  font-size: 0.66rem;
  align-self: start;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.links-sidebar .card-remove {
  top: 4px;
  right: 4px;
}
.links-sidebar .card-edit {
  top: 4px;
  right: 30px;
}
.links-sidebar .card-wrap:not(:has(.card-remove)) .card-edit {
  right: 4px;
}
.links-sidebar .add-panel {
  margin-top: 0.85rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a0e13;
}
.links-sidebar .add-panel h2 {
  font-size: 0.88rem;
  margin-bottom: 0.65rem;
}
.links-sidebar .add-panel p.hint {
  font-size: 0.72rem;
  margin-bottom: 0.65rem;
}
.links-sidebar .add-form {
  grid-template-columns: 1fr;
  gap: 0.5rem;
}
.links-sidebar .add-form button {
  width: 100%;
}
@media (max-width: 1200px) {
  .page-layout {
    grid-template-columns: minmax(0, 1fr) 300px;
  }
  .tracker-sidebar {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
    overflow: visible;
  }
}
@media (max-width: 1024px) {
  .page-layout {
    grid-template-columns: 1fr;
  }
  .links-sidebar,
  .tracker-sidebar {
    position: static;
    max-height: none;
    overflow: visible;
  }
}