:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #151922;
  --muted: #647084;
  --line: #e4e8f0;
  --brand: #5865f2;
  --soft: #f0f3ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  padding: 28px max(18px, calc((100vw - 1120px) / 2)) 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

h1 {
  margin: 0;
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.05;
  letter-spacing: 0;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  min-width: 240px;
}

.stats span,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.shell {
  width: min(1120px, calc(100vw - 36px));
  margin: 20px auto 40px;
}

.search-panel,
.summary,
.panel,
.card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 12px 30px rgba(36, 43, 62, 0.06);
}

.search-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.search-row,
.filter-row {
  display: grid;
  gap: 10px;
}

.search-row {
  grid-template-columns: minmax(0, 1fr) 150px 96px;
}

.filter-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

input,
select,
button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 11px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

button {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 650;
  cursor: pointer;
}

button:hover {
  background: #4752c4;
}

.summary {
  display: none;
  margin-top: 14px;
  padding: 14px;
}

.summary.visible {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.results {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.browser {
  display: grid;
  grid-template-columns: 260px 300px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 50px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 0;
  font-size: 15px;
}

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

.list {
  display: grid;
  max-height: 640px;
  overflow: auto;
}

.list-item {
  display: grid;
  gap: 4px;
  width: 100%;
  height: auto;
  min-height: 58px;
  justify-items: start;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.list-item:hover,
.list-item.active {
  background: var(--soft);
  color: var(--text);
}

.list-item strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.messages-panel .results {
  max-height: 640px;
  overflow: auto;
  margin-top: 0;
  padding: 12px;
}

.light-button {
  width: auto;
  height: 32px;
  border-color: var(--line);
  background: #fff;
  color: var(--brand);
}

.light-button:hover {
  background: var(--soft);
  color: var(--brand);
}

.user-panel {
  display: none;
  margin-top: 14px;
}

.user-panel.visible {
  display: block;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  padding: 12px;
}

.user-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  height: auto;
  border-color: var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.user-card:hover {
  background: var(--soft);
  color: var(--text);
}

.user-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--soft);
}

.avatar[hidden] {
  display: block;
  visibility: hidden;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
}

.author {
  font-weight: 700;
}

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

.text {
  margin-top: 6px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.links a {
  max-width: 320px;
  overflow: hidden;
  border-radius: 6px;
  padding: 5px 8px;
  background: var(--soft);
  color: var(--brand);
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.empty {
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 760px) {
  .topbar {
    display: block;
  }

  .stats {
    justify-content: flex-start;
    margin-top: 14px;
  }

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

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

  .list,
  .messages-panel .results {
    max-height: 420px;
  }
}
