:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-soft: #eef3ef;
  --text: #20242a;
  --muted: #66706f;
  --line: #d8ded9;
  --primary: #145c72;
  --primary-dark: #0d4252;
  --accent: #d97706;
  --accent-dark: #a55504;
  --success: #157347;
  --warning: #a16207;
  --danger: #b42318;
  --info: #2563eb;
  --shadow: 0 18px 50px rgba(25, 35, 39, 0.16);
  --radius: 8px;
  --header-h: 72px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial,
    sans-serif;
  letter-spacing: 0;
}

body.dialog-open {
  overflow: hidden;
}

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

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.is-hidden {
  display: none !important;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: var(--header-h);
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid rgba(216, 222, 217, 0.85);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #fff;
  background: var(--primary);
  border-radius: var(--radius);
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand-text {
  max-width: 300px;
  overflow: hidden;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
}

.nav-item,
.auth-tab {
  min-height: 40px;
  padding: 0 13px;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.nav-item:hover,
.auth-tab:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.nav-item.is-active,
.auth-tab.is-active {
  color: var(--primary-dark);
  background: #e3f0ed;
  border-color: #bed8d1;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition:
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.button {
  padding: 0 16px;
  font-weight: 700;
}

.button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
}

.button.primary {
  color: #fff;
  background: var(--primary);
}

.button.primary:hover {
  background: var(--primary-dark);
}

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

.button.accent:hover {
  background: var(--accent-dark);
}

.button.ghost,
.icon-button {
  color: var(--text);
  background: var(--surface);
  border-color: var(--line);
}

.button.ghost:hover,
.icon-button:hover {
  background: var(--surface-soft);
}

.button.full {
  width: 100%;
}

.button:focus-visible,
.icon-button:focus-visible,
.nav-item:focus-visible,
.auth-tab:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(20, 92, 114, 0.28);
  outline-offset: 2px;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.mobile-menu {
  display: none;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 4px 4px 8px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: #fff;
  background: var(--accent);
  border-radius: 50%;
  font-weight: 800;
}

.user-chip-name {
  max-width: 96px;
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.hero {
  position: relative;
  min-height: calc(100vh - var(--header-h) - 56px);
  overflow: hidden;
  background: #0e2028;
}

.hero-media {
  position: absolute;
  inset: 0;
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.02);
}

.hero-shade {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(7, 22, 27, 0.82), rgba(7, 22, 27, 0.46) 48%, rgba(7, 22, 27, 0.18)),
    linear-gradient(0deg, rgba(7, 22, 27, 0.22), rgba(7, 22, 27, 0.08));
}

.hero-content {
  position: relative;
  z-index: 1;
  width: min(1060px, calc(100% - 40px));
  margin: 0 auto;
  padding: 104px 0 74px;
  color: #fff;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #f6b55a;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  max-width: 760px;
  margin: 0;
  font-size: 4.5rem;
  line-height: 1;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 650px;
  margin: 22px 0 28px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.16rem;
  line-height: 1.8;
}

.hero-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: min(680px, 100%);
  min-height: 62px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-search svg {
  width: 22px;
  height: 22px;
  margin-left: 8px;
  color: var(--muted);
}

.hero-search input {
  min-width: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.hero-dots {
  display: flex;
  gap: 8px;
  margin-top: 30px;
}

.hero-dot {
  width: 34px;
  height: 6px;
  padding: 0;
  background: rgba(255, 255, 255, 0.44);
  border: 0;
  border-radius: 999px;
}

.hero-dot.is-active {
  background: #fff;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  width: min(1120px, calc(100% - 40px));
  margin: -56px auto 0;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 22px;
  background: var(--surface);
}

.metric-value {
  color: var(--primary-dark);
  font-size: 2rem;
  font-weight: 850;
}

.metric-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.content-section {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 58px 0;
}

.content-section.narrow {
  width: min(820px, calc(100% - 40px));
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.section-head h2 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
}

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

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

.post-card {
  display: grid;
  grid-template-rows: 188px 1fr;
  min-width: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.post-card-image {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: var(--surface-soft);
}

.post-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 240ms ease;
}

.post-card:hover .post-card-image img {
  transform: scale(1.04);
}

.post-status {
  position: absolute;
  top: 12px;
  left: 12px;
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  color: #fff;
  background: rgba(20, 92, 114, 0.92);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.post-status.pending {
  background: rgba(161, 98, 7, 0.94);
}

.post-status.rejected {
  background: rgba(180, 35, 24, 0.94);
}

.post-card-body {
  display: grid;
  gap: 10px;
  padding: 16px;
}

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

.post-tag {
  color: var(--primary-dark);
  font-weight: 800;
}

.post-card h3 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.35;
}

.post-card p {
  display: -webkit-box;
  min-height: 3.3em;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
}

.mini-meta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.84rem;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(240px, 360px) 1fr;
  gap: 14px;
  align-items: start;
  margin-bottom: 20px;
}

.search-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.search-box svg {
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.search-box input {
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
}

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

.chip {
  min-height: 36px;
  padding: 0 12px;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
}

.chip.is-active,
.chip:hover {
  color: var(--primary-dark);
  background: #e3f0ed;
  border-color: #bed8d1;
}

.gate-panel,
.publish-form,
.table-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.gate-panel {
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 28px;
}

.gate-panel svg {
  width: 30px;
  height: 30px;
  color: var(--primary);
}

.gate-panel h3,
.table-title h3 {
  margin: 0;
}

.gate-panel p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.publish-form {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.form-row {
  display: grid;
  gap: 16px;
}

.form-row.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-weight: 750;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  padding: 12px;
  resize: vertical;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dashboard-layout,
.admin-layout {
  display: grid;
  gap: 18px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.stat-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  color: var(--primary-dark);
  font-size: 1.7rem;
}

.admin-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.9fr);
  gap: 18px;
  align-items: start;
}

.table-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

td {
  color: var(--text);
  font-size: 0.92rem;
}

tbody tr:hover {
  background: #f7faf8;
}

.table-title-cell {
  max-width: 260px;
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.status-pill.published,
.status-pill.active {
  color: #0d5132;
  background: #dff3e8;
}

.status-pill.pending {
  color: #7a4a05;
  background: #fbe7bc;
}

.status-pill.rejected,
.status-pill.suspended {
  color: #8b1a12;
  background: #f8d7d4;
}

.table-select {
  min-height: 34px;
  padding: 0 8px;
  font-size: 0.9rem;
}

.auth-dialog,
.post-dialog {
  width: min(460px, calc(100% - 32px));
  padding: 24px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.post-dialog {
  width: min(760px, calc(100% - 32px));
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
}

dialog::backdrop {
  background: rgba(12, 24, 30, 0.54);
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
}

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

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

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 0.9rem;
}

.post-detail-image {
  width: 100%;
  max-height: 320px;
  object-fit: cover;
  border-radius: var(--radius);
}

.post-detail-content {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.post-detail-content h2 {
  margin: 0;
  font-size: 1.8rem;
  line-height: 1.25;
}

.post-detail-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.8;
  white-space: pre-wrap;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 10px;
  min-height: 220px;
  padding: 32px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed #bcc7c0;
  border-radius: var(--radius);
  text-align: center;
}

.empty-state svg {
  width: 32px;
  height: 32px;
  color: var(--primary);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(360px, calc(100% - 40px));
  padding: 12px 14px;
  color: #fff;
  background: #172026;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.site-footer {
  border-top: 1px solid var(--line);
  background: #172026;
  color: rgba(255, 255, 255, 0.86);
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0;
}

.site-footer strong {
  display: block;
  color: #fff;
}

.site-footer p {
  margin: 7px 0 0;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.9rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 16px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.9rem;
}

@media (max-width: 980px) {
  .site-header {
    grid-template-columns: auto auto 1fr;
    gap: 12px;
    padding: 0 18px;
  }

  .mobile-menu {
    display: inline-flex;
  }

  .top-nav {
    position: absolute;
    top: calc(var(--header-h) - 1px);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 18px;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }

  .top-nav.is-open {
    display: flex;
  }

  .nav-item {
    justify-content: flex-start;
    width: 100%;
  }

  .header-actions {
    justify-self: end;
  }

  .post-grid,
  .post-grid.compact,
  .stat-grid,
  .admin-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  :root {
    --header-h: 64px;
  }

  .site-header {
    padding: 0 12px;
  }

  .brand-text {
    max-width: 172px;
    font-size: 0.86rem;
  }

  #register-button {
    display: none;
  }

  #login-button {
    width: 42px;
    padding: 0;
  }

  #login-button span {
    display: none;
  }

  .user-chip-name {
    display: none;
  }

  .hero {
    min-height: 680px;
  }

  .hero-content {
    width: min(100% - 28px, 1060px);
    padding-top: 82px;
  }

  h1 {
    font-size: 3rem;
    line-height: 1.05;
  }

  .hero-copy {
    font-size: 1rem;
  }

  .hero-search {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .hero-search .button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: calc(100% - 28px);
  }

  .content-section,
  .content-section.narrow {
    width: calc(100% - 28px);
    padding: 42px 0;
  }

  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .post-grid,
  .post-grid.compact,
  .stat-grid,
  .admin-columns,
  .form-row.two {
    grid-template-columns: 1fr;
  }

  .post-card {
    grid-template-rows: 176px 1fr;
  }

  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .button {
    width: 100%;
  }

  .footer-inner {
    align-items: flex-start;
    flex-direction: column;
    width: calc(100% - 28px);
  }

  .footer-links {
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
