:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #18202c;
  --muted: #5d6878;
  --border: #dfe4ec;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #dc2626;
  --badge-bg: #eef2f7;
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.wrap {
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
  padding-bottom: 14px;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.brand-sub {
  font-size: 13px;
  color: var(--muted);
}

.main-content {
  flex: 1;
  padding-top: 28px;
  padding-bottom: 40px;
}

.intro h1 {
  margin: 0 0 6px;
  font-size: 26px;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.file-grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.file-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.file-card:hover {
  border-color: #b8c4d6;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.card-top {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.card-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.card-desc {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.badge-cat {
  background: #e8f0fe;
  color: #1e40af;
}

.viewer-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.viewer-head-main h1 {
  margin: 8px 0 4px;
  font-size: 24px;
}

.viewer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.viewer-desc {
  margin: 4px 0 0;
  color: var(--muted);
}

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

.no-download-note {
  font-size: 13px;
  color: var(--muted);
  background: var(--badge-bg);
  padding: 6px 12px;
  border-radius: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: #f1f4f8;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-danger {
  color: var(--danger);
  border-color: #fecaca;
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 13px;
}

.viewer-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.viewer-html {
  background: #fff;
}

.html-frame {
  width: 100%;
  height: 78vh;
  min-height: 520px;
  border: 0;
  display: block;
}

.doc-body {
  padding: 24px 28px;
}

.doc-body h1,
.doc-body h2,
.doc-body h3 {
  margin-top: 1.4em;
  margin-bottom: 0.5em;
}

.doc-body h1:first-child,
.doc-body h2:first-child {
  margin-top: 0;
}

.doc-body pre,
.txt-body {
  background: #f8fafc;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}

.txt-body {
  margin: 0;
  padding: 24px;
  white-space: pre-wrap;
  word-break: break-word;
}

.pdf-bar,
.img-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: #f9fafb;
}

.pdf-zoom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pdf-status {
  font-size: 13px;
  color: var(--muted);
}

.pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: #eef1f6;
  max-height: 82vh;
  overflow: auto;
}

.pdf-page-canvas {
  background: #fff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
  max-width: 100%;
  height: auto;
}

.img-stage {
  padding: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
  background: #eef1f6;
  min-height: 320px;
}

.preview-img {
  max-width: 100%;
  height: auto;
  transform-origin: center center;
  transition: transform 0.15s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.empty-state,
.empty-note {
  margin-top: 24px;
  color: var(--muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--card);
  padding: 12px 0;
  font-size: 13px;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.changelog-details summary {
  cursor: pointer;
  list-style: none;
}

.changelog-box {
  margin-top: 6px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* Admin styles */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

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

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

.field input,
.field select,
.field textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  background: #fff;
}

.field textarea {
  min-height: 110px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.row-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.error-msg {
  color: var(--danger);
  font-size: 14px;
  margin: 8px 0 0;
}

.ok-msg {
  color: #15803d;
  font-size: 14px;
  margin: 8px 0 0;
}

@media (max-width: 640px) {
  .doc-body {
    padding: 16px;
  }
  .viewer-head {
    flex-direction: column;
  }
  .admin-table {
    display: block;
    overflow-x: auto;
  }
}
