:root {
  color-scheme: light;
  --ink: #15181d;
  --muted: #657282;
  --bg: #f7f9fb;
  --panel: #ffffff;
  --line: #d9e0e7;
  --accent: #1f7a68;
  --accent-dark: #155b4d;
  --blue: #345e9f;
  --shadow: 0 14px 42px rgba(32, 42, 54, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  line-height: 1.6;
}

a {
  color: inherit;
}

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

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px max(20px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(247, 249, 251, 0.92);
  backdrop-filter: blur(14px);
}

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

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  letter-spacing: 0;
}

.top-nav {
  display: flex;
  gap: 8px;
}

.top-nav a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

.top-nav a:hover {
  background: #eaf0f4;
  color: var(--ink);
}

main,
.site-footer {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
}

.intro {
  padding: 72px 0 34px;
}

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

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

h1 {
  max-width: 760px;
  margin-bottom: 16px;
  font-size: clamp(34px, 7vw, 64px);
  line-height: 1.04;
  letter-spacing: 0;
}

.intro-copy {
  max-width: 720px;
  color: var(--muted);
  font-size: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 28px;
}

.stats span {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--muted);
}

.stats strong {
  display: block;
  color: var(--ink);
  font-size: 28px;
  line-height: 1.2;
}

.toolbar {
  position: sticky;
  top: 71px;
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(140px, 0.6fr) minmax(140px, 0.6fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea,
button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

input,
select,
textarea {
  width: 100%;
  padding: 0 12px;
  background: white;
  color: var(--ink);
  outline: none;
}

textarea {
  min-height: 96px;
  padding: 10px 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 104, 0.14);
}

button,
.source-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

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

.secondary-button {
  background: white;
  color: var(--ink);
}

.secondary-button:hover {
  background: #eaf0f4;
}

.danger-button {
  background: #a33a3a;
}

.danger-button:hover {
  background: #7f2929;
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.mode-tab {
  background: white;
  color: var(--ink);
}

.mode-tab.active {
  background: var(--accent);
  color: white;
}

#togglePublicBase.active {
  background: var(--accent);
  color: white;
}

.section {
  padding-top: 44px;
}

.section-heading {
  margin-bottom: 18px;
}

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

.timeline-list {
  display: grid;
  gap: 12px;
  padding-bottom: 20px;
}

.date-heading {
  position: sticky;
  top: 156px;
  z-index: 4;
  margin: 12px 0 0;
  padding: 9px 0;
  background: var(--bg);
  color: var(--blue);
  font-size: 20px;
}

.link-card {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.link-time {
  display: grid;
  align-content: center;
  gap: 4px;
  color: var(--muted);
}

.link-time strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.link-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
}

.link-main p {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
}

.link-main h4 {
  margin: 0 0 4px;
  font-size: 18px;
}

.link-main small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.source-link {
  min-height: 42px;
  border-radius: 8px;
  white-space: nowrap;
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.load-more {
  width: 100%;
  margin: 8px 0 52px;
}

.policy {
  padding-bottom: 48px;
}

.policy ul {
  margin: 0;
  padding-left: 20px;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0 42px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.admin-gate {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.gate-card {
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.gate-card h1 {
  margin-bottom: 10px;
  font-size: 36px;
}

.gate-card button {
  width: 100%;
  margin-top: 14px;
}

#gateHelp,
#gateStatus {
  color: var(--muted);
}

#gateStatus {
  display: block;
  margin-top: 10px;
  font-weight: 700;
}

.my-start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0;
}

.editor-panel {
  padding-top: 18px;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.wide-field {
  grid-column: 1 / -1;
}

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

#saveStatus {
  color: var(--muted);
  font-weight: 700;
}

#myStatus {
  color: var(--muted);
  font-weight: 700;
}

.backup-panel {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.backup-panel .section-heading {
  margin-bottom: 8px;
}

.backup-panel h3 {
  margin: 0;
  font-size: 24px;
}

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

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.backup-code {
  min-height: 140px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.publish-panel {
  padding-top: 18px;
}

.publish-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.publish-grid div {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.publish-grid strong,
.publish-grid span {
  display: block;
}

.publish-grid strong {
  font-size: 26px;
}

.publish-grid span,
.publish-note {
  color: var(--muted);
}

.review-summary {
  margin: 14px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
}

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

.review-item {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.review-kind {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: white;
  font-weight: 800;
}

.review-kind.added {
  background: var(--accent);
}

.review-kind.deleted {
  background: #a33a3a;
}

.review-kind.modified {
  background: var(--blue);
}

.review-applied {
  border-color: rgba(31, 122, 104, 0.5);
}

.review-ignored {
  opacity: 0.58;
}

.diff-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin: 8px 0;
  padding: 8px;
  border-radius: 8px;
  background: #f4f7fa;
}

.diff-row span {
  overflow-wrap: anywhere;
}

.publish-steps {
  margin: 0 0 12px;
  padding-left: 22px;
}

code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #eaf0f4;
}

.admin-toolbar {
  position: static;
  margin-bottom: 14px;
}

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

.admin-record {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.admin-record strong,
.admin-record span,
.admin-record small {
  display: block;
}

.admin-record span,
.admin-record p,
.admin-record small {
  color: var(--muted);
}

.admin-record h3,
.admin-record p {
  margin: 0 0 4px;
}

.admin-record-main {
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-source {
  margin: 8px 0;
  padding: 10px;
  border-left: 3px solid var(--line);
  border-radius: 4px;
  background: #f4f7fa;
}

.admin-source span {
  color: var(--blue);
  font-weight: 800;
}

.admin-source small {
  margin-top: 2px;
  color: var(--muted);
}

.admin-source p {
  display: -webkit-box;
  margin: 4px 0 0;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  color: var(--muted);
  white-space: pre-wrap;
}

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

@media (max-width: 760px) {
  .site-header,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .intro {
    padding-top: 44px;
  }

  .stats,
  .toolbar,
  .link-card,
  .link-main,
  .admin-form,
  .admin-record,
  .publish-grid,
  .review-item,
  .diff-row {
    grid-template-columns: 1fr;
  }

  .toolbar,
  .date-heading {
    position: static;
  }

  .source-link {
    width: 100%;
  }

  .card-actions,
  .card-actions button {
    width: 100%;
  }
}
