/*
  1280x800, collapsed activity, empty status:
  header 48 + summary 56 + activity 32 + pad 12 + toolbar 36 + gap 8
  + three 188px rows + two 8px gaps = 772. The fourth row scrolls.
  Nickname controls stay inside the 188px card.
*/

.summary, .activity {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  color: var(--ink);
}

.summary {
  height: auto;
  min-height: var(--summary-h);
  justify-content: space-between;
  align-items: center;
  padding-top: 6px;
  padding-bottom: 6px;
}

.summary-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
  flex: 1;
}

.summary-ours { flex: none; min-width: 0; }

.summary-scoreline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
}

.summary-scoreline strong {
  font-size: 22px;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.summary-scoreline span,
.summary-update-label {
  font-size: 12px;
  line-height: 1.25;
}

.summary-update-label,
#stat-sync { margin: 0; }

.left-rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  align-self: stretch;
  overflow: visible;
}

.rank-rail {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-card);
  padding: 8px 8px 6px;
  min-width: 0;
  overflow: visible;
}

.rank-rail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.rank-rail-head h2 {
  margin: 0;
  font-size: 13px;
  line-height: 16px;
  font-weight: 700;
  color: var(--muted);
}

.rank-rail-head a {
  font-size: 12px;
  line-height: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.rank-cutoff {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 14px;
  font-weight: 700;
}

.rank-cutoff[hidden] { display: none !important; }

.summary-standings {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
  min-width: 0;
  overflow: visible;
  font-size: 12px;
  line-height: 16px;
}

.summary-standings li {
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr) auto;
  column-gap: 6px;
  align-items: center;
  min-width: 0;
  min-height: 18px;
  padding: 1px 4px;
  border-radius: 6px;
  overflow: hidden;
  color: var(--body);
}

.summary-standings .stand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-standings .stand-rank,
.summary-standings .stand-score {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.summary-standings li.is-rank-1,
.summary-standings li.is-rank-2,
.summary-standings li.is-rank-3 {
  font-weight: 600;
}

.summary-standings li.is-rank-1 { background: #fbf6ea; }
.summary-standings li.is-rank-2 { background: #f3f5f7; }
.summary-standings li.is-rank-3 { background: #f8f1ea; }

.summary-standings li.is-rank-1 .stand-rank,
.summary-standings li.is-rank-2 .stand-rank,
.summary-standings li.is-rank-3 .stand-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
  width: 1.35em;
  height: 1.35em;
  border-radius: 4px;
  font-weight: 700;
  line-height: 1;
}

.summary-standings li.is-rank-1 .stand-rank { background: #f0e2b6; color: #6d5620; }
.summary-standings li.is-rank-2 .stand-rank { background: #e3e6eb; color: #3e4650; }
.summary-standings li.is-rank-3 .stand-rank { background: #edd9c6; color: #6b4630; }

.summary-standings li.is-ours {
  background: var(--accent-weak);
  color: var(--ink);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent);
}

.summary-standings li.is-cutoff-after {
  border-bottom: 2px dashed #5c6b78;
}

.summary-side {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 12px;
  flex: none;
}

#stat-sync { color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }

.summary-update-label { color: var(--muted); font-weight: 600; }

.activity {
  height: var(--activity-h);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: var(--activity-h);
  overflow: hidden;
}

.activity.is-open {
  height: auto;
  overflow: visible;
  grid-template-rows: var(--activity-h) auto;
  align-items: start;
  padding-top: 4px;
  padding-bottom: 8px;
}

.remaining, .contest-state {
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  color: var(--body);
}

.summary dl {
  display: flex;
  gap: 16px;
  min-width: 0;
  flex: 1;
  align-items: baseline;
}

.summary dl div {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  align-items: flex-start;
  min-width: 0;
}

.summary dt {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 600;
}

.summary dd {
  font-size: 22px;
  line-height: 1.15;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

#stat-sync {
  font-size: 12px;
  line-height: 1.25;
  font-weight: 600;
  text-align: right;
}

#stat-sync.is-error,
#stat-sync.is-stale {
  padding: 0 6px;
  border-radius: 6px;
  font-weight: 700;
}

#stat-sync.is-error { color: var(--danger); background: var(--danger-bg); }
#stat-sync.is-stale { color: var(--amber); background: var(--amber-bg); }

.activity-preview, .live-status { grid-column: 1; grid-row: 1; min-width: 0; }

.live-status:empty { display: none; }

.live-status {
  color: var(--danger);
  font-weight: 600;
  background: var(--surface);
}

.activity-line {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
}

a.activity-line:hover { text-decoration: underline; }

.activity-more {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-top: 4px;
}

.activity-more[hidden]:not([hidden="until-found" i]) { display: none !important; }

#activity-toggle {
  grid-column: 2;
  grid-row: 1;
  height: 28px;
  min-height: 28px;
}

.workspace {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  column-gap: 16px;
  align-items: start;
  padding: 12px 16px 16px;
  max-width: 100%;
}

.filter-rail { min-width: 0; }

.filter-body {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-card);
  padding: 12px 12px 8px;
}

.filter-body h2 {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}

.filter-all, .filter-parent, .filter-leaves label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  font-size: 14px;
  font-weight: 500;
}

.filter-parent { font-weight: 700; }

.filter-leaves { margin: 0 0 8px 22px; }

.filter-leaves label { color: var(--body); font-weight: 500; }

.count {
  margin-left: auto;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.filter-rail > summary {
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 8px;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-control);
  padding: 8px 12px;
}

.board-main { min-width: 0; }

.toolbar {
  min-height: var(--toolbar-h);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: var(--grid-gap);
  padding: 2px 8px;
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--body);
  white-space: nowrap;
}

.toolbar input, .toolbar select {
  height: 32px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  padding: 0 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

#search-input { width: 148px; min-width: 0; }

#visible-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  color: var(--ink);
}

.sort-note {
  color: var(--body);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.board-status, .board-error, .empty-note {
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  line-height: 1.45;
}

.board-error { color: var(--danger); }

.problem-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--grid-gap);
  align-items: stretch;
}

.problem-card {
  position: relative;
  height: var(--card-h);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  min-width: 0;
}

.problem-card.is-solved {
  background: var(--solved-bg);
  border-color: var(--solved-line);
}

.problem-card.is-menu { z-index: 4; }

.problem-open {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 12px 4px;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
}

.card-kicker {
  height: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.card-kind {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--body);
  font-size: 13px;
  font-weight: 600;
}

.points {
  margin-left: auto;
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex: none;
  font-variant-numeric: tabular-nums;
}

.points-value { font-size: 20px; line-height: 1; font-weight: 700; color: var(--ink); }

.points-note { font-size: 12px; color: var(--muted); font-weight: 600; }

.card-title {
  height: 44px;
  font-size: 17px;
  line-height: 1.3;
  font-weight: 700;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow-wrap: anywhere;
}

.card-meta {
  height: 18px;
  display: flex;
  gap: 8px;
  align-items: center;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
}

.card-meta span { white-space: nowrap; }

.meta-update { flex: none; }

.meta-post {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-done {
  display: inline-flex;
  align-items: center;
  flex: none;
  color: var(--solved);
}

.meta-findings, .meta-files { flex: none; }

.meta-solve {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-solve.is-solved { color: var(--solved); font-weight: 700; }
.meta-solve.is-latest-unknown { color: var(--amber); font-weight: 700; }

.nick-grid {
  height: 72px;
  flex: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  padding: 0 8px 8px;
}

.nick {
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  justify-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 1px;
  margin: 0;
  padding: 0 4px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 12px;
  line-height: 1.1;
  text-align: left;
}

button.nick { cursor: pointer; }
button.nick:hover { border-color: var(--line); }
button.nick:disabled { cursor: not-allowed; opacity: 1; }

.nick-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 5px;
  min-width: 0;
  width: 100%;
}

.nick-name {
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
  color: var(--ink);
}

.nick-marks {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex: none;
}

.nick-live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.nick-star { flex: none; font-size: 12px; line-height: 1; }

.nick-when {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
}

.nick.is-empty { border-color: transparent; background: transparent; }

.nick.is-live {
  border-color: var(--accent);
  background: var(--accent-weak);
  animation: live-border 1.6s ease-in-out infinite;
}

.nick.is-focus {
  border-color: var(--amber-line);
  background: var(--amber-bg);
  animation: exclusive-emphasis 1.8s ease-in-out infinite;
}

.nick.is-live.is-focus {
  border-color: var(--accent);
  background: var(--amber-bg);
  animation: live-border 1.6s ease-in-out infinite, exclusive-emphasis 1.8s ease-in-out infinite;
}

button.nick.is-live:hover,
button.nick.is-live.is-focus:hover { border-color: var(--accent); }
button.nick.is-focus:hover { border-color: var(--amber); }

.exclusive-pop {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 80px;
  z-index: 5;
  max-height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(25, 31, 40, 0.12);
}

.activity-rows { display: flex; flex-direction: column; gap: 4px; }

.activity-pager {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.activity-page-label, .activity-bound { font-size: 13px; color: var(--muted); }

.activity-fresh { margin: 6px 0 0; font-size: 13px; font-weight: 700; color: var(--primary); }

.activity-pager button:disabled { opacity: 0.45; }

.exclusive-pop button {
  min-height: 32px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  padding: 4px 8px;
  font-weight: 600;
}

@media (min-width: 901px) {
  .filter-rail > summary {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .filter-rail > .filter-body { display: block !important; }
  .filter-rail { position: sticky; top: 12px; }
}

@media (max-width: 900px) {
  .problem-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .problem-card { height: auto; min-height: var(--card-h); }
  .toolbar { height: auto; flex-wrap: wrap; }
  .toolbar label { flex: 1 1 140px; }
  #search-input { width: auto; flex: 1 1 8em; max-width: 100%; }
}

@media (max-width: 680px) {
  .summary { height: auto; min-height: var(--summary-h); flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .summary dl { flex-wrap: wrap; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .problem-grid { grid-template-columns: minmax(0, 1fr); }
  .toolbar label { flex: 1 1 100%; }
  .toolbar input, .toolbar select { font-size: 16px; }
}
