:root {
  color-scheme: light;
  --bg: #fafafa;
  --panel: #ffffff;
  --text: #09090b;
  --muted: #71717a;
  --line: #e4e4e7;
  --accent: #002fa7;
  --accent-dark: #002278;
  --danger: #ef4444;
  --shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
}

@keyframes page-enter {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

a {
  color: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1040px;
  margin: 0 auto;
  padding: calc(24px + env(safe-area-inset-top, 0px)) 24px 24px;
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

.top-nav {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
}

.top-nav a,
.text-link {
  text-decoration: none;
}

.top-nav a:hover,
.text-link:hover {
  color: var(--accent);
}

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 24px calc(64px + env(safe-area-inset-bottom, 0px));
  animation: page-enter 360ms ease-out both;
}

.hero {
  padding: 38px 0 28px;
}

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

.section h1,
.article h1 {
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1.08;
  margin: 0 0 18px;
}

.hero-intro {
  color: var(--muted);
  font-size: 20px;
  max-width: 680px;
  margin: 0;
}

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

.quick-tool {
  display: grid;
  gap: 8px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.quick-tool label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.quick-tool-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.section {
  padding: 34px 0;
}

.sectioned {
  border-top: 1px solid var(--line);
}

.section.narrow,
.article,
.auth-box {
  max-width: 760px;
  margin: 0 auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-title h1,
.section-title h2 {
  margin: 0;
}

.link-groups {
  display: grid;
  gap: 24px;
}

.link-group h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 15px;
}

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

.link-card {
  display: block;
  min-height: 96px;
  padding: 18px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.link-card span {
  display: block;
  font-weight: 750;
  margin-bottom: 8px;
}

.link-card small,
.admin-row small,
.meta,
.muted {
  color: var(--muted);
}

.link-card small {
  display: block;
  overflow-wrap: anywhere;
}

.post-list,
.table-list {
  display: grid;
  gap: 10px;
}

.post-row,
.admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.post-row a {
  font-weight: 700;
  text-decoration: none;
}

.post-row time {
  color: var(--muted);
  white-space: nowrap;
}

.article {
  padding-top: 36px;
}

.markdown-body {
  margin-top: 28px;
  font-size: 18px;
}

.markdown-body img {
  max-width: 100%;
  border-radius: 8px;
}

.markdown-body pre {
  overflow: auto;
  padding: 16px;
  background: #202124;
  color: #f4f4f0;
  border-radius: 8px;
}

.markdown-body code {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
}

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

.button.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
}

.button.ghost {
  background: transparent;
  color: var(--accent);
}

.button.danger {
  border-color: var(--danger);
  background: var(--danger);
}

.empty {
  padding: 18px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
  border: 1px dashed var(--line);
  border-radius: 8px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.flash-list {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.flash {
  margin: 0;
  padding: 12px 14px;
  border-radius: 8px;
  background: #eef7f3;
  color: #174c3f;
  border: 1px solid #cae7dc;
}

.flash.error {
  background: #fff2f0;
  color: #8f1d14;
  border-color: #ffd3cc;
}

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

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

.form label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
  line-height: 1.6;
}

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

.admin-shell {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.admin-sidebar {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 8px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-sidebar h1 {
  margin: 0 0 8px;
  font-size: 22px;
}

.admin-sidebar a,
.link-button {
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  justify-content: flex-start;
  min-height: auto;
  text-decoration: none;
}

.admin-sidebar a:hover,
.link-button:hover {
  background: transparent;
  color: var(--accent);
}

.admin-content {
  min-width: 0;
}

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

.stat {
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat strong {
  display: block;
  font-size: 34px;
  line-height: 1;
}

.stat span {
  color: var(--muted);
}

.admin-row {
  align-items: flex-start;
  padding: 16px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.admin-row strong,
.admin-row small {
  display: block;
  overflow-wrap: anywhere;
}

.inline-form {
  grid-template-columns: 1fr 1.5fr 1fr 110px auto;
  align-items: end;
  margin-bottom: 24px;
}

@media (max-width: 760px) {
  .site-header,
  .section-title,
  .post-row,
  .admin-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .link-grid,
  .quick-tools,
  .stats,
  .admin-shell,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .quick-tool-row {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
  }

  .hero {
    padding-top: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page {
    animation: none;
  }
}

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

.animate-fade-in-up {
  animation: pageFadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@media (prefers-reduced-motion: reduce) {
  .animate-fade-in-up {
    animation: none !important;
  }
}

.animate-fade-out-down {
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1) !important;
  opacity: 0 !important;
  transform: translateY(8px) !important;
}
