:root {
  --ink: #10283f;
  --ink-strong: #071a2b;
  --paper: #f4f6f8;
  --surface: #ffffff;
  --line: #dbe2e8;
  --muted: #6b7c8d;
  --amber: #d59b32;
  --amber-soft: #f6ead2;
  --green: #17835b;
  --red: #b6413e;
  --shadow: 0 14px 34px rgba(16, 40, 63, 0.09);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}
a { color: inherit; }
button, input, textarea { font: inherit; }
button, .button, .material-card, .quiet-link { transition: 160ms ease; }

.site-header {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 38px;
  color: #fff;
  background: var(--ink-strong);
  border-bottom: 3px solid var(--amber);
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.42);
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { margin-top: 2px; color: #91a4b5; font: 10px/1.2 Consolas, monospace; }
.quiet-link, .quiet-button {
  border: 1px solid rgba(255,255,255,.25);
  background: transparent;
  color: #fff;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
}
.quiet-link:hover, .quiet-button:hover, .quiet-link:focus-visible, .quiet-button:focus-visible { border-color: var(--amber); outline: none; }

.page-shell { width: min(1180px, calc(100% - 48px)); margin: 0 auto; padding: 56px 0 72px; }
.library-intro { display: flex; align-items: end; justify-content: space-between; gap: 40px; padding-bottom: 32px; border-bottom: 1px solid var(--line); }
.eyebrow { margin: 0 0 10px; color: var(--amber); font: 700 11px/1.2 Consolas, monospace; }
.library-intro h1 { max-width: 760px; margin: 0; color: var(--ink-strong); font-size: clamp(34px, 5vw, 58px); line-height: 1.08; font-family: "Microsoft YaHei UI", "PingFang SC", sans-serif; }
.library-intro p:not(.eyebrow) { margin: 16px 0 0; color: var(--muted); font-size: 16px; }
.library-count { min-width: 148px; padding-left: 22px; border-left: 3px solid var(--amber); }
.library-count strong { display: block; color: var(--ink-strong); font: 700 38px/1 Consolas, monospace; }
.library-count span { display: block; margin-top: 8px; color: var(--muted); font-size: 12px; }

.material-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; padding-top: 32px; }
.material-card {
  position: relative;
  min-height: 290px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: inherit;
  background: var(--surface);
  box-shadow: 0 4px 14px rgba(16,40,63,.05);
  text-decoration: none;
}
.material-card:hover, .material-card:focus-visible { transform: translateY(-3px); border-color: #9daebb; box-shadow: var(--shadow); outline: none; }
.file-tab { align-self: flex-start; min-width: 72px; padding: 8px 14px; color: #fff; background: var(--ink); font: 700 11px/1 Consolas, monospace; }
.file-tab--pdf { background: var(--red); }
.file-tab--html { background: var(--green); }
.material-body { flex: 1; padding: 26px 24px 16px; }
.material-date { margin: 0 0 12px; color: var(--muted); font: 11px/1 Consolas, monospace; }
.material-body h2 { margin: 0; color: var(--ink-strong); font-size: 22px; line-height: 1.3; }
.material-body > p:not(.material-date) { min-height: 44px; margin: 14px 0; color: var(--muted); font-size: 14px; line-height: 1.6; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-row span { padding: 4px 7px; border: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.material-open { display: flex; justify-content: space-between; padding: 14px 24px; border-top: 1px solid var(--line); font-size: 13px; font-weight: 700; }
.material-open span { color: var(--amber); }

.empty-state { margin-top: 32px; padding: 54px; border: 1px dashed #b7c3cd; text-align: center; background: rgba(255,255,255,.45); }
.empty-state h2 { margin: 0 0 10px; color: var(--ink-strong); font-size: 26px; }
.empty-state > p:not(.eyebrow) { margin: 0 0 24px; color: var(--muted); }
.button { display: inline-flex; justify-content: center; border: 0; border-radius: 4px; padding: 11px 18px; color: #fff; background: var(--ink); text-decoration: none; cursor: pointer; }
.button:hover, .button:focus-visible { background: #173d5e; outline: 3px solid var(--amber-soft); }
footer { display: flex; justify-content: space-between; padding: 18px 38px; color: #8392a0; background: var(--ink-strong); font-size: 11px; }

.auth-page { min-height: 100vh; background: var(--ink-strong); }
.auth-shell { width: min(460px, calc(100% - 36px)); margin: 0 auto; padding: 70px 0; }
.back-link { color: var(--muted); text-decoration: none; font-size: 13px; }
.auth-page .back-link { color: #9eb0c0; }
.auth-panel { margin-top: 22px; padding: 38px; border-top: 4px solid var(--amber); background: #fff; box-shadow: 0 24px 70px rgba(0,0,0,.28); }
.auth-panel h1 { margin: 0; color: var(--ink-strong); font-size: 31px; }
.auth-panel > p:not(.eyebrow):not(.form-error) { margin: 10px 0 24px; color: var(--muted); }
.form-stack { display: grid; gap: 18px; }
label { display: grid; gap: 7px; color: var(--ink); font-size: 13px; font-weight: 700; }
input, textarea { width: 100%; border: 1px solid #bfcbd4; border-radius: 3px; padding: 10px 11px; color: var(--ink-strong); background: #fff; font-weight: 400; }
input:focus, textarea:focus { border-color: var(--ink); outline: 3px solid #e6edf2; }
.form-error { padding: 9px 11px; color: #8c2825; background: #fae6e5; font-size: 13px; }

.admin-shell { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 72px; }
.notice { margin-bottom: 18px; padding: 11px 14px; border-left: 4px solid var(--amber); background: var(--amber-soft); font-size: 13px; }
.admin-section { padding: 30px 0 34px; border-bottom: 1px solid var(--line); }
.upload-section { display: grid; grid-template-columns: minmax(240px, .7fr) minmax(0, 1.3fr); gap: 52px; }
.section-heading h1, .section-heading h2 { margin: 0; color: var(--ink-strong); }
.section-heading h1 { font-size: 32px; }
.section-heading h2 { font-size: 25px; }
.section-heading > p:not(.eyebrow) { max-width: 360px; color: var(--muted); line-height: 1.6; }
.section-heading.compact { margin-bottom: 18px; }
.upload-form { display: grid; grid-template-columns: 1fr 1fr; gap: 17px; }
.upload-form label:nth-of-type(2), .upload-form .file-field { grid-column: 1 / -1; }
.upload-form .button { justify-self: start; }
.file-field small { color: var(--muted); font-weight: 400; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: #fff; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
th { color: var(--muted); background: #edf1f4; font-size: 11px; }
td small { display: block; margin-top: 4px; color: var(--muted); }
.status { font-size: 12px; font-weight: 700; }
.status--1 { color: var(--green); }
.status--0 { color: var(--muted); }
.row-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.row-actions form { display: inline; }
.row-actions a, .row-actions button { border: 0; padding: 0; color: var(--ink); background: none; text-decoration: underline; cursor: pointer; }
.row-actions .danger { color: var(--red); }
.table-empty { padding: 30px; color: var(--muted); text-align: center; }
.cell-slug a { word-break: break-all; }
.path-hint { max-width: 760px; margin: 0 0 10px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.path-hint code { padding: 2px 6px; border: 1px solid var(--line); border-radius: 3px; color: var(--ink-strong); background: #fff; word-break: break-all; }

.viewer-page { height: 100vh; overflow: hidden; background: #182838; }
.viewer-header { height: 60px; display: grid; grid-template-columns: 180px 1fr 180px; align-items: center; gap: 18px; padding: 0 22px; color: #fff; background: var(--ink-strong); }
.viewer-header > div { min-width: 0; display: flex; align-items: center; justify-content: center; gap: 12px; }
.viewer-header strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.viewer-header .quiet-link { justify-self: end; }
.viewer-kind { color: var(--amber); font: 700 11px/1 Consolas, monospace; }
.viewer-frame { display: block; width: 100%; height: calc(100vh - 60px); border: 0; background: #fff; }

@media (max-width: 900px) {
  .material-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upload-section { grid-template-columns: 1fr; gap: 18px; }
  .viewer-header { grid-template-columns: auto 1fr auto; }
}

@media (max-width: 620px) {
  .site-header { height: 66px; padding: 0 18px; }
  .page-shell, .admin-shell { width: min(100% - 28px, 1180px); padding-top: 34px; }
  .library-intro { align-items: start; flex-direction: column; gap: 24px; }
  .library-intro h1 { font-size: 35px; }
  .material-grid { grid-template-columns: 1fr; }
  .material-card { min-height: 250px; }
  .upload-form { grid-template-columns: 1fr; }
  .upload-form label { grid-column: 1 !important; }
  .viewer-header { height: 54px; grid-template-columns: auto 1fr; padding: 0 12px; }
  .viewer-header > div { justify-content: flex-start; }
  .viewer-header .quiet-link { display: none; }
  .viewer-frame { height: calc(100vh - 54px); }
  footer { padding: 16px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
