:root {
  --shell-width: 1080px;
  --shell-gutter: 28px;
  --shell-top: 22px;
  --page-bg: #f1f1f1;
  --paper: #ffffff;
  --ink: #111111;
  --border: #222222;
  --muted: #555555;
  --soft: #f2f2f2;
  --head: #eeeeee;
  --stripe: #fafafa;
}

* {
  box-sizing: border-box;
}

html {
  overflow-y: scroll;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(17, 17, 17, 0.025) 1px, transparent 1px),
    linear-gradient(0deg, rgba(17, 17, 17, 0.018) 1px, transparent 1px),
    linear-gradient(135deg, rgba(17, 17, 17, 0.018) 0 1px, transparent 1px 8px),
    var(--page-bg);
  background-size: 18px 18px, 18px 18px, 10px 10px, auto;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: var(--ink);
}

button {
  border: 1.5px solid var(--ink);
  background: var(--paper);
  padding: 7px 11px;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

button:focus-visible,
a:focus-visible,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

button:hover,
.nav a:hover,
.tabs button:hover {
  background: var(--ink);
  color: var(--paper);
  outline: 0;
}

button[disabled] {
  color: var(--muted);
  cursor: not-allowed;
}

button[disabled]:hover {
  background: var(--paper);
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--paper);
  padding: 7px 8px;
  border-radius: 0;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

.page {
  position: relative;
  width: min(var(--shell-width), calc(100% - var(--shell-gutter)));
  margin: var(--shell-top) auto;
  background: var(--paper);
  border: 2px solid var(--ink);
}

.site-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: end;
  padding: 24px 28px 18px;
  border-bottom: 2px solid var(--ink);
}

.back-home {
  position: fixed;
  top: var(--shell-top);
  left: max(8px, calc((100vw - min(var(--shell-width), calc(100vw - var(--shell-gutter)))) / 2 - 54px));
  z-index: 10;
  display: block;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  background: var(--paper);
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease;
}

.back-home::before,
.back-home::after {
  content: "";
  position: absolute;
  top: 50%;
  background: currentColor;
}

.back-home::before {
  left: 11px;
  width: 13px;
  height: 2px;
  transform: translateY(-50%);
}

.back-home::after {
  left: 11px;
  width: 9px;
  height: 9px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  background: transparent;
  transform: translateY(-50%) rotate(45deg);
}

.back-home:hover {
  background: var(--ink);
  color: var(--paper);
  outline: 0;
}

h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  margin: 24px 0 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--ink);
  font-size: 20px;
}

h3 {
  margin: 18px 0 10px;
  font-size: 16px;
}

p {
  margin: 8px 0;
}

.subtitle,
.muted {
  color: var(--muted);
}

.subtitle {
  margin: 7px 0 0;
}

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

.nav a,
.tabs button {
  display: inline-block;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  padding: 6px 10px;
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease;
}

.nav a[aria-current="page"],
.tabs button[aria-selected="true"] {
  background: var(--ink);
  color: var(--paper);
}

main {
  padding: 22px 28px 28px;
  animation: surface-in 180ms ease-out both;
}

.summary {
  border: 1.5px solid var(--ink);
  padding: 16px;
  background: var(--soft);
}

.summary-title {
  margin: 0 0 12px;
  font-weight: 800;
}

.tips-panel {
  padding-top: 12px;
}

.tips-panel h2 {
  margin-top: 0;
}

.pre-line {
  white-space: pre-line;
}

.box {
  border: 1.5px solid var(--ink);
  padding: 12px 14px;
  background: var(--paper);
}

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

.metric {
  border: 1.5px solid var(--ink);
  padding: 12px 14px;
  background: var(--paper);
}

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

.metric .value {
  font-size: 30px;
  font-weight: 800;
  margin-top: 4px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 14px;
  table-layout: fixed;
  font-size: 14px;
}

th,
td {
  border: 1px solid var(--border);
  padding: 8px 9px;
  vertical-align: top;
  word-break: break-word;
}

th {
  background: var(--head);
  text-align: left;
  font-weight: 800;
}

tbody tr:nth-child(even) td {
  background: var(--stripe);
}

.tag {
  display: inline-block;
  border: 1px solid var(--ink);
  padding: 1px 6px;
  margin: 1px 4px 1px 0;
  font-size: 12px;
  background: var(--paper);
  white-space: nowrap;
}

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

.item-card {
  position: relative;
  overflow: hidden;
  border: 1.5px solid var(--ink);
  background: var(--paper);
  transition: background-color 180ms ease;
}

.item-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, rgba(17, 17, 17, 0.12) 0 2px, transparent 2px 8px);
  opacity: 0;
  transition: opacity 180ms ease;
  pointer-events: none;
}

.item-card:hover {
  background: #e7e7e7;
}

.item-card:hover::before {
  opacity: 1;
}

.item-card-link {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  min-height: 142px;
  padding: 14px;
  color: inherit;
  text-decoration: none;
}

.item-card-link:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.item-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item-card h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.item-card p {
  margin: 0;
  color: var(--ink);
}

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

.item-card-tags {
  align-self: end;
}

.empty-card {
  border: 1.5px solid var(--ink);
  background: var(--paper);
  padding: 18px;
  color: var(--muted);
}

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

.toolbar {
  justify-content: space-between;
  margin: 12px 0;
}

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

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

label {
  display: grid;
  gap: 5px;
  font-weight: 700;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

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

.notice {
  border: 1.5px solid var(--ink);
  background: var(--soft);
  padding: 10px 12px;
  margin: 12px 0;
}

.upload-progress {
  grid-column: 1 / -1;
  display: none;
  position: relative;
  height: 30px;
  border: 1px solid var(--ink);
  background: var(--paper);
  overflow: hidden;
}

.upload-progress.is-active {
  display: block;
}

.upload-progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: repeating-linear-gradient(135deg, #d0d0d0 0 2px, #fff 2px 7px);
  border-right: 1px solid var(--ink);
  transition: width 120ms ease;
}

.upload-progress span {
  position: relative;
  display: block;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
}

.error {
  border: 1.5px solid var(--ink);
  background: var(--head);
  padding: 10px 12px;
  margin: 12px 0;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

.nowrap {
  white-space: nowrap;
}

.admin-panel {
  display: grid;
  gap: 16px;
}

.file-note {
  color: var(--muted);
  font-size: 12px;
}

.site-footer {
  width: min(var(--shell-width), calc(100% - var(--shell-gutter)));
  margin: -8px auto 26px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.is-loading,
.summary,
.box,
.item-grid,
.wide-table,
.empty-card {
  animation: surface-in 180ms ease-out both;
}

@keyframes surface-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  .page {
    width: calc(100% - 12px);
    margin: 8px auto;
  }

  .site-header {
    grid-template-columns: 1fr;
    align-items: start;
    padding-left: 14px;
    padding-right: 14px;
  }

  .nav {
    justify-content: flex-start;
  }

  .back-home {
    top: 8px;
    left: 8px;
  }

  main {
    padding-left: 14px;
    padding-right: 14px;
  }

  h1 {
    font-size: 28px;
  }

  .metrics,
  .form-grid,
  .item-grid {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 12px;
  }

  th,
  td {
    padding: 7px;
  }

  .wide-table {
    display: block;
    overflow-x: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  body {
    background: #fff;
  }

  .page {
    width: auto;
    margin: 0;
    border: 0;
  }

  .nav,
  .back-home,
  .site-footer,
  .tabs,
  .toolbar,
  .form-actions,
  button,
  input,
  textarea,
  select {
    display: none !important;
  }

  section,
  table,
  .box,
  .metric {
    break-inside: avoid;
  }
}
