:root {
  --bg: #0d1015;
  --panel: #11141a;
  --panel-2: #161a22;
  --line: #232833;
  --text: #e8eaed;
  --muted: #7d8494;
  --green: #3ddc4a;
  --amber: #f59e0b;
  --red: #ef5350;
  --out: #1c3a2a;
  --in: #1b2230;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--green); }

/* --- login ---------------------------------------------------------------- */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
}
.login-card h1 { margin: 0 0 4px; font-size: 18px; }
.login-card p.sub { margin: 0 0 22px; color: var(--muted); font-size: 12px; }
.login-card label { display: block; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.login-card input {
  width: 100%;
  margin-bottom: 16px;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.login-card input:focus { outline: none; border-color: var(--green); }
button.primary {
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 6px;
  background: var(--green);
  color: #06210a;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.primary:disabled { opacity: .55; cursor: default; }
.error { margin-top: 14px; color: var(--red); font-size: 12px; min-height: 16px; }

/* --- shell ---------------------------------------------------------------- */
.shell { display: flex; flex-direction: column; height: 100vh; }

header.top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
header.top h1 { margin: 0; font-size: 15px; font-weight: 600; white-space: nowrap; }
header.top .spacer { flex: 1; }
header.top .who { color: var(--muted); font-size: 12px; }

select, input[type="search"] {
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}
select:focus, input[type="search"]:focus { outline: none; border-color: var(--green); }
input[type="search"] { min-width: 260px; }

button.ghost {
  padding: 7px 11px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
button.ghost:hover { color: var(--text); border-color: var(--muted); }

.stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 16px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.stats b { color: var(--text); font-weight: 600; }

/* --- panes ---------------------------------------------------------------- */
.panes { display: flex; flex: 1; min-height: 0; }

.list {
  width: 380px;
  flex: 0 0 380px;
  border-right: 1px solid var(--line);
  overflow-y: auto;
  background: var(--panel);
}
.detail { flex: 1; overflow-y: auto; padding: 18px 22px 60px; min-width: 0; }

.row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.row:hover { background: var(--panel-2); }
.row.active { background: var(--panel-2); box-shadow: inset 3px 0 0 var(--green); }
.row .line1 { display: flex; align-items: baseline; gap: 8px; }
.row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .when { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.row .snippet {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row .meta { margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  font-size: 10px;
  letter-spacing: .3px;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tag.unread { color: var(--green); border-color: #24512a; }
.tag.incomplete { color: var(--amber); border-color: #5a4415; }
.tag.never { color: var(--red); border-color: #5c2a28; }
.tag.blocked { color: var(--red); border-color: #5c2a28; }
.tag.account { color: #8ab4f8; border-color: #26364f; }

/* --- conversation --------------------------------------------------------- */
.thread-head { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 18px; }
.thread-head h2 { margin: 0 0 6px; font-size: 17px; }
.thread-head .facts { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }

.notice {
  margin: 0 0 18px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #5a4415;
  background: #221a08;
  color: #f0c674;
  font-size: 12px;
}

.msg { display: flex; margin-bottom: 12px; }
.msg.out { justify-content: flex-end; }
.msg .bubble {
  max-width: min(640px, 78%);
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--in);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg.out .bubble { background: var(--out); border-color: #24512a; }
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.msg .foot { margin-top: 5px; font-size: 11px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.msg.hit .bubble { box-shadow: 0 0 0 2px var(--amber); }
mark { background: #6b5310; color: #ffe9a8; border-radius: 2px; padding: 0 1px; }

.daybreak {
  text-align: center;
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.empty { color: var(--muted); padding: 40px 10px; text-align: center; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 12px; }

/* --- narrow screens -------------------------------------------------------
   Two side-by-side panes do not fit on a phone, and the whole point of this
   being a site rather than an extension page is that it opens anywhere. Below
   this width the list and the conversation take turns instead. */
.back { display: none; }

@media (max-width: 860px) {
  header.top { gap: 8px; padding: 10px 12px; }
  header.top h1 { font-size: 14px; }
  header.top .who { display: none; }
  input[type="search"] { flex: 1 1 100%; min-width: 0; order: 5; }
  .stats { gap: 10px; padding: 7px 12px; font-size: 11px; }

  .list { flex: 1 1 auto; width: auto; border-right: 0; }
  .detail { display: none; padding: 14px 14px 50px; }

  .panes.viewing .list { display: none; }
  .panes.viewing .detail { display: block; flex: 1 1 auto; }

  .back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
  }
  .msg .bubble { max-width: 90%; }
}

/* Who was signed in when a message went out. */
.tag.operator { color: #d7a3ff; border-color: #43305c; }
.tag.operator.self { color: #f0d9ff; border-color: #7a52a8; background: #2a1c3d; }
.msg .who .by { color: #d7a3ff; }
.msg .who .by.self { color: #f0d9ff; font-weight: 600; }
.msg .who .by.muted { color: #6b7280; font-style: italic; }
