:root {
  --bg: #f6f2e8;
  --bg-ink: #15110b;
  --surface: #fffdf7;
  --surface-strong: #fff8e6;
  --line: #d8c9aa;
  --line-strong: #ad8f5f;
  --text: #1c1811;
  --muted: #736951;
  --accent: #25655b;
  --accent-strong: #16443e;
  --accent-soft: #dceee6;
  --gold: #b77b18;
  --gold-soft: #fff1c8;
  --warn: #a84f25;
  --blue: #244f8f;
  --danger: #a4332d;
  --shadow: 0 18px 45px rgba(49, 38, 19, 0.12);
  --radius: 8px;
  --font-display: "Palatino Linotype", "Noto Serif SC", "Source Han Serif SC", serif;
  --font-body: "Microsoft YaHei UI", "Noto Sans SC", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(173, 143, 95, 0.08) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(180deg, rgba(173, 143, 95, 0.08) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--bg);
}

body {
  margin: 0;
  min-width: 320px;
  font-family: var(--font-body);
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

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

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.auth-card {
  width: min(460px, 100%);
  display: grid;
  gap: 24px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.92);
  box-shadow: var(--shadow);
}

.auth-card h1 {
  margin: 0;
  font-size: 46px;
  line-height: 1;
}

.auth-copy {
  margin: 12px 0 0;
  color: var(--muted);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(173, 143, 95, 0.38);
  background: rgba(255, 253, 247, 0.92);
  backdrop-filter: blur(14px);
}

.header-inner {
  width: min(1180px, calc(100% - 32px));
  height: 72px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand,
.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--bg-ink);
  color: #ffe9ab;
  font-family: var(--font-display);
  font-size: 22px;
}

.brand strong,
h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: 0;
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-chip {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.icon-button,
.primary-button,
.ghost-button,
.link-button,
.favorite-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.icon-button {
  width: 42px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent);
  font-size: 21px;
}

.primary-button {
  padding: 0 20px;
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: #fffdf7;
}

.ghost-button,
.link-button,
.favorite-button {
  padding: 0 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--accent-strong);
}

.ghost-button.compact {
  min-height: 36px;
  padding: 0 12px;
}

.favorite-button.active {
  border-color: rgba(183, 123, 24, 0.5);
  background: var(--gold-soft);
  color: #87570b;
}

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

.primary-button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
  transform: none;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(330px, 420px);
  gap: 32px;
  padding: 42px 0 28px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(36px, 6vw, 72px);
  line-height: 0.95;
}

.overview-text {
  max-width: 660px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.overview-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.78);
  box-shadow: var(--shadow);
}

.overview-stats div {
  min-width: 0;
  padding: 18px 16px;
  border-left: 1px solid var(--line);
}

.overview-stats div:first-child {
  border-left: 0;
}

.overview-stats span {
  display: block;
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1;
  white-space: nowrap;
}

.overview-stats small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.toolbar,
.content-shell {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 247, 0.82);
  box-shadow: var(--shadow);
}

.toolbar {
  padding: 18px;
}

.filter-topline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 180px;
  gap: 14px;
  align-items: end;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(173, 143, 95, 0.34);
}

.category-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.category-row > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-tab {
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent-strong);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.tag-tab:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.tag-tab.active {
  border-color: var(--accent-strong);
  background: var(--accent);
  color: #fffdf7;
}

.inline-check {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--accent-strong);
  white-space: nowrap;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(128px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.field,
.custom-select-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field span,
.field-label {
  color: var(--muted);
  font-size: 13px;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0 12px;
  outline: none;
}

.custom-select {
  position: relative;
  min-width: 0;
}

.select-trigger {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.select-trigger span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select.disabled .select-trigger {
  cursor: not-allowed;
  background: #f0eadc;
  color: #9a907b;
}

.select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  display: none;
  max-height: 260px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 18px 40px rgba(49, 38, 19, 0.18);
}

.custom-select.open .select-menu {
  display: grid;
  gap: 3px;
}

.select-option {
  min-height: 34px;
  padding: 6px 9px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.select-option:hover,
.select-option.selected {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

input:focus,
.select-trigger:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(37, 101, 91, 0.22);
  outline-offset: 2px;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.content-shell {
  margin: 18px 0 28px;
  padding: 22px;
}

.list-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.list-heading h2 {
  margin: 0;
  font-size: 30px;
}

.list-heading p:last-child {
  margin: 6px 0 0;
  color: var(--muted);
  text-align: right;
}

.article-list {
  display: grid;
  gap: 14px;
}

.article-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 178px;
  gap: 20px;
  padding: 18px;
  border: 1px solid rgba(173, 143, 95, 0.44);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #fffdf7, #fff9ed);
  animation: rise 240ms ease both;
}

.article-card.current-year {
  border-color: rgba(183, 123, 24, 0.72);
  background: linear-gradient(180deg, #fffdf7, #fff4d5);
}

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

.article-kicker,
.article-tags,
.article-meta,
.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.article-kicker {
  margin-bottom: 8px;
}

.badge {
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.badge.status-open {
  border-color: rgba(37, 101, 91, 0.32);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge.status-running {
  border-color: rgba(36, 79, 143, 0.3);
  background: #e4edf9;
  color: var(--blue);
}

.badge.status-upcoming {
  border-color: rgba(168, 79, 37, 0.26);
  background: #f8e4d5;
  color: var(--warn);
}

.badge.status-ended {
  background: #eee8dc;
}

.year-badge {
  border-color: rgba(183, 123, 24, 0.5);
  background: var(--gold-soft);
  color: #87570b;
  font-weight: 700;
}

.article-title {
  margin: 0 0 7px;
  font-size: 21px;
  line-height: 1.35;
}

.article-title button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.article-title button:hover {
  color: var(--accent);
}

.article-summary {
  display: -webkit-box;
  min-height: 48px;
  margin: 0 0 12px;
  overflow: hidden;
  color: var(--muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.article-tags {
  margin-bottom: 12px;
}

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

.article-side {
  display: grid;
  align-content: space-between;
  justify-items: end;
  gap: 14px;
  border-left: 1px solid var(--line);
  padding-left: 18px;
}

.deadline {
  text-align: right;
}

.deadline strong {
  display: block;
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1;
}

.deadline span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.side-actions {
  display: grid;
  gap: 8px;
  justify-items: stretch;
  width: 100%;
}

.loading-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.loading-grid span {
  height: 152px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #eee4d0 25%, #fff9ed 37%, #eee4d0 63%);
  background-size: 400% 100%;
  animation: shimmer 1.2s ease infinite;
}

.state-panel,
.empty-state {
  display: grid;
  gap: 10px;
  justify-items: start;
  margin: 12px 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.empty-state span,
.state-panel span {
  color: var(--muted);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  margin-top: 20px;
}

#pageInfo {
  min-width: 132px;
  color: var(--muted);
  text-align: center;
}

.site-footer {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 30px;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--muted);
  font-size: 13px;
}

.detail-dialog {
  width: min(850px, calc(100% - 28px));
  max-height: calc(100% - 40px);
  border: 0;
  padding: 0;
  border-radius: var(--radius);
  background: transparent;
}

.detail-dialog::backdrop {
  background: rgba(22, 17, 9, 0.55);
  backdrop-filter: blur(4px);
}

.dialog-card {
  position: relative;
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 28px 80px rgba(20, 16, 8, 0.32);
}

.dialog-close {
  position: sticky;
  top: 14px;
  float: right;
  margin: 14px 14px 0 0;
  z-index: 2;
}

.detail-body {
  padding: 28px;
}

.detail-body h3 {
  margin: 0 54px 12px 0;
  font-size: 31px;
  line-height: 1.25;
}

.detail-summary {
  color: var(--muted);
  font-size: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.detail-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.hidden,
[hidden] {
  display: none !important;
}

@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .overview,
  .filter-grid,
  .filter-topline {
    grid-template-columns: 1fr;
  }

  .category-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .overview-stats,
  .filter-actions,
  .year-field {
    width: 100%;
  }

  .filter-actions button {
    flex: 1;
  }
}

@media (max-width: 720px) {
  .header-inner,
  main,
  .site-footer {
    width: min(100% - 22px, 1180px);
  }

  .header-inner {
    height: auto;
    min-height: 64px;
    padding: 10px 0;
    align-items: flex-start;
  }

  .brand strong {
    font-size: 16px;
  }

  .brand small,
  .user-chip {
    display: none;
  }

  .header-actions {
    gap: 6px;
  }

  .overview {
    grid-template-columns: 1fr;
    padding-top: 26px;
  }

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

  .overview-stats div,
  .overview-stats div:first-child {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .overview-stats div:first-child {
    border-top: 0;
  }

  .content-shell,
  .toolbar {
    padding: 14px;
  }

  .list-heading,
  .site-footer {
    display: grid;
  }

  .list-heading p:last-child {
    text-align: left;
  }

  .article-card {
    grid-template-columns: 1fr;
  }

  .article-side {
    grid-template-columns: 1fr;
    justify-items: start;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 14px 0 0;
  }

  .deadline {
    text-align: left;
  }

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

  .pagination {
    display: grid;
    grid-template-columns: 1fr;
  }

  #pageInfo {
    order: -1;
    min-width: 0;
  }

  .detail-body {
    padding: 22px 16px;
  }

  .detail-body h3 {
    margin-right: 46px;
    font-size: 25px;
  }
}

/* v1 desk refresh: denser research-desk layout, less decorative weight. */
html {
  background: #f7f5ef;
}

.mobile-favorites-toggle,
.panel-close {
  display: none;
}

.workspace {
  width: min(1440px, calc(100% - 28px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}

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

.overview {
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  padding: 24px 0 14px;
}

.overview h1 {
  font-size: 38px;
}

.overview-text {
  max-width: 720px;
  margin-top: 10px;
  font-size: 15px;
}

.overview-stats,
.toolbar,
.content-shell,
.favorites-panel,
.admin-view,
.admin-create-form,
.admin-table-wrap {
  border-radius: 6px;
  box-shadow: none;
}

.overview-stats {
  align-self: stretch;
  background: var(--surface);
}

.toolbar,
.content-shell {
  padding: 16px;
}

.toolbar {
  margin-bottom: 14px;
}

.filter-grid {
  grid-template-columns: repeat(5, minmax(132px, 1fr)) auto;
  gap: 10px;
}

.content-shell {
  margin-bottom: 0;
}

.list-heading {
  margin-bottom: 12px;
}

.list-heading h2,
.favorites-panel h2,
.admin-heading h1 {
  font-size: 24px;
}

.article-list {
  gap: 10px;
}

.article-card {
  grid-template-columns: minmax(0, 1fr) 150px;
  padding: 14px 16px;
  border-radius: 6px;
  animation: none;
}

.article-card.current-year {
  border-left: 4px solid var(--accent);
}

.article-title {
  margin: 8px 0 6px;
}

.article-title button {
  font-size: 19px;
}

.article-summary {
  -webkit-line-clamp: 2;
  margin: 0 0 10px;
  font-size: 14px;
}

.article-meta,
.article-tags,
.article-kicker {
  gap: 6px;
}

.article-side {
  padding-left: 14px;
}

.deadline strong {
  font-size: 24px;
}

.favorites-panel {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 108px);
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.panel-heading,
.admin-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-meta {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.favorites-list {
  display: grid;
  gap: 10px;
}

.favorite-item {
  display: grid;
  gap: 7px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.favorite-item:first-child {
  border-top: 0;
}

.favorite-title {
  padding: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  line-height: 1.45;
  text-align: left;
}

.favorite-title:hover {
  color: var(--accent-strong);
}

.favorite-meta,
.favorite-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.favorite-actions button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-strong);
  color: var(--danger);
  cursor: pointer;
}

.side-empty {
  display: grid;
  gap: 6px;
  padding: 18px 0;
  color: var(--muted);
  font-size: 13px;
}

.side-empty strong {
  color: var(--text);
}

.admin-view {
  grid-column: 1 / -1;
  margin: 24px 0;
  padding: 18px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.admin-create-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto minmax(220px, 1fr);
  gap: 12px;
  align-items: end;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.admin-table th,
.admin-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
}

.status-pill.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill.disabled {
  background: #f3dfda;
  color: var(--danger);
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  .favorites-panel {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 80;
    width: min(360px, calc(100% - 34px));
    max-height: none;
    border-radius: 0;
    transform: translateX(102%);
    transition: transform 180ms ease;
  }

  .favorites-panel.open {
    transform: translateX(0);
  }

  .favorites-panel.hidden {
    display: block !important;
  }

  .mobile-favorites-toggle,
  .panel-close {
    display: inline-flex;
  }
}

@media (max-width: 760px) {
  .workspace,
  .header-inner,
  .site-footer {
    width: min(100% - 20px, 1180px);
  }

  .overview,
  .filter-grid,
  .admin-create-form {
    grid-template-columns: 1fr;
  }

  .overview h1 {
    font-size: 30px;
  }

  .article-card {
    grid-template-columns: 1fr;
    padding: 13px;
  }

  .article-side {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 12px 0 0;
  }

  .admin-table th,
  .admin-table td {
    padding: 9px;
  }
}
