:root {
  --bg: #f4f7fb;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-soft: #f8fafc;
  --text: #1f2937;
  --muted: #667085;
  --border: #dbe3ef;
  --border-strong: #c4d2e3;
  --accent: #0f172a;
  --accent-soft: #eff6ff;
  --incoming: #ffffff;
  --outgoing: #0f172a;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(191, 219, 254, 0.42), transparent 24%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

a {
  color: inherit;
}

.is-hidden {
  display: none !important;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-main {
  flex: 1;
  padding: 18px 0 36px;
}

.page-container {
  width: min(1460px, calc(100% - 32px));
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.hero-card,
.metric-card,
.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid rgba(219, 227, 239, 0.95);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: visible;
}

.hero-card:has(.section-help[open]),
.metric-card:has(.section-help[open]),
.panel:has(.section-help[open]) {
  z-index: 120;
}

.hero-card {
  padding: 24px 28px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.section-eyebrow::before {
  display: none;
}

.hero-card__title,
.panel__title {
  margin: 0;
  color: #0f172a;
}

.hero-card__title {
  font-size: clamp(30px, 4vw, 40px);
  line-height: 1.05;
}

.hero-card__body,
.metric-card__hint,
.panel__subtitle,
.conversation-item__meta,
.conversation-item__preview,
.group-header__meta,
.reply-box__hint,
.empty-state,
.message-bubble__meta {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.hero-card__body {
  max-width: 860px;
  margin: 14px 0 0;
}

.hero-card__actions,
.thread-actions,
.reply-box__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.button,
.button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

.button {
  background: var(--accent);
  color: #fff;
  border: 1px solid transparent;
}

.button-secondary {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--border-strong);
}

.metrics-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card {
  padding: 18px 20px;
}

.metric-card__label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-card__value {
  margin-top: 10px;
  color: #0f172a;
  font-size: 34px;
  font-weight: 800;
}

.metric-card__hint {
  margin-top: 8px;
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(340px, 0.75fr) minmax(0, 1.25fr);
}

.panel__header {
  padding: 20px 22px 0;
}

.panel__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel__header--thread {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
}

.panel__title {
  font-size: 24px;
  line-height: 1.1;
}

.panel__title--prominent {
  font-size: 34px;
  line-height: 1.04;
  letter-spacing: 0;
}

.panel__subtitle {
  margin: 10px 0 0;
}

.section-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: none;
  z-index: 40;
}

.section-help > summary {
  list-style: none;
}

.section-help > summary::-webkit-details-marker {
  display: none;
}

.section-help__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(219, 227, 239, 0.95);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  color: #0f172a;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

.section-help__trigger:hover {
  border-color: rgba(15, 23, 42, 0.2);
}

.section-help__popup {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  display: none;
  z-index: 80;
  width: min(380px, 82vw);
  padding: 13px 14px;
  border: 1px solid rgba(219, 227, 239, 0.95);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.12);
  color: var(--muted);
}

.section-help__popup::before {
  content: "";
  position: absolute;
  right: 12px;
  top: -6px;
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.98);
  border-left: 1px solid rgba(219, 227, 239, 0.95);
  border-top: 1px solid rgba(219, 227, 239, 0.95);
  transform: rotate(45deg);
}

.section-help[open] .section-help__popup {
  display: block;
}

.section-help__popup-title {
  margin: 0 0 6px;
  color: #0f172a;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
}

.section-help__popup-body {
  font-size: 13px;
  line-height: 1.6;
}

.panel__body {
  padding: 18px 22px 22px;
}

.panel__body--sidebar {
  display: grid;
  gap: 14px;
}

.panel__body--thread {
  display: grid;
  gap: 16px;
}

.search-field {
  position: relative;
}

.search-field__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-field input,
.reply-box textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}

.search-field input {
  min-height: 48px;
  padding: 0 14px 0 38px;
}

.list-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.messages-list,
.thread-messages {
  display: grid;
  gap: 12px;
}

.group-header {
  padding: 14px 16px 6px;
}

.group-header__title {
  color: #0f172a;
  font-size: 16px;
  font-weight: 700;
}

.group-header__meta {
  margin-top: 4px;
  font-size: 13px;
}

.conversation-item {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
  cursor: pointer;
}

.conversation-item.is-active {
  border-color: #94a3b8;
  background: var(--accent-soft);
}

.conversation-item__top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.conversation-item__name {
  color: #0f172a;
  font-weight: 700;
}

.conversation-item__context {
  margin-top: 4px;
  color: #334155;
  font-size: 13px;
  font-weight: 600;
}

.conversation-item__meta {
  margin-top: 8px;
  font-size: 13px;
}

.conversation-item__preview {
  margin-top: 8px;
  font-size: 13px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eff4fb;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
}

.pill--context {
  background: #dbeafe;
  color: #1d4ed8;
}

.thread-messages {
  min-height: 420px;
  align-content: start;
}

.message-row {
  display: flex;
}

.message-row--self {
  justify-content: flex-end;
}

.message-bubble {
  max-width: min(76%, 640px);
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--incoming);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.message-row--self .message-bubble {
  background: var(--outgoing);
  color: #fff;
  border-color: rgba(15, 23, 42, 0.9);
}

.message-row--self .message-bubble .message-bubble__meta {
  color: rgba(255, 255, 255, 0.72);
}

.message-bubble__meta {
  margin-bottom: 8px;
  font-size: 12px;
}

.message-bubble__text {
  font-size: 14px;
  line-height: 1.6;
}

.reply-box {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.reply-box__label {
  display: inline-block;
  margin-bottom: 10px;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
}

.reply-box textarea {
  padding: 12px 14px;
  resize: vertical;
}

.empty-state {
  padding: 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
}

@media (max-width: 1180px) {
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .page-container {
    width: min(100%, calc(100% - 20px));
  }

  .hero-card,
  .panel__header--thread,
  .conversation-item__top,
  .reply-box__actions {
    flex-direction: column;
    align-items: stretch;
  }

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

  .hero-card,
  .panel__header,
  .panel__body {
    padding-left: 18px;
    padding-right: 18px;
  }

  .hero-card__actions > *,
  .reply-box__actions > .button {
    width: 100%;
  }

  .message-bubble {
    max-width: 100%;
  }
}
