:root {
  --bg: #f6f4ea;
  --bg-soft: #ebe6d2;
  --bg-grid: rgba(15, 118, 110, 0.06);
  --ink: #1d2322;
  --ink-soft: #4f5f5a;
  --ink-faint: #6f7f79;
  --accent: #0f766e;
  --accent-strong: #0f625b;
  --accent-soft: #d5f3eb;
  --warm: #d97706;
  --warm-soft: #fde9c8;
  --stroke: #d7d3c2;
  --card: rgba(255, 255, 255, 0.84);
  --card-strong: rgba(255, 255, 255, 0.94);
  --shadow: 0 24px 48px rgba(19, 31, 29, 0.14);
  --shadow-soft: 0 12px 26px rgba(19, 31, 29, 0.08);
  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Bai Jamjuree", "Tahoma", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% -12%, #ffd8a3 0%, transparent 42%),
    radial-gradient(circle at -8% 26%, #a4eadb 0%, transparent 36%),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-soft) 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

.bg-glow {
  position: fixed;
  width: 36rem;
  height: 36rem;
  border-radius: 999px;
  filter: blur(72px);
  opacity: 0.34;
  z-index: 0;
  pointer-events: none;
}

.bg-glow-a {
  background: #2dc49a;
  top: -14rem;
  left: -12rem;
}

.bg-glow-b {
  background: #f59e0b;
  bottom: -18rem;
  right: -12rem;
}

.layout {
  max-width: 1420px;
  margin: 0 auto;
  padding: 26px;
  position: relative;
  z-index: 1;
  animation: fade-rise 620ms ease both;
}

.card {
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.78));
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.card-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 22px;
  padding: 26px 28px;
  margin-bottom: 20px;
}

.card-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(15, 118, 110, 0.08), rgba(217, 119, 6, 0.08));
  pointer-events: none;
}

.hero > * {
  position: relative;
  z-index: 1;
}

.eyebrow {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  color: var(--accent-strong);
}

h1 {
  margin: 9px 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(1.65rem, 3.4vw, 2.7rem);
  line-height: 1.03;
}

.hero-subtitle {
  margin: 0;
  color: var(--ink-soft);
  max-width: 64ch;
  font-size: 0.98rem;
}

.hero-status {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 600;
  color: var(--accent-strong);
  box-shadow: var(--shadow-soft);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45);
}

.status-dot.online {
  background: #22c55e;
  animation: pulse 1.8s ease infinite;
}

.main-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 290px minmax(420px, 1.38fr) minmax(340px, 1fr);
  align-items: start;
}

.main-grid > * {
  animation: fade-rise 560ms ease both;
}

.main-grid > :nth-child(1) {
  animation-delay: 70ms;
}

.main-grid > :nth-child(2) {
  animation-delay: 130ms;
}

.main-grid > :nth-child(3) {
  animation-delay: 190ms;
}

.panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 0 0 14px;
  padding: 0 2px 12px;
  border-bottom: 1px solid rgba(15, 118, 110, 0.11);
}

.panel-head h2 {
  margin: 0;
  font-size: 1.04rem;
  letter-spacing: 0.01em;
}

.users-list,
.conversation-list,
.list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.users-panel {
  min-height: 440px;
}

.users-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 5px;
}

.user-item {
  border: 1px solid rgba(15, 118, 110, 0.14);
  background:
    linear-gradient(170deg, rgba(255, 255, 255, 0.96), rgba(247, 255, 252, 0.92));
  border-radius: var(--radius-md);
  padding: 11px 11px 10px;
  cursor: pointer;
  transition: transform 170ms ease, border-color 170ms ease, box-shadow 170ms ease;
}

.user-item:hover {
  transform: translateY(-2px);
  border-color: #63c9b6;
  box-shadow: var(--shadow-soft);
}

.user-item.active {
  border-color: var(--accent);
  background: linear-gradient(170deg, #f2fffb, #e8fbf5);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.user-id {
  font-weight: 700;
  margin-bottom: 4px;
}

.user-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-size: 0.67rem;
  font-weight: 700;
  padding: 2px 7px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.source-group {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.source-user {
  background: #e0f2fe;
  border-color: #7dd3fc;
  color: #075985;
}

.source-room {
  background: #fef3c7;
  border-color: #fcd34d;
  color: #92400e;
}

.source-web,
.source-unknown {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #374151;
}

.user-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.center-column {
  display: grid;
  gap: 20px;
  align-content: start;
  grid-auto-rows: max-content;
}

.chat-panel,
.timeline-panel,
.users-panel,
.insights-panel {
  border-radius: var(--radius-xl);
}

.chat-form {
  display: grid;
  gap: 10px;
}

label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(15, 118, 110, 0.2);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
  background: var(--card-strong);
  color: var(--ink);
  transition: border-color 170ms ease, box-shadow 170ms ease, transform 170ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #1ea090;
  box-shadow: 0 0 0 3px rgba(30, 160, 144, 0.17);
  outline: none;
}

textarea {
  resize: vertical;
}

.form-hint {
  margin: -2px 0 2px;
  font-size: 0.79rem;
  color: var(--ink-faint);
  line-height: 1.35;
}

.quick-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(140deg, #0f766e, #149284);
  color: #fff;
  box-shadow: 0 10px 18px rgba(15, 118, 110, 0.22);
}

.btn-primary:hover {
  filter: brightness(1.05);
}

.btn-ghost {
  border: 1px solid rgba(15, 118, 110, 0.22);
  background: rgba(255, 255, 255, 0.85);
  color: var(--accent-strong);
}

.quick-cmd {
  padding: 6px 11px;
  font-size: 0.82rem;
}

.chip {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--warm-soft);
  color: #9a4f07;
  border: 1px solid rgba(217, 119, 6, 0.22);
}

.timeline-panel {
  min-height: 380px;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 470px;
  overflow: auto;
  padding: 12px 10px;
  border-radius: 18px;
  border: 1px solid rgba(16, 128, 102, 0.32);
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 255, 255, 0.42), transparent 42%),
    linear-gradient(180deg, #b6eec0 0%, #a4e2ae 100%);
}

.timeline-empty {
  border-radius: 12px;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px dashed rgba(24, 66, 38, 0.34);
  color: #31553f;
  font-size: 0.85rem;
}

.line-row {
  display: flex;
  width: 100%;
  align-items: flex-end;
  gap: 7px;
}

.line-row.user {
  justify-content: flex-end;
}

.line-row.assistant {
  justify-content: flex-start;
}

.line-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--accent-strong);
  color: #fff;
  flex: 0 0 auto;
  margin-bottom: 16px;
  box-shadow: 0 6px 12px rgba(15, 118, 110, 0.3);
}

.line-stack {
  max-width: min(80%, 560px);
  display: grid;
  gap: 4px;
}

.line-row.user .line-stack {
  justify-items: end;
}

.line-bubble {
  position: relative;
  border-radius: 14px;
  padding: 8px 11px;
  line-height: 1.36;
  white-space: pre-wrap;
  font-size: 0.88rem;
  width: fit-content;
  max-width: 100%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  border: 1px solid transparent;
}

.line-bubble.assistant {
  background: #ffffff;
  border-color: rgba(15, 118, 110, 0.12);
  color: #1f2d27;
}

.line-bubble.assistant::after {
  content: "";
  position: absolute;
  left: -6px;
  bottom: 6px;
  border-width: 6px 6px 0 0;
  border-style: solid;
  border-color: #ffffff transparent transparent transparent;
}

.line-bubble.user {
  background: #8de763;
  border-color: rgba(33, 96, 34, 0.2);
  color: #10210f;
}

.line-bubble.user::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 6px;
  border-width: 6px 0 0 6px;
  border-style: solid;
  border-color: #8de763 transparent transparent transparent;
}

.line-meta {
  font-size: 0.68rem;
  color: rgba(20, 42, 30, 0.75);
  padding: 0 2px;
}

.line-tools {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 0 2px;
}

.line-reply-btn {
  border: 1px solid rgba(15, 118, 110, 0.32);
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent-strong);
  border-radius: 999px;
  font-size: 0.67rem;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.line-reply-btn:hover {
  background: #e8fffa;
  border-color: #149284;
}

.line-tags {
  margin-top: 2px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid #88d9ca;
  background: #e8fffa;
  color: #0f766e;
  font-size: 0.78rem;
  font-weight: 600;
  margin-right: 6px;
}

.line-tag {
  font-size: 0.66rem;
  padding: 2px 6px;
  border-color: #7fcdb2;
  background: rgba(232, 255, 250, 0.9);
  color: #0f6f65;
  margin-right: 0;
}

.insights-panel {
  min-height: 420px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.insights-panel > * {
  display: none;
}

.stack {
  display: grid;
  gap: 12px;
}

.track-section {
  --section-accent: #0f766e;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(15, 118, 110, 0.15);
  border-radius: 16px;
  padding: 11px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
  animation: fade-rise 520ms ease both;
}

.track-section::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--section-accent), rgba(255, 255, 255, 0));
}

.stack > .track-section:nth-child(1) {
  animation-delay: 40ms;
}

.stack > .track-section:nth-child(2) {
  animation-delay: 80ms;
}

.stack > .track-section:nth-child(3) {
  animation-delay: 120ms;
}

.stack > .track-section:nth-child(4) {
  animation-delay: 160ms;
}

.stack > .track-section:nth-child(5) {
  animation-delay: 200ms;
}

.stack > .track-section:nth-child(6) {
  animation-delay: 240ms;
}

.stack > .track-section:nth-child(7) {
  animation-delay: 280ms;
}

.compose-section {
  --section-accent: #0f766e;
  background: linear-gradient(160deg, rgba(223, 252, 246, 0.92), rgba(255, 255, 255, 0.82));
}

.alert-section {
  --section-accent: #ef4444;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.9));
}

.alert-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.alert-pending-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #fecaca;
  background: #fee2e2;
  color: #dc2626;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.alert-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.alert-list li {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 12px;
  padding: 9px 10px;
}

.alert-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.alert-item-title {
  font-weight: 700;
  color: #1f2937;
}

.alert-item-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #fee2e2;
  color: #dc2626;
  font-size: 0.68rem;
  font-weight: 700;
}

.alert-item-meta {
  margin-top: 5px;
  font-size: 0.74rem;
  color: var(--ink-faint);
}

.alert-empty {
  min-height: 140px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  color: var(--ink-faint);
}

.tracking-section {
  --section-accent: #2563eb;
  background: linear-gradient(160deg, rgba(232, 242, 255, 0.92), rgba(255, 255, 255, 0.82));
}

.summary-section {
  --section-accent: #16a34a;
  background: linear-gradient(160deg, rgba(232, 255, 238, 0.92), rgba(255, 255, 255, 0.82));
}

.discuss-section {
  --section-accent: #ea580c;
  background: linear-gradient(160deg, rgba(255, 238, 222, 0.92), rgba(255, 255, 255, 0.82));
}

.meeting-section {
  --section-accent: #0284c7;
  background: linear-gradient(160deg, rgba(230, 247, 255, 0.92), rgba(255, 255, 255, 0.82));
}

.news-section {
  --section-accent: #b45309;
  background: linear-gradient(160deg, rgba(255, 245, 227, 0.92), rgba(255, 255, 255, 0.82));
}

.guide-section {
  --section-accent: #334155;
  background: linear-gradient(160deg, rgba(240, 244, 248, 0.92), rgba(255, 255, 255, 0.82));
}

.stack section h3 {
  margin: 0 0 9px;
  font-size: 0.95rem;
  color: #1f2c2a;
}

.tracking-note {
  min-height: 56px;
  font-size: 0.83rem;
}

.tracking-controls {
  margin-top: 8px;
}

.track-item-title {
  display: block;
  font-weight: 700;
  color: #1f2a28;
}

.track-item-detail {
  display: block;
  color: var(--ink-soft);
  margin-top: 3px;
}

.track-item-meta {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.text-box {
  margin: 0;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  padding: 10px;
  color: var(--ink-soft);
  min-height: 72px;
  white-space: pre-wrap;
}

.list {
  display: grid;
  gap: 8px;
}

.list li {
  border: 1px solid rgba(15, 118, 110, 0.14);
  border-radius: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.86);
  line-height: 1.35;
}

.bubble-meta {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.users-list::-webkit-scrollbar,
.conversation-list::-webkit-scrollbar {
  width: 8px;
}

.users-list::-webkit-scrollbar-thumb,
.conversation-list::-webkit-scrollbar-thumb {
  background: rgba(15, 118, 110, 0.28);
  border-radius: 999px;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.55);
  }
  100% {
    box-shadow: 0 0 0 12px rgba(34, 197, 94, 0);
  }
}

@keyframes fade-rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1180px) {
  .layout {
    padding: 18px;
  }

  .main-grid {
    grid-template-columns: 1fr;
  }

  .users-panel,
  .insights-panel,
  .timeline-panel {
    min-height: auto;
  }

  .conversation-list {
    max-height: 320px;
  }
}

@media (max-width: 760px) {
  .card-hero {
    flex-direction: column;
    gap: 14px;
    padding: 20px;
  }

  .hero-status {
    width: 100%;
    justify-content: center;
  }

  .panel {
    padding: 14px;
  }

  .line-stack {
    max-width: 88%;
  }

  .quick-row {
    gap: 6px;
  }
}
