/* Verity colors: black and blue. These are stand-ins until the exact logo
   values are supplied; change them here and everything follows. */
:root {
  --brand-black: #0b0d12;
  --brand-blue: #1f6bff;
  --brand-blue-dark: #1450c8;
  --brand-tint: #e6eeff;

  --ground: #f2f3f5;
  --panel: #ffffff;
  --text: #14161b;
  --muted: #5d6470;
  --line: #e1e4e9;

  /* Reserved for check status, always paired with a word or icon. */
  --pass: #157a3c;
  --pass-bg: #e5f5ea;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --block: #b42318;
  --block-bg: #fde8e6;

  --radius: 12px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); min-height: 100vh; }
button, input, textarea { font: inherit; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 24px; background: var(--brand-black); color: #fff;
}
.brand { font-weight: 800; font-size: 20px; letter-spacing: 0.02em; }
.brand-xr { color: var(--brand-blue); margin-left: 2px; }
.topbar h1 { font-size: 16px; font-weight: 500; margin: 0; color: #c9ced8; }
.topbar-meta { margin-left: auto; display: flex; gap: 16px; font-size: 14px; color: #c9ced8; }
#queue-count { color: #fff; font-weight: 600; }

.notice {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 10;
  margin: 0; max-width: calc(100% - 32px); font-size: 14px;
}
.notice:not(:empty) { padding: 10px 16px; border-radius: 8px; background: var(--brand-black); color: #fff; box-shadow: 0 4px 16px rgb(0 0 0 / 0.18); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 360px;
  gap: 16px; padding: 16px 24px;
  height: calc(100vh - 56px);
}
.panel { background: var(--panel); border-radius: var(--radius); padding: 16px; overflow: auto; position: relative; }
.panel-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 12px; display: flex; justify-content: space-between; }
.muted { color: var(--muted); font-weight: 400; }
.hint { font-size: 12px; color: var(--muted); margin: 12px 0 0; }
.empty-state { color: var(--muted); padding: 24px 0; text-align: center; list-style: none; }
.error { color: var(--block); }

/* ---------- Segments ---------- */
.segment-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.segment {
  width: 100%; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left; color: var(--text);
}
.segment:not(.active):hover:not(:disabled) { background: var(--ground); }
.segment.active { background: var(--brand-black); color: #fff; }
.segment:disabled { cursor: not-allowed; opacity: 0.6; }
.count { min-width: 26px; padding: 2px 8px; border-radius: 999px; background: var(--brand-tint); color: var(--brand-blue-dark); font-size: 13px; font-weight: 600; text-align: center; }
.segment.active .count { background: var(--brand-blue); color: #fff; }

/* ---------- Message list ---------- */
.bulk-bar {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 10px; margin-bottom: 8px; border-radius: 8px; background: var(--brand-tint); font-size: 14px;
}
.bulk-bar.empty { background: var(--ground); color: var(--muted); }
.bulk-bar label { display: flex; gap: 8px; align-items: center; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 8px; border-bottom: 1px solid var(--line); border-radius: 8px; }
.row.selected { background: var(--brand-tint); box-shadow: inset 3px 0 0 var(--brand-blue); }
.row.reviewed { opacity: 0.6; }
.bulk-check { margin-top: 4px; }
.row-main { flex: 1; min-width: 0; border: 0; background: none; padding: 0; text-align: left; cursor: pointer; color: inherit; }
.row-main:disabled { cursor: not-allowed; }
.row-top { display: flex; align-items: center; gap: 8px; }
.row-name { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-line { display: block; margin-top: 4px; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; background: var(--brand-black); color: #fff; }
.channel-linkedin { background: var(--brand-blue); }
.panel-list.locked .rows, .panel-list.locked .bulk-bar { opacity: 0.45; }
.lock-note { position: sticky; bottom: 0; margin-top: 12px; padding: 10px; border-radius: 8px; background: var(--brand-black); color: #fff; font-size: 13px; text-align: center; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge-ready { background: var(--pass-bg); color: var(--pass); }
.badge-warning { background: var(--warn-bg); color: var(--warn); }
.badge-blocking { background: var(--block-bg); color: var(--block); }
.badge-done { background: var(--ground); color: var(--muted); }

/* ---------- Message detail ---------- */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.detail-title { margin: 0; font-size: 20px; }
.detail-head p { margin: 4px 0 0; font-size: 14px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card-title { font-size: 14px; margin: 0 0 10px; }
.message .subject { margin: 0 0 12px; font-weight: 600; }
.body { white-space: pre-wrap; line-height: 1.6; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.subject .field-label { display: inline; margin-right: 6px; }
.message.editing { border-color: var(--brand-blue); box-shadow: 0 0 0 3px var(--brand-tint); }
.edit-subject, .edit-body, .reject-form textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 12px; color: var(--text);
}
.edit-body { min-height: 260px; line-height: 1.6; resize: vertical; }
.edit-subject:focus, .edit-body:focus, .reject-form textarea:focus { outline: 2px solid var(--brand-blue); outline-offset: 1px; }

mark { background: none; color: inherit; }
mark.tailored { background: var(--brand-tint); color: var(--brand-blue-dark); border-radius: 3px; padding: 0 1px; }
mark.issue { text-decoration: underline wavy var(--block); text-underline-offset: 3px; }

.contact-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 0; }
.contact-grid div { padding: 8px 10px; border-radius: 8px; background: var(--ground); }
.contact-grid div.used { background: var(--brand-tint); }
.contact-grid dt { font-size: 12px; color: var(--muted); }
.contact-grid dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.contact-grid div.used dd { color: var(--brand-blue-dark); }

.checks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.check-pass .check-icon { background: var(--pass-bg); color: var(--pass); }
.check-warning .check-icon { background: var(--warn-bg); color: var(--warn); }
.check-block .check-icon { background: var(--block-bg); color: var(--block); }
.check-word { font-size: 12px; font-weight: 600; margin-left: 4px; }
.check-pass .check-word { color: var(--pass); }
.check-warning .check-word { color: var(--warn); }
.check-block .check-word { color: var(--block); }

.reject-form { border: 1px solid var(--block); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; background: #fffafa; }
.reject-form textarea { min-height: 80px; }
.reject-form fieldset { border: 0; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; font-size: 14px; }

.actions { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 12px; }
.btn { padding: 9px 18px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 600; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--brand-black); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-primary { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-blue-dark); border-color: var(--brand-blue-dark); }
.btn-danger { color: var(--block); border-color: var(--block-bg); }
.btn-danger:hover:not(:disabled) { border-color: var(--block); }
form .btn-danger { background: var(--block); border-color: var(--block); color: #fff; }

.history summary { cursor: pointer; margin: 0; }
.history ol { margin: 10px 0 0; padding-left: 20px; font-size: 13px; display: grid; gap: 4px; }

/* ---------- Narrow screens: stack the panels ---------- */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; height: auto; padding: 12px 16px; }
  .panel-list { order: 2; }
  .panel-detail { order: 3; }
  .topbar { flex-wrap: wrap; gap: 8px 16px; padding: 12px 16px; }
}

/* Keep Reject / Edit / Approve in view while scrolling a long message. */
.panel-detail > .actions {
  position: sticky; bottom: -16px; z-index: 1;
  margin: 0 -16px 12px; padding: 12px 16px;
  background: var(--panel); border-top: 1px solid var(--line);
}

/* ---------- Login ---------- */
.login { display: grid; place-items: start center; padding: 48px 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 8px; }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.login-card .error:empty { display: none; }
.login-divider { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.reviewer .btn { margin-left: 8px; }
[hidden] { display: none !important; }

/* ---------- Message parts (AI-recombined / Library original) ---------- */
.view-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.view-btn { border: 0; background: none; padding: 6px 10px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; }
.view-btn.active { background: var(--brand-black); color: #fff; }
.legend { display: flex; gap: 6px; flex-wrap: wrap; }
.parts { display: grid; gap: 10px; }
.part { display: grid; grid-template-columns: 130px 1fr; gap: 12px; align-items: start; }
.part:has(> span:empty:first-child) { grid-template-columns: 1fr; }
.part:has(> span:empty:first-child) > span:first-child { display: none; }
.part-text { white-space: pre-wrap; line-height: 1.5; }
.source-tag { justify-self: start; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--ground); color: var(--muted); }
.source-original { background: #e7f5ec; color: var(--pass); }
.source-recombined { background: var(--brand-tint); color: var(--brand-blue-dark); }
.source-written { background: #fff4e0; color: var(--warn); }
.source-edited { background: #fde8e6; color: var(--block); }
.no-source { color: var(--muted); font-style: italic; }
.block-id { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
