:root {
  color-scheme: light;
  --bg: #eef3f5;
  --panel: #ffffff;
  --panel-soft: #f6f8f9;
  --text: #182226;
  --muted: #607179;
  --line: #dce5e8;
  --brand: #157f83;
  --brand-dark: #0f6669;
  --accent: #f0b44d;
  --danger: #c2413b;
  --candidate: #e9f4f4;
  --operator: #ffffff;
  --shadow: 0 20px 50px rgba(24, 34, 38, .14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  min-width: 320px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: .62;
}

.topbar {
  min-height: 64px;
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(220, 229, 232, .9);
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
  letter-spacing: 0;
  flex: 0 0 auto;
}

.brand-name {
  margin: 0;
  font-size: 16px;
  line-height: 1.1;
  font-weight: 850;
  letter-spacing: 0;
}

.brand-note,
.muted {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #cfe3df;
  border-radius: 999px;
  background: #f2faf8;
  color: #1a6d59;
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2fb174;
  box-shadow: 0 0 0 4px rgba(47, 177, 116, .14);
}

.candidate-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .78), rgba(238, 243, 245, .94)),
    var(--bg);
}

.workspace {
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: stretch;
}

.context {
  min-width: 0;
  min-height: calc(100vh - 120px);
  display: grid;
  align-content: center;
  gap: 18px;
}

.context-panel,
.trust-item,
.chat-shell,
.login-card,
.operator-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .84);
}

.context-panel {
  padding: 30px;
  box-shadow: 0 12px 34px rgba(24, 34, 38, .08);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--brand-dark);
  font-size: 13px;
  line-height: 1.2;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .08em;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

.context h1 {
  margin: 0;
  max-width: 640px;
  font-size: clamp(32px, 4vw, 54px);
  line-height: 1;
}

.lead {
  margin: 16px 0 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.trust-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.trust-item {
  min-height: 82px;
  padding: 12px;
  display: grid;
  align-content: center;
  gap: 6px;
}

.trust-title {
  font-size: 13px;
  font-weight: 850;
}

.trust-text {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.chat-shell {
  min-width: 0;
  min-height: calc(100vh - 120px);
  max-height: 760px;
  align-self: center;
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
}

.chat-header {
  min-height: 74px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e6f2f1;
  color: var(--brand-dark);
  font-weight: 900;
  flex: 0 0 auto;
}

.chat-title {
  min-width: 0;
  flex: 1;
}

.chat-title strong,
.chat-title span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-title strong {
  font-size: 15px;
  line-height: 1.2;
}

.chat-title span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.messages {
  min-height: 0;
  padding: 18px 16px 12px;
  overflow-y: auto;
  background:
    linear-gradient(180deg, rgba(246, 248, 249, .94), rgba(255, 255, 255, .96)),
    var(--panel-soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day {
  align-self: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.bubble {
  max-width: 88%;
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.42;
  box-shadow: 0 5px 14px rgba(24, 34, 38, .07);
  overflow-wrap: anywhere;
}

.bubble.operator {
  align-self: flex-start;
  background: var(--operator);
  border: 1px solid var(--line);
}

.bubble.candidate {
  align-self: flex-end;
  background: var(--candidate);
  border: 1px solid #cfe3df;
}

.bubble.system {
  align-self: center;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.quick {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 14px 0;
  background: #fff;
}

.chip {
  border: 1px solid #cfe3df;
  border-radius: 999px;
  background: #fff;
  color: var(--brand-dark);
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.composer {
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #fff;
  display: grid;
  grid-template-columns: 1fr 42px;
  gap: 10px;
}

.composer input,
.composer textarea,
.login-card input,
.operator-card input,
.operator-card select {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: 0;
}

.composer input,
.login-card input,
.operator-card input,
.operator-card select {
  min-height: 42px;
  padding: 0 13px;
}

.composer textarea {
  min-height: 42px;
  max-height: 120px;
  resize: vertical;
  padding: 11px 13px;
}

.send,
.primary,
.ghost,
.danger {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 850;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.send {
  width: 42px;
  border: 0;
  background: var(--brand);
  color: #fff;
  font-size: 20px;
  box-shadow: 0 8px 18px rgba(21, 127, 131, .24);
}

.primary {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  padding: 0 14px;
}

.ghost {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0 14px;
}

.danger {
  border: 1px solid #f1b7b3;
  background: #fff6f5;
  color: var(--danger);
  padding: 0 14px;
}

.legal {
  margin: 0;
  padding: 0 12px 12px;
  color: var(--muted);
  background: #fff;
  font-size: 11px;
  line-height: 1.35;
}

.operator-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(320px, 420px) minmax(420px, 1fr);
  background: #eef2f3;
}

.operator-sidebar,
.inbox,
.operator-chat {
  min-height: 100vh;
  min-width: 0;
}

.operator-sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.operator-card {
  padding: 14px;
  display: grid;
  gap: 10px;
}

.operator-card label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 750;
}

.operator-settings {
  display: grid;
  gap: 8px;
}

.operator-setting {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  gap: 9px;
  background: var(--panel-soft);
}

.operator-setting-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.operator-setting-main strong {
  font-size: 13px;
}

.operator-setting-main span,
.switch-row span,
.priority-row span {
  color: var(--muted);
  font-size: 12px;
}

.switch-row,
.priority-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  justify-content: space-between;
  gap: 10px !important;
}

.switch-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.priority-row input {
  width: 72px;
  min-height: 34px;
  padding: 0 8px;
  text-align: center;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  font-size: 24px;
}

.inbox {
  border-right: 1px solid var(--line);
  display: grid;
  grid-template-rows: auto 1fr;
}

.pane-header {
  min-height: 72px;
  padding: 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pane-header h1,
.operator-chat h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
}

.conversation-list {
  padding: 12px;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 10px;
}

.conversation-card {
  position: relative;
  width: 100%;
  min-height: 98px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  display: grid;
  gap: 8px;
}

.conversation-card.active {
  border-color: var(--brand);
  box-shadow: 0 12px 30px rgba(21, 127, 131, .12);
}

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

.conversation-name {
  font-weight: 850;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-meta,
.conversation-preview {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent);
  color: #2f2108;
  font-size: 12px;
  font-weight: 850;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
}

.state {
  border-radius: 999px;
  padding: 5px 8px;
  background: #f2f5f6;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.state.queued {
  background: #fff8e8;
  color: #8a5a00;
}

.state.active {
  background: #edf9f4;
  color: #11694d;
}

.operator-chat {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  background: #fff;
}

.chat-tools {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.typing-preview {
  min-height: 38px;
  padding: 10px 16px;
  border-bottom: 1px solid #edf2f4;
  color: var(--brand-dark);
  background: #f2faf8;
  font-size: 13px;
  display: none;
  overflow-wrap: anywhere;
}

.typing-preview.visible {
  display: block;
}

.template-row {
  padding: 8px 12px 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: #fff;
}

.operator-composer {
  grid-template-columns: 1fr auto;
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  margin: 80px auto;
  padding: 22px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 0;
  font-size: 26px;
}

.empty {
  min-height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 24px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #182226;
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 20;
}

.toast.visible {
  display: block;
}

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

  .context {
    display: none;
  }

  .chat-shell {
    width: min(440px, calc(100vw - 32px));
    margin: 0 auto;
  }

  .operator-page {
    grid-template-columns: 240px 330px minmax(360px, 1fr);
  }
}

@media (max-width: 820px) {
  .topbar {
    padding: 0 14px;
  }

  .brand-note,
  .status {
    display: none;
  }

  .workspace {
    width: 100%;
    padding: 0;
  }

  .chat-shell {
    width: 100%;
    min-height: calc(100vh - 64px);
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .operator-page {
    grid-template-columns: 1fr;
  }

  .operator-sidebar,
  .inbox,
  .operator-chat {
    min-height: auto;
  }

  .inbox {
    max-height: 42vh;
  }

  .operator-chat {
    min-height: 58vh;
  }

  .chat-tools {
    align-items: stretch;
  }

  .chat-tools button,
  .chat-tools select {
    flex: 1;
  }
}
