:root {
  --bg: #eef1eb;
  --bg-strong: #e7ebe4;
  --panel: rgba(251, 252, 248, 0.9);
  --line: rgba(24, 33, 24, 0.14);
  --ink: #182118;
  --muted: #667068;
  --accent: #1f5c44;
  --accent-soft: rgba(31, 92, 68, 0.12);
  --shadow: 0 8px 18px rgba(24, 33, 24, 0.04);
  --good: #1d7a50;
  --bad: #a12a2a;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Avenir Next", "Helvetica Neue", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(31, 92, 68, 0.08), transparent 24%),
    radial-gradient(circle at top right, rgba(37, 83, 114, 0.08), transparent 22%),
    linear-gradient(180deg, #f4f6f1 0%, var(--bg) 44%, var(--bg-strong) 100%);
}

a {
  color: inherit;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 14px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-size: 11px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2.15rem;
  line-height: 1.05;
  font-weight: 700;
}

h2 {
  font-size: 1rem;
  line-height: 1.15;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1.4fr;
  gap: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  min-height: 74vh;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 10px;
}

.stack {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.search-section {
  padding-top: 2px;
  border-top: 1px solid rgba(24, 33, 24, 0.08);
}

.intake-note {
  padding-top: 0;
  border-top: 0;
  margin-bottom: 6px;
}

.conversation-search {
  margin-bottom: 10px;
}

.button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.compact-row {
  gap: 6px;
}

.import-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.workspace-switcher {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.review-actions {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

.button-link:hover {
  filter: brightness(0.95);
}

.secondary-link {
  background: rgba(252, 252, 249, 0.95);
  color: var(--ink);
  border: 1px solid var(--line);
}

button {
  border: 0;
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}

button:hover {
  filter: brightness(0.95);
}

button:disabled {
  cursor: wait;
  opacity: 0.72;
}

input,
textarea,
.lookup-box,
.ai-box {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
}

input[type="search"] {
  padding-right: 14px;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

.ai-box,
.lookup-box {
  white-space: pre-wrap;
  border-radius: 0;
  border-left: 0;
  border-right: 0;
  background: transparent;
  padding: 6px 0 8px;
}

.ai-box {
  min-height: 88px;
}

.list {
  display: grid;
  gap: 0;
}

.list-item {
  display: grid;
  gap: 2px;
  text-align: left;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 9px 2px 9px 0;
}

.list-item-top {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 10px;
}

.secondary-button {
  background: rgba(252, 252, 249, 0.92);
  color: var(--ink);
  border: 1px solid var(--line);
}

.workspace-chip {
  background: rgba(252, 252, 249, 0.92);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 600;
  font-size: 12px;
}

.workspace-chip.active {
  background: var(--accent);
  color: white;
}

.list-item span,
.muted {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

#search-summary {
  min-height: 28px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
}

.pagination:empty {
  display: none;
}

.pagination-button {
  min-width: 88px;
}

.pagination-label {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.list-item.selected {
  border-left: 2px solid rgba(31, 92, 68, 0.45);
  padding-left: 8px;
}

.list-item.reviewed {
  opacity: 0.8;
}

.workspace-panel.hidden {
  display: none;
}

.panel-header.inline {
  margin-bottom: 8px;
}

.panel-header.inline h3 {
  margin: 0;
  font-size: 14px;
}

.verified-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.muted.good {
  color: var(--good);
}

.muted.bad {
  color: var(--bad);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0 12px;
  max-height: 48vh;
  overflow: auto;
  padding: 8px 0;
  border-radius: 0;
  background: transparent;
  border-top: 1px solid rgba(24, 33, 24, 0.08);
  border-bottom: 1px solid rgba(24, 33, 24, 0.08);
}

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

.message-separator {
  display: grid;
  justify-items: center;
  gap: 1px;
  margin: 5px 0 1px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.02em;
}

.message-separator-service {
  font-weight: 700;
}

.message-separator-time {
  opacity: 0.8;
}

.message-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 78%;
}

.message-cluster {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message-row.inbound {
  align-self: flex-start;
}

.message-row.outbound {
  align-self: flex-end;
  align-items: flex-end;
}

.message-bubble {
  position: relative;
  padding: 9px 12px;
  border-radius: 16px;
  line-height: 1.34;
  box-shadow: none;
}

.message-cluster .message-bubble:not(:first-child) {
  margin-top: 1px;
}

.message-cluster .message-bubble:not(:first-child):not(:last-child) {
  border-radius: 16px;
}

.message-cluster .message-bubble:first-child:not(:last-child) {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 16px;
}

.message-cluster .message-bubble:last-child:not(:first-child) {
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.message-cluster .message-bubble:last-child::after {
  content: "";
  position: absolute;
  bottom: 2px;
  width: 12px;
  height: 12px;
  border-radius: 0 0 10px 0;
}

.message-bubble.incoming {
  background: #ffffff;
  color: var(--ink);
  border: 1px solid rgba(24, 33, 24, 0.1);
}

.message-cluster .message-bubble.incoming:last-child::after {
  left: -4px;
  background: #ffffff;
  border-left: 1px solid rgba(24, 33, 24, 0.1);
  border-bottom: 1px solid rgba(24, 33, 24, 0.1);
  transform: skewX(18deg);
}

.message-bubble.imessage {
  background: linear-gradient(180deg, #3191ff 0%, #0a7bff 100%);
  color: white;
}

.message-cluster .message-bubble.imessage:last-child::after {
  right: -4px;
  background: #0a7bff;
  transform: skewX(-18deg);
}

.message-bubble.sms {
  background: linear-gradient(180deg, #42d96d 0%, #29c454 100%);
  color: white;
}

.message-cluster .message-bubble.sms:last-child::after {
  right: -4px;
  background: #29c454;
  transform: skewX(-18deg);
}

.message-status {
  font-size: 11px;
  color: var(--muted);
  padding: 0 4px;
}

.message-status.failed {
  color: #cf2f2f;
  font-weight: 700;
}

.message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.composer {
  display: grid;
  gap: 6px;
}

.composer-shell {
  display: grid;
  gap: 8px;
  padding: 10px 0 0;
  border-radius: 0;
  border-top: 1px solid rgba(24, 33, 24, 0.08);
  background: transparent;
  box-shadow: none;
}

.composer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.composer-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.composer-pill.imessage {
  background: rgba(49, 145, 255, 0.12);
  color: #0a7bff;
}

.composer-pill.sms {
  background: rgba(41, 196, 84, 0.14);
  color: #1b9d42;
}

.composer-body {
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(24, 33, 24, 0.1);
}

.composer-body textarea {
  min-height: 136px;
  max-height: 260px;
  padding: 4px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  resize: none;
  flex: 1 1 auto;
  min-width: 0;
  overflow-y: auto;
  line-height: 1.32;
  font-size: 13px;
}

.composer-body textarea:focus {
  outline: none;
}

.composer-send {
  min-width: 66px;
  padding: 9px 12px;
  background: linear-gradient(180deg, #3292ff 0%, #0a7bff 100%);
  border-radius: 10px;
  align-self: flex-end;
}

.status-note {
  min-height: 18px;
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
  text-align: right;
}

.status-note.good {
  color: var(--good);
}

.status-note.bad {
  color: var(--bad);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: #ddd7ce;
  color: var(--ink);
  font-size: 12px;
}

.pill.good {
  background: #d5efdf;
  color: var(--good);
}

.pill.bad {
  background: #f2d2d2;
  color: var(--bad);
}

.guide-shell {
  display: grid;
  gap: 12px;
}

.guide-hero {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  min-height: auto;
}

.guide-hero-copy {
  max-width: 760px;
}

.guide-lead {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin-top: 8px;
}

.guide-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.guide-card {
  min-height: auto;
}

.guide-card h2 {
  margin-bottom: 8px;
}

.guide-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
  color: var(--ink);
  line-height: 1.38;
}

.guide-list.ordered {
  padding-left: 20px;
}

.guide-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.thread-strip {
  display: grid;
  gap: 4px;
  margin-bottom: 6px;
}

.strip-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.thread-panel .panel-header {
  margin-bottom: 8px;
}

.thread-panel .button-row {
  gap: 6px;
}

.thread-panel .muted {
  margin-top: 3px;
}

.import-meta .muted,
.review-actions .muted {
  line-height: 1.2;
}

.lang-toggle {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
}

.lang-chip {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
}

.lang-chip.active {
  background: var(--accent);
  color: white;
}

@media (max-width: 1080px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: auto;
  }

  .guide-grid {
    grid-template-columns: 1fr;
  }

  .guide-hero {
    flex-direction: column;
  }
}
