:root {
  --bg-top: #f7fbf9;
  --bg-bottom: #e6f1ee;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --line: rgba(26, 63, 71, 0.12);
  --line-strong: rgba(15, 167, 161, 0.2);
  --text: #16252d;
  --text-soft: #59707a;
  --text-inverse: #f3fcfa;
  --accent: #0fa7a1;
  --accent-strong: #0d7f96;
  --danger-soft: rgba(176, 79, 87, 0.12);
  --badge-red: #ff5b6e;
  --badge-amber: #ffbe1f;
  --badge-green: #22c76a;
  --badge-blue: #2f80ff;
  --shadow-lg: 0 28px 68px rgba(22, 37, 45, 0.14);
  --shadow-sm: 0 10px 24px rgba(22, 37, 45, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --font-sans: "Aptos", "Segoe UI Variable", "Segoe UI", "Trebuchet MS", sans-serif;
  --font-display: "Bahnschrift", "Aptos Display", "Segoe UI Variable Display", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at top left, rgba(14, 127, 150, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(15, 167, 161, 0.16), transparent 26%),
    linear-gradient(160deg, var(--bg-top) 0%, #eef6f3 48%, var(--bg-bottom) 100%);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input {
  font: inherit;
}

.page-body {
  position: relative;
  overflow-x: hidden;
}

.page-body::before,
.page-body::after {
  content: "";
  position: fixed;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(10px);
  pointer-events: none;
  opacity: 0.55;
  z-index: 0;
}

.page-body::before {
  top: -7rem;
  left: -6rem;
  background: radial-gradient(circle, rgba(15, 167, 161, 0.24), transparent 68%);
}

.page-body::after {
  right: -7rem;
  bottom: -8rem;
  background: radial-gradient(circle, rgba(13, 127, 150, 0.2), transparent 66%);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1680px, calc(100% - 2rem));
  margin: 1rem auto;
  display: grid;
  grid-template-columns: minmax(250px, 0.62fr) minmax(0, 1.38fr);
  gap: 1rem;
}

.column-shell,
.panel,
.hero-card,
.thread-banner,
.detail-card,
.thread-item,
.message-card,
.stat-card {
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.column-shell,
.panel,
.thread-banner,
.hero-card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 28px 68px rgba(22, 37, 45, 0.14);
  border-radius: var(--radius-xl);
}

.column-shell {
  padding: 1.1rem;
  display: grid;
  gap: 1rem;
  align-content: start;
  min-height: calc(100vh - 2rem);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

.hero-card {
  padding: 1.35rem;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(20, 36, 44, 0.92), rgba(15, 76, 90, 0.84)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  color: var(--text-inverse);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.8rem;
  border-radius: 999px;
  color: rgba(243, 252, 250, 0.78);
  background: rgba(243, 252, 250, 0.08);
  border: 1px solid rgba(243, 252, 250, 0.14);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.74rem;
}

.page-title,
.section-title,
.headline {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: 0.01em;
}

.page-title {
  margin-top: 1rem;
  font-size: clamp(2rem, 3.2vw, 3.4rem);
  line-height: 0.94;
}

.panel-copy,
.section-copy,
.subheadline,
.thread-subject,
.thread-meta,
.thread-excerpt,
.timestamp,
.message-fragment,
.message-body,
.search-label,
.detail-caption {
  color: var(--text-soft);
}

.panel-copy,
.section-copy,
.subheadline {
  margin: 0.4rem 0 0;
  line-height: 1.6;
}

.stats-grid,
.detail-grid,
.thread-list,
.timeline {
  display: grid;
  gap: 1rem;
}

.stats-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1.2rem;
}

.stat-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.stat-card.accent {
  background: linear-gradient(150deg, rgba(15, 167, 161, 0.96), rgba(13, 127, 150, 0.9));
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(243, 252, 250, 0.72);
}

.stat-value {
  margin-top: 0.4rem;
  font-size: 2rem;
  font-weight: 700;
}

.panel {
  padding: 1rem;
}

.section-head,
.thread-top,
.thread-bottom,
.message-meta,
.message-footer,
.avatar-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.section-title {
  font-size: 1.35rem;
}

.chat-list-head {
  justify-content: center;
  text-align: center;
  margin-top: -0.68rem;
  margin-bottom: 0.2rem;
}

.chat-list-head > div {
  max-width: 18rem;
  margin: 0 auto;
}

.chat-list-head .section-copy {
  margin-top: 0;
}

.search-form {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}

.search-label {
  font-size: 0.8rem;
  font-weight: 700;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
}

.search-input {
  width: 100%;
  border: 1px solid rgba(30, 66, 77, 0.12);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  padding: 0.48rem 0.82rem;
  border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.search-input:focus {
  outline: none;
  border-color: rgba(15, 167, 161, 0.52);
  box-shadow: 0 0 0 4px rgba(15, 167, 161, 0.14);
}

.button-primary,
.button-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  padding: 0.38rem 0.88rem;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.button-primary {
  color: #f6fffe;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 16px 32px rgba(13, 127, 150, 0.18);
}

.detail-link {
  width: 100%;
  margin-top: 0.55rem;
}

.copy-chat-link {
  width: 100%;
  padding: 0.74rem 0.9rem;
  border: 1px solid rgba(30, 66, 77, 0.12);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
  text-align: left;
  font: inherit;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-all;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.copy-chat-link:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 167, 161, 0.28);
  box-shadow: 0 10px 22px rgba(22, 37, 45, 0.08);
}

.copy-chat-link.is-copied {
  border-color: rgba(34, 199, 106, 0.28);
  box-shadow: 0 0 0 3px rgba(34, 199, 106, 0.14);
}

.back-to-top-wrap {
  position: sticky;
  bottom: 0.75rem;
  display: flex;
  justify-content: flex-end;
  padding-bottom: 0.2rem;
  opacity: 0;
  transform: translateY(0.35rem);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.back-to-top-link {
  width: 2.85rem;
  height: 2.85rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid rgba(30, 66, 77, 0.14);
  border-radius: 999px;
  color: #f6fffe;
  font-size: 1.22rem;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  box-shadow: 0 14px 28px rgba(13, 127, 150, 0.2);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  pointer-events: auto;
}

.back-to-top-link:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(13, 127, 150, 0.24);
}

.back-to-top-wrap.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.button-ghost {
  color: var(--text-soft);
  background: transparent;
  border-color: rgba(30, 66, 77, 0.12);
}

.button-primary:hover,
.button-ghost:hover {
  transform: translateY(-1px);
}

.inline-button {
  justify-self: start;
}

.thread-item,
.detail-card,
.message-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(30, 66, 77, 0.1);
  box-shadow: var(--shadow-sm);
}

.thread-item,
.message-card {
  display: block;
  padding: 0.82rem 0.9rem;
  border-radius: var(--radius-lg);
}

.thread-item.active {
  background:
    linear-gradient(180deg, rgba(15, 167, 161, 0.13), rgba(255, 255, 255, 0.92));
  border-color: rgba(15, 167, 161, 0.34);
  box-shadow: none;
}

.thread-list {
  gap: 0.5rem;
}

.thread-item {
  position: relative;
  padding: 0.68rem 0.78rem;
  border-radius: 18px;
}

.thread-item.active .thread-name,
.thread-item.active .thread-name-code {
  color: #0b5158;
}

.thread-link {
  display: block;
}

.thread-name-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  justify-content: space-between;
}

.thread-top-copy {
  min-width: 0;
}

.thread-name,
.message-title {
  font-weight: 700;
  color: var(--text);
}

.thread-name {
  min-width: 0;
  flex: 1 1 auto;
}

.thread-name-code {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.32;
  word-break: break-all;
}

.chat-badge {
  width: 0.78rem;
  height: 1rem;
  flex: 0 0 0.78rem;
  border-radius: 0.34rem 0.34rem 0.12rem 0.12rem;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 78%, 0 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.72),
    0 1px 3px rgba(22, 37, 45, 0.12);
}

.chat-badge-red {
  background: var(--badge-red);
}

.chat-badge-amber {
  background: var(--badge-amber);
}

.chat-badge-green {
  background: var(--badge-green);
}

.chat-badge-blue {
  background: var(--badge-blue);
}

.badge-form {
  display: flex;
  gap: 0.38rem;
}

.badge-form-toolbar {
  justify-content: flex-end;
  margin-left: auto;
}

.badge-button {
  width: 0.88rem;
  height: 0.88rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(22, 37, 45, 0.16);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(22, 37, 45, 0.08);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.badge-button:hover {
  transform: translateY(-1px);
}

.badge-button.is-active {
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.92),
    0 0 0 4px rgba(22, 37, 45, 0.16);
  border-color: rgba(22, 37, 45, 0.36);
}

.badge-button-red {
  background: var(--badge-red);
}

.badge-button-amber {
  background: var(--badge-amber);
}

.badge-button-green {
  background: var(--badge-green);
}

.badge-button-blue {
  background: var(--badge-blue);
}

.thread-subject,
.thread-excerpt,
.message-fragment,
.message-body,
.detail-card strong {
  line-height: 1.55;
}

.thread-subject,
.thread-excerpt,
.message-fragment,
.thread-name,
.detail-card strong {
  overflow-wrap: anywhere;
}

.thread-meta {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.thread-excerpt {
  margin-top: 0.65rem;
}

.thread-bottom,
.chip-row {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  align-items: center;
}

.thread-bottom {
  margin-top: 0.9rem;
}

.count-pill,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  border-radius: 999px;
  font-size: 0.84rem;
}

.count-pill {
  min-width: 2rem;
  padding: 0 0.7rem;
  color: var(--text-inverse);
  background: #1a5a63;
  font-weight: 700;
}

.chip {
  padding: 0.44rem 0.78rem;
  border: 1px solid rgba(30, 66, 77, 0.12);
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.66);
}

.chip.active {
  color: #0d5056;
  border-color: rgba(15, 167, 161, 0.24);
  background: rgba(15, 167, 161, 0.14);
}

.chip.subtle {
  color: #536a73;
  background: rgba(22, 37, 45, 0.04);
}

.chip.chip-ai {
  color: #7a4d11;
  border-color: rgba(255, 190, 31, 0.28);
  background: rgba(255, 190, 31, 0.2);
}

.message-side-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.thread-banner {
  padding: 1.15rem;
  display: grid;
  gap: 1rem;
}

.thread-banner-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.avatar {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: var(--text-inverse);
  font-weight: 700;
  font-size: 1.05rem;
  flex-shrink: 0;
  background: linear-gradient(145deg, #0fa7a1, #0d7f96);
  box-shadow: 0 18px 30px rgba(15, 167, 161, 0.22);
}

.headline {
  margin-top: 0.6rem;
  font-size: clamp(1.5rem, 2vw, 2rem);
  overflow-wrap: anywhere;
}

.detail-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-card {
  padding: 1rem;
  border-radius: var(--radius-md);
}

.detail-caption {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-card strong {
  display: block;
  margin-top: 0.45rem;
  color: var(--text);
}

.timeline {
  margin-top: 1rem;
}

.message-card.incoming {
  background:
    linear-gradient(180deg, rgba(47, 128, 255, 0.09), rgba(255, 255, 255, 0.9));
  border-color: rgba(47, 128, 255, 0.18);
}

.meta-stack {
  display: grid;
  gap: 0.3rem;
  min-width: 0;
}

.timestamp {
  white-space: nowrap;
  font-size: 0.9rem;
}

.message-body {
  margin-top: 0.75rem;
  color: #26424c;
}

.message-body p {
  margin: 0;
}

.message-empty {
  margin: 0;
  font-style: italic;
}

.message-footer {
  margin-top: 1rem;
  align-items: center;
}

.empty-state {
  padding: 1.4rem;
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  border: 1px dashed rgba(30, 66, 77, 0.18);
  box-shadow: var(--shadow-sm);
}

.empty-state h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
}

.empty-state p {
  margin: 0.6rem 0 0;
  color: var(--text-soft);
  line-height: 1.6;
}

.fill-space {
  min-height: 100%;
  align-content: center;
}

.error-state {
  border-color: rgba(176, 79, 87, 0.2);
  background: linear-gradient(180deg, var(--danger-soft), rgba(255, 255, 255, 0.92));
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: minmax(225px, 0.56fr) minmax(0, 1.44fr);
  }

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

@media (max-width: 920px) {
  .app-shell {
    width: min(100% - 1rem, 1680px);
    margin: 0.5rem auto 1rem;
    grid-template-columns: 1fr;
  }

  .column-shell {
    min-height: auto;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .column-shell,
  .panel,
  .hero-card,
  .thread-banner {
    border-radius: 24px;
  }

  .column-shell,
  .panel {
    padding: 0.95rem;
  }

  .search-row,
  .detail-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .thread-top,
  .message-meta,
  .message-footer,
  .avatar-line {
    flex-direction: column;
    align-items: stretch;
  }

  .timestamp {
    white-space: normal;
  }
}
