/* vanish — dark harness ui. */

:root {
  --bg: #07090e;
  --rail: #05070a;
  --card: rgba(12, 16, 25, 0.75);
  --line: rgba(255, 255, 255, 0.07);
  --emerald: #00f0b4;
  --cyan: #00d2ff;
  --text: #e6edf3;
  --dim: #8b949e;
  --muted: #484f58;
  --red: #f85149;
  --mono: "jetbrains mono", ui-monospace, sfmono-regular, menlo, monospace;
  --sans: "space grotesk", -apple-system, blinkmacsystemfont, sans-serif;
  --rail-w: 280px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ---- scrollbars ------------------------------------------------------ */
/* default browser scrollbars clash with the dark theme; these keep them
   slim and quiet. firefox gets the shorthand properties, chromium/safari
   get the ::-webkit-scrollbar equivalents. */

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 148, 158, 0.35) transparent;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(139, 148, 158, 0.35);
  border-radius: 9999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 180, 0.55);
  background-clip: padding-box;
}

::-webkit-scrollbar-corner {
  background: transparent;
}

/* ---- optional credential disclosure ---------------------------------- */
/* the vercel fields exist so build-log reading is configurable; they are
   collapsed by default because most sessions never need them. */

.conv-activity {
  display: block;
  font-size: 0.68rem;
  color: var(--emerald);
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.adv-creds {
  margin-top: 0.75rem;
}

.adv-creds summary {
  color: var(--dim);
  font-size: 0.72rem;
  cursor: pointer;
  user-select: none;
  padding: 0.25rem 0;
}

.adv-creds summary:hover {
  color: var(--text);
}

.adv-creds[open] summary {
  margin-bottom: 0.35rem;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  line-height: 1.55;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
}

/* ---- rails ---------------------------------------------------------- */

.rail {
  width: var(--rail-w);
  flex-shrink: 0;
  background: var(--rail);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: width 0.18s ease;
}
.rail-left {
  border-right: 1px solid var(--line);
}
.rail-right {
  border-left: 1px solid var(--line);
}

/* collapsed: the rail shrinks to a slim handle strip. content is hidden,
   the header keeps only the collapse button, and the main column reflows. */
.rail[data-collapsed] {
  width: 44px;
  overflow: hidden;
}
.rail[data-collapsed] .rail-head {
  flex-direction: column;
  gap: 10px;
  padding: 12px 0 10px;
}
.rail[data-collapsed] .rail-head > div,
.rail[data-collapsed] .rail-section {
  display: none;
}
.rail[data-collapsed] .rail-collapse {
  margin: 0 auto;
}

.rail-head {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 16px 14px;
  border-bottom: 1px solid var(--line);
  /* both panels get exactly the same header box: the vanish header carries a
     live build id that can wrap to two lines, which used to make the two
     headers different heights. */
  min-height: 62px;
}
.rail-head > div {
  flex: 1;
  min-width: 0;
}
.rail-title {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.3;
}
.rail-sub {
  font-size: 10px;
  color: var(--emerald);
  font-family: var(--mono);
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* the collapse affordance lives in the header, identical on both rails */
.rail-collapse {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.rail-collapse:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.rail-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rail-section.grow {
  flex: 1;
  min-height: 120px;
  overflow-y: auto;
}

.rail-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.45;
}

label {
  font-size: 11px;
  color: var(--dim);
  margin-top: 4px;
}

input[type="text"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(10, 14, 22, 0.9);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  outline: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: rgba(0, 240, 180, 0.45);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  cursor: pointer;
  color: var(--dim);
}
.toggle input {
  width: auto;
}

.btn {
  margin-top: 8px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
}
.btn:hover {
  background: rgba(255, 255, 255, 0.07);
}
.btn.primary {
  border-color: rgba(0, 240, 180, 0.45);
  background: rgba(0, 240, 180, 0.12);
  color: var(--emerald);
}
.btn.danger {
  border-color: rgba(248, 81, 73, 0.45);
  background: rgba(248, 81, 73, 0.1);
  color: var(--red);
}

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9999px;
  background: rgba(0, 240, 180, 0.15);
  color: var(--emerald);
  font-family: var(--mono);
  font-size: 10px;
  text-align: center;
}

.dirty-list,
.tree {
  font-family: var(--mono);
  font-size: 11.5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dirty-row {
  color: var(--emerald);
}
.file {
  color: var(--dim);
  padding: 2px 4px;
  border-radius: 4px;
  cursor: default;
  word-break: break-all;
}
.file.dirty {
  color: var(--emerald);
}

/* ---- editor pane ----------------------------------------------------- */

.editor-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: var(--bg);
}

.editor-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.editor-path {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.editor-pane textarea {
  flex: 1;
  resize: none;
  border-radius: 0;
  border-left: none;
  border-right: none;
  font-size: 12px;
  line-height: 1.6;
  /* the textarea is the whole pane body, so it needs its own scroll */
  height: auto;
  min-height: 0;
}

.editor-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
}

.editor-foot .btn {
  margin-top: 0;
  padding: 5px 14px;
}

.editor-status {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
}

/* tree rows become clickable affordances */
.tree .file {
  cursor: pointer;
}
.tree .file:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

/* ---- main ----------------------------------------------------------- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.feed {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg.user {
  align-self: flex-end;
  max-width: 620px;
  padding: 9px 14px;
  border: 1px solid rgba(0, 240, 180, 0.45);
  border-radius: 12px 12px 4px 12px;
  background: rgba(0, 240, 180, 0.07);
}
.msg-label {
  font-size: 10px;
  color: var(--emerald);
  letter-spacing: 0.1em;
}
.msg-body {
  white-space: pre-wrap;
  word-break: break-word;
}

.step {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 10px 14px;
}
.step-head {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.stream {
  margin-top: 8px;
}
.stream-label {
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 0.1em;
  margin-bottom: 3px;
}
.stream.reasoning .stream-text {
  color: var(--dim);
  font-style: italic;
  white-space: pre-wrap;
  border-left: 2px solid rgba(0, 210, 255, 0.25);
  padding-left: 10px;
}
.stream.content .stream-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.tool {
  margin-top: 8px;
  border: 1px solid rgba(0, 210, 255, 0.25);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(10, 15, 26, 0.8);
}
.tool.ok {
  border-color: rgba(0, 240, 180, 0.3);
}
.tool.failed {
  border-color: rgba(248, 81, 73, 0.45);
}
.tool-head {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--cyan);
}
.tool.ok .tool-head {
  color: var(--emerald);
}
.tool.failed .tool-head {
  color: var(--red);
}
.tool-args,
.tool-result {
  margin-top: 5px;
  padding: 6px 8px;
  max-height: 220px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--dim);
  background: rgba(0, 0, 0, 0.25);
  border-radius: 5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.note {
  align-self: center;
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid var(--line);
  color: var(--dim);
  font-family: var(--mono);
  font-size: 11px;
}

.commit-card {
  padding: 8px 12px;
  border: 1px solid rgba(0, 240, 180, 0.3);
  border-left: 3px solid var(--emerald);
  border-radius: 8px;
  background: rgba(0, 240, 180, 0.05);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--emerald);
}

.error-card,
.fatal {
  padding: 10px 14px;
  border: 1px solid rgba(248, 81, 73, 0.4);
  border-left: 3px solid var(--red);
  border-radius: 8px;
  background: rgba(248, 81, 73, 0.06);
}
.error-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--red);
  margin-bottom: 4px;
}
.error-body {
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.fatal {
  margin: 12px;
  color: var(--red);
}

/* ---- dock ----------------------------------------------------------- */

.dock {
  border-top: 1px solid var(--line);
  padding: 10px 24px 16px;
  background: rgba(5, 7, 10, 0.9);
}
.dock-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}
.status.running {
  color: var(--emerald);
}
.dock-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.dock-row textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 180px;
  font-family: var(--sans);
  font-size: 13px;
}
.dock-row .btn {
  margin-top: 0;
  height: 40px;
  padding: 0 20px;
}

/* ---- notification centre --------------------------------------------- */
/* update notices live behind a bell FIXED to the bottom-right corner of the
   viewport — beside the harness rail, never inside the prompt container.
   an earlier version mounted it into .dock-status, which read as if it
   belonged to the text input. the dom is mounted by notify.rs itself;
   these rules only dress it. */

.notif-bell {
  /* fixed, not flexed: it does not participate in any container layout */
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 55;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(12, 16, 25, 0.9);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  line-height: 1;
}
.notif-bell::before {
  content: "🔔";
  font-size: 15px;
}
.notif-bell:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(0, 240, 180, 0.35);
}

.notif-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 9999px;
  background: var(--emerald);
  color: #04110c;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 15px;
  text-align: center;
  font-weight: 700;
}

.notif-panel {
  position: fixed;
  right: 20px;
  /* directly above the bell (bottom 20 + height 34 + 10px gap) */
  bottom: 64px;
  z-index: 60;
  width: 340px;
  max-height: 60vh;
  overflow-y: auto;
  border: 1px solid rgba(0, 240, 180, 0.35);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(12, 16, 25, 0.97), rgba(5, 7, 10, 0.97));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
}

.notif-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: none;
}

.notif-empty {
  padding: 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.notif-item {
  position: relative;
  padding: 10px 30px 10px 14px;
  border-bottom: 1px solid var(--line);
}
.notif-item:last-child {
  border-bottom: none;
}

.notif-title {
  font-weight: 600;
  font-size: 12.5px;
  color: var(--emerald);
  margin-bottom: 3px;
}

.notif-body {
  font-size: 12px;
  color: var(--dim);
  white-space: pre-wrap;
  word-break: break-word;
}

.notif-action {
  margin-top: 8px;
  padding: 5px 12px;
  border: 1px solid rgba(0, 240, 180, 0.5);
  border-radius: 6px;
  background: rgba(0, 240, 180, 0.15);
  color: var(--emerald);
  font-family: var(--sans);
  font-size: 11.5px;
  cursor: pointer;
}
.notif-action:hover {
  background: rgba(0, 240, 180, 0.25);
}

.notif-dismiss {
  position: absolute;
  top: 6px;
  right: 6px;
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px;
}
.notif-dismiss:hover {
  color: var(--red);
}

/* ---- ota update banner ---------------------------------------------- */

.ota {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  width: 340px;
  padding: 14px 16px;
  border: 1px solid rgba(0, 240, 180, 0.45);
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(0, 240, 180, 0.12), rgba(12, 16, 25, 0.95));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6);
  animation: ota-in 0.35s ease-out;
  overflow: hidden;
}

@keyframes ota-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ota-title {
  font-weight: 600;
  color: var(--emerald);
  margin-bottom: 6px;
}
.ota-changelog {
  list-style: none;
  margin: 6px 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.ota-changelog li::before {
  content: "· ";
  color: var(--emerald);
}
.ota-footer {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.ota-btn {
  margin-top: 10px;
  width: 100%;
  padding: 7px;
  border: 1px solid rgba(0, 240, 180, 0.5);
  border-radius: 6px;
  background: rgba(0, 240, 180, 0.15);
  color: var(--emerald);
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
}
/* the "later" choice: same affordance, no urgency */
.ota-btn.quiet {
  margin-top: 6px;
  border-color: var(--line);
  background: transparent;
  color: var(--muted);
}
.ota-btn.quiet:hover {
  color: var(--dim);
}

/* the sparkle: a light sweep across the banner announcing something new */
.sparkle::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 30%,
    rgba(255, 255, 255, 0.22) 48%,
    transparent 62%
  );
  transform: translateX(-100%);
  animation: sweep 2.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sweep {
  0% {
    transform: translateX(-100%);
  }
  55%,
  100% {
    transform: translateX(100%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sparkle::after,
  .ota {
    animation: none;
  }
}

/* ---- restored transcript --------------------------------------------- */
/* marks the seam between a previous session's messages and live ones, so a
   reloaded page is honest about where the history came from. */

.restored-divider {
  align-self: center;
  color: var(--cyan);
  border-color: rgba(0, 210, 255, 0.3);
}

.step.restored {
  opacity: 0.75;
}

.tool.restored-call {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  padding: 3px 8px;
  border-left: 2px solid rgba(0, 210, 255, 0.25);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- first-run setup guidance ---------------------------------------- */
/* with no server there is no sign-in, so an unconfigured harness has to
   explain itself or it just looks broken. */

.setup-card {
  padding: 16px 18px;
  border: 1px solid rgba(0, 210, 255, 0.35);
  border-left: 3px solid var(--cyan);
  border-radius: 10px;
  background: rgba(0, 210, 255, 0.05);
}

.setup-title {
  font-weight: 600;
  color: var(--cyan);
  margin-bottom: 8px;
}

.setup-body {
  color: var(--text);
  margin-bottom: 10px;
}

.setup-steps {
  margin: 0 0 4px 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--dim);
  font-size: 12.5px;
}

.setup-steps b {
  color: var(--text);
}

.setup-missing {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: #ffc107;
}

/* pull the eye toward the panel that needs filling in */
.rail-right[data-attention="true"] {
  border-left-color: rgba(0, 210, 255, 0.5);
  box-shadow: inset 3px 0 18px rgba(0, 210, 255, 0.09);
}

/* ---- conversation threads -------------------------------------------- */

.conversations-section {
  max-height: 42vh;
  overflow-y: auto;
}

.btn-new {
  width: 100%;
  border-color: rgba(0, 240, 180, 0.35);
  color: var(--emerald);
  background: rgba(0, 240, 180, 0.08);
}

.btn-quiet {
  width: 100%;
  font-size: 11px;
  color: var(--muted);
  padding: 5px 10px;
}
.btn-quiet:hover {
  color: var(--red);
  border-color: rgba(248, 81, 73, 0.4);
}

.conv-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}

.conv-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--dim);
  font-size: 12px;
}
.conv-row:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.conv-row.active {
  background: rgba(0, 240, 180, 0.08);
  border-color: rgba(0, 240, 180, 0.25);
  color: var(--emerald);
}

.conv-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

.conv-del {
  border: none;
  background: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 0 2px;
  opacity: 0;
}
.conv-row:hover .conv-del {
  opacity: 1;
}
.conv-del:hover {
  color: var(--red);
}
