:root {
  color-scheme: light;
  --bg: #f7f3ee;
  --surface: #fffdf8;
  --surface-soft: #f1e7dc;
  --ink: #2b241f;
  --muted: #6f645c;
  --line: #ded2c5;
  --accent: #c96442;
  --accent-dark: #8f3f2b;
  --accent-soft: #f3dfd5;
  --aubergine: #3d2f3c;
  --amber: #b86f2d;
  --danger: #9f352f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.topbar {
  display: grid;
  grid-template-columns: 220px minmax(260px, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 20px 32px;
  background: var(--aubergine);
  color: white;
}

.brand-logo {
  display: block;
  width: min(176px, 38vw);
  height: auto;
}

.title-block {
  display: flex;
  align-items: center;
  min-width: 0;
}

.eyebrow {
  margin: 0 0 4px;
  color: #e7b6a0;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
}

main {
  padding: 24px 32px 48px;
}

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  padding: 8px 14px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

.top-actions button,
.dialog-actions button:last-child,
.judge-actions button {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-email {
  color: #f2d8ca;
  font-size: 13px;
}

.hidden {
  display: none !important;
}

.login-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 20px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 22px;
}

.login-panel h2 {
  margin-bottom: 8px;
}

.login-panel p {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 10px;
  padding: 0;
}

.login-message {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--accent-dark);
  font-weight: 700;
}

.domain-hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.tabs button {
  font-weight: 700;
}

.tabs button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.summary span {
  display: block;
  font-size: 26px;
  font-weight: 800;
}

.summary small {
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 18px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-title h2 {
  margin: 0;
  font-size: 18px;
}

.section-title p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.stacked-title {
  display: grid;
  align-items: start;
}

.inline-sort {
  min-width: 180px;
}

.lead-list,
.update-list {
  display: grid;
  gap: 12px;
}

.lead,
.update {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.lead-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.lead h3 {
  margin-bottom: 6px;
  font-size: 17px;
}

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

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  background: #fbf7f1;
}

.rating {
  min-width: 72px;
  color: var(--amber);
  font-weight: 800;
  text-align: right;
}

.desc {
  margin: 12px 0;
  color: #443b35;
  line-height: 1.55;
}

.lead-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.lead-grid strong {
  display: block;
  color: var(--ink);
}

.lead-footer {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-top: 14px;
}

.link-actions,
.judge-actions,
.update-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.judge-actions {
  justify-content: flex-end;
  margin-left: auto;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
  font-weight: 700;
}

a:hover {
  text-decoration: underline;
}

.status {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.status.danger {
  color: var(--danger);
}

.update h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.update p {
  color: #443b35;
  font-size: 13px;
  line-height: 1.5;
}

.update-actions button {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 13px;
}

.update-actions button.voted {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
}

.leaderboard-title {
  align-items: start;
}

.leaderboard-grid {
  display: grid;
  gap: 16px;
}

.leaderboard-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.leaderboard-card h3 {
  margin-bottom: 4px;
  font-size: 17px;
}

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

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
}

.leaderboard-table th,
.leaderboard-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 10px;
  text-align: left;
}

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

.leaderboard-table tr:last-child td {
  border-bottom: 0;
}

.rank {
  color: var(--amber);
  font-weight: 900;
}

.muted-cell {
  color: var(--muted);
}

dialog {
  width: min(640px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: var(--surface);
}

dialog::backdrop {
  background: rgb(43 36 31 / 0.42);
}

form {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.dialog-head h3 {
  margin: 0;
}

.dialog-head button {
  width: 34px;
  min-height: 34px;
  padding: 0;
  font-size: 20px;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.check-row input {
  width: auto;
}

h4 {
  margin-bottom: 8px;
  font-size: 14px;
}

.log-list {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: #fbf7f1;
  color: var(--muted);
  font-size: 13px;
}

.log-item strong,
.log-item span {
  display: block;
}

.log-item strong {
  color: var(--ink);
  margin-bottom: 4px;
}

.log-item p {
  margin: 6px 0 0;
}

.empty,
.error {
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 24px;
}

.empty.compact {
  padding: 12px;
  font-size: 13px;
}

.error {
  border-color: #dba6a1;
  color: var(--danger);
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 14px;
  }

  .brand-logo {
    width: 160px;
  }

  h1 {
    font-size: 26px;
  }

  .filters,
  .summary,
  .layout,
  .login-panel {
    grid-template-columns: 1fr;
  }

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

  .lead-footer {
    display: grid;
  }

  .judge-actions {
    justify-content: flex-start;
    margin-left: 0;
  }

  .topbar,
  main {
    padding-left: 18px;
    padding-right: 18px;
  }
}
