.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
  align-items: stretch;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: var(--doc-max);
  margin: 0 auto;
  padding: 0 1.5rem;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
}
.app-layout--home .header-inner {
  max-width: min(var(--content-max), 100% - 2rem);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.nav-btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.8125rem;
  font-weight: 500;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
}
.nav-btn:hover { color: var(--text); }
.nav-btn.active {
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}
.nav-btn-ghost { font-size: 0.8125rem; color: var(--muted); }

/* Main + document shell */
.doc-main {
  flex: 1;
  width: 100%;
  margin: 0;
  padding: 1.75rem 1.5rem 2.5rem;
}

.doc-container {
  max-width: var(--doc-max);
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

/* 首页：统计在上、主内容下，整体收拢居中 */
.doc-container.doc-home {
  max-width: min(var(--content-max), 100% - 1.5rem);
}

.doc-home-layout {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.doc-home-stats {
  width: 100%;
}

.doc-col-main {
  min-width: 0;
}

/* 首页三列统计：顶部横排（桌面/手机同结构） */
.doc-home .stats-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.4rem;
}
.doc-home .stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 3.6rem;
  padding: 0.55rem 0.4rem;
}
.doc-home .stat-value {
  font-size: 1.2rem;
}
.doc-home .stat-label {
  font-size: 0.64rem;
  text-transform: none;
  letter-spacing: 0.04em;
  margin-top: 0.1rem;
}

@media (min-width: 600px) {
  .doc-home .stat-value {
    font-size: 1.35rem;
  }
  .doc-home .stat-card {
    min-height: 3.9rem;
    padding: 0.65rem 0.5rem;
  }
}

@media (max-width: 899px) {
  .doc-main {
    padding: 1.1rem 0.75rem 1.75rem;
  }
  .page-title {
    margin-bottom: 0.75rem;
  }
  .paper, .card {
    padding: 1.1rem 1rem;
  }
  .result-box {
    padding: 0.85rem 0.8rem;
    margin-top: 0.85rem;
  }
  .result-box-body {
    align-items: center;
  }
  .result-qr {
    align-items: center;
    width: 100%;
  }
  .result-qr-img,
  .result-qr img {
    width: min(200px, 78vw) !important;
    max-width: 100%;
  }
  .result-text > div {
    justify-content: center !important;
  }
  .result-meta {
    text-align: center;
    max-width: 100%;
  }
}

.page-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 1rem;
  letter-spacing: 0.02em;
}

/* 统计条（非首页场景保留横向） */
.stats-bar {
  display: flex;
  flex-direction: row;
  gap: 0.75rem;
  width: 100%;
}

.stat-card {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  padding: 0.8rem 0.9rem;
  background: var(--surface);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.stat-label {
  font-size: 0.6875rem;
  color: var(--muted);
  margin-top: 0.2rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.site-footer {
  width: 100%;
  text-align: center;
  padding: 1.25rem 1.5rem;
  color: var(--faint);
  font-size: 0.75rem;
  border-top: 1px solid var(--line);
}
.site-footer a { color: var(--faint); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; color: var(--muted); }

/* Paper / card */
.paper, .card {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 1.5rem 1.35rem;
  border-radius: var(--radius);
}

/* Buttons */
.btn-primary {
  background: var(--ink);
  color: var(--surface);
  padding: 0.5rem 1.1rem;
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
}
.btn-primary:hover { background: #262626; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-danger {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  text-decoration: none;
}
.btn-danger:hover { background: var(--hover); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  text-decoration: none;
}
.btn-ghost:hover { background: var(--hover); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.page-num {
  min-width: 2rem;
  text-align: center;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  padding: 0.3rem 0.45rem;
}
.page-num.is-active {
  background: var(--ink) !important;
  color: var(--surface) !important;
  border-color: var(--ink) !important;
}

/* Form */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.85rem;
}
.form-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.form-hint {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
}

/* Result */
.result-box {
  background: var(--hover);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  margin-top: 1.1rem;
}
.result-box-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.1rem;
}
@media (min-width: 520px) {
  .result-box-body {
    flex-direction: row;
    align-items: flex-start;
  }
}
.result-qr {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.4rem;
}
.result-qr img,
.result-qr-img {
  display: block;
  width: 200px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
}
.result-qr-download {
  font-size: 0.8rem;
  text-decoration: none;
}
.result-text { flex: 1; min-width: 0; width: 100%; }
.result-url {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
  word-break: break-all;
  text-decoration: none;
}
.result-url:hover { text-decoration: underline; }
.result-meta {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}

/* Error (neutral) */
.error-msg {
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.82rem;
  margin-top: 0.85rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 1.5rem 1.4rem;
  width: 100%;
  max-width: 22rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
.modal-title {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.9rem;
  letter-spacing: 0.02em;
}
.modal-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.9rem;
  justify-content: flex-end;
}

/* Table */
.link-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.link-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.link-table th {
  text-align: left;
  padding: 0.45rem 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--ink);
  white-space: nowrap;
  background: var(--surface);
}
.link-table td {
  padding: 0.6rem 0.6rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.link-table tr:last-child td { border-bottom: none; }
.link-table tr:hover td { background: var(--hover); }

.tag {
  display: inline-block;
  padding: 0.08rem 0.32rem;
  font-size: 0.65rem;
  font-weight: 500;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--bg);
  border-radius: 1px;
  margin-left: 0.2rem;
  vertical-align: middle;
  line-height: 1.3;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-void, .tag-red {
  color: var(--text);
  border-color: var(--faint);
  background: #f0f0f0;
}
.tag-ok, .tag-green {
  color: var(--ink);
  border-color: #c4c4c4;
  background: var(--surface);
}
.tag-mute, .tag-gray, .tag-blue { color: var(--muted); }

.pagination {
  display: flex;
  gap: 0.3rem;
  justify-content: center;
  margin-top: 1.1rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Edit drawer */
.edit-drawer {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 1.1rem 1.15rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
}
.edit-drawer-title {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.logotype {
  text-decoration: none;
}
.logotype span {
  text-decoration: none;
}

.link-muted {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.8rem;
}
.link-muted:hover { text-decoration: underline; color: var(--text); }

.admin-toolbar {
  text-align: right;
  font-size: 0.75rem;
  color: var(--muted);
  margin: -0.2rem 0 0.65rem;
}
