:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --border: #d8dde5;
  --text: #1d2530;
  --muted: #657184;
  --accent: #116d6e;
  --accent-dark: #0d5556;
  --mark: #ffe08a;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 32px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

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

.stats {
  display: grid;
  grid-template-columns: 180px 180px minmax(0, 1fr);
  gap: 16px;
  margin-bottom: 18px;
}

.stat,
.rank,
.notice,
.filters,
.message {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat {
  padding: 18px;
}

.stat span,
.rank > span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.stat strong {
  font-size: 34px;
  line-height: 1;
}

.rank {
  padding: 14px 16px;
}

.rank ol {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 18px;
  margin: 0;
  padding-left: 20px;
}

.rank li {
  min-width: 0;
}

.rank li span {
  display: inline-block;
  max-width: calc(100% - 48px);
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  white-space: nowrap;
}

.rank b {
  float: right;
  color: var(--accent-dark);
}

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto auto auto auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

input,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 7px 10px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--text);
}

.check input {
  width: 16px;
  min-height: 16px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 7px 14px;
  text-decoration: none;
}

.ghost {
  background: #fff;
  color: var(--accent-dark);
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin: 18px 0 10px;
}

.messages {
  display: grid;
  gap: 10px;
}

.message-toggle {
  display: block;
  width: 100%;
  min-height: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 14px 16px;
  text-align: left;
}

.message-toggle:hover {
  background: #f9fbfc;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.meta b {
  color: var(--accent-dark);
}

.summary {
  white-space: normal;
  word-break: break-word;
}

.full-text {
  border-top: 1px solid var(--border);
  padding: 14px 16px 18px;
}

.full-text p {
  white-space: pre-wrap;
  word-break: break-word;
}

.full-text a {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent-dark);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.media-item {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f5f7f8;
  overflow: hidden;
}

img.media-item,
.media-item img,
video.media-item {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

mark {
  background: var(--mark);
  border-radius: 3px;
  padding: 0 2px;
}

.pager {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

.notice {
  padding: 24px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-box {
  width: min(360px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.form-error {
  color: #b42318;
  font-size: 13px;
}

@media (max-width: 920px) {
  .stats,
  .filters {
    grid-template-columns: 1fr 1fr;
  }

  .rank {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .topbar,
  .result-head {
    align-items: stretch;
    flex-direction: column;
  }

  .stats,
  .filters,
  .rank ol {
    grid-template-columns: 1fr;
  }
}
