:root {
  --ink: #111111;
  --muted: #686868;
  --subtle: #888888;
  --line: #dddddd;
  --light-line: #eeeeee;
  --paper: #ffffff;
  --hover: #fbfaf3;
  --danger: #a33a2c;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  min-height: 100vh;
  line-height: 1.6;
}

a { color: inherit; }
button, input, textarea { font: inherit; }

.page-shell {
  width: 100%;
  max-width: 1200px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 48px 32px;
  display: flex;
  flex-direction: column;
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  margin-bottom: 100px;
  border-bottom: 1px solid var(--light-line);
}

.site-title {
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.3px;
  text-decoration: none;
  white-space: nowrap;
}

nav {
  display: flex;
  gap: 25px;
  align-items: center;
}

nav a {
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition: color .15s;
}

nav a:hover,
nav a[aria-current="page"] { color: var(--ink); }

.admin-link { color: var(--ink); }

.user-chip {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

main {
  width: 100%;
  flex: 1;
}

h1 {
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 52px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -1.5px;
}

.desc {
  max-width: 600px;
  margin-bottom: 56px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}

.hero { width: 100%; }

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin-bottom: 100px;
  border: 1px solid var(--line);
  background: var(--line);
}

.hero-stats div {
  min-height: 140px;
  padding: 34px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background: #fff;
  transition: background .12s;
}

.hero-stats div:hover { background: var(--hover); }
.hero-stats strong { font-size: 28px; line-height: 1.2; }
.hero-stats span { margin-top: 5px; color: var(--subtle); font-size: 14px; }

.notice {
  margin: -60px 0 56px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  font-size: 14px;
}

.notice.success { color: #28642f; background: #f6fbf6; border-color: #bdd8c0; }
.notice.error { color: #8f3025; background: #fff8f7; border-color: #e2c1bc; }

.admin-panel {
  display: grid;
  grid-template-columns: .8fr 1.2fr;
  gap: 1px;
  margin-bottom: 100px;
  border: 1px solid var(--line);
  background: var(--line);
}

.admin-panel > div,
.admin-panel > form {
  padding: 38px 34px;
  background: #fff;
}

.admin-panel h2,
.library h2,
.login-grid h2 {
  color: var(--ink);
  font-weight: 650;
  letter-spacing: -.5px;
}

.admin-panel h2 { margin-bottom: 10px; font-size: 28px; }
.admin-panel p { max-width: 380px; color: var(--muted); font-size: 15px; }

.upload-form,
.login-form {
  display: grid;
  gap: 18px;
}

.upload-form label,
.login-form label {
  display: grid;
  gap: 7px;
}

.upload-form label > span,
.login-form label > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.upload-form small { color: #aaa; font-weight: 400; }

input,
textarea {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
  background: #fff;
  color: var(--ink);
}

input::placeholder,
textarea::placeholder { color: #aaa; }

input:focus,
textarea:focus { border-color: var(--ink); }

textarea { resize: vertical; }
input[type="file"] { padding: 8px; }

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 8px 12px;
  border: 0;
  background: #f1f1f1;
  color: var(--ink);
  cursor: pointer;
}

.upload-form > button,
.login-form > button,
.search-form button {
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s;
}

.upload-form > button:hover,
.login-form > button:hover,
.search-form button:hover {
  background: #333;
}

.library { padding-bottom: 0; }

.library-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 28px;
}

.library h2 { font-size: 38px; line-height: 1.2; }

.search-form {
  display: flex;
  width: min(500px, 100%);
}

.search-form input { border-right: 0; }
.search-form button { flex: 0 0 auto; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-bottom: 30px;
  border-left: 1px solid var(--line);
}

.filters a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-left: 0;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.filters a:hover { color: var(--ink); background: var(--hover); }
.filters a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.filters span { opacity: .65; }

.resource-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.resource-card {
  min-width: 0;
  overflow: hidden;
  background: #fff;
}

.preview {
  height: 240px;
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: #f5f5f5;
}

.preview img,
.preview video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.preview video { background: #111; }
.preview > a:not(.document-preview) { width: 100%; height: 100%; display: block; }

.document-preview {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f7f7f7;
  color: var(--ink);
  text-decoration: none;
}

.document-preview span { font-size: 38px; font-weight: 700; letter-spacing: -1px; }
.document-preview small { color: var(--subtle); }

.type-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 8px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  font-size: 11px;
}

.card-body { padding: 24px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 8px; color: var(--subtle); font-size: 11px; }
.card-meta span:not(:last-child)::after { content: "\00b7"; padding-left: 8px; }
.card-body h3 { margin: 8px 0 5px; font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.card-body > p { margin-bottom: 18px; color: var(--muted); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.card-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--light-line);
}

.card-actions .download { font-size: 14px; font-weight: 600; text-decoration: none; }
.card-actions > span { margin-right: auto; color: var(--subtle); font-size: 11px; }
.card-actions form { margin: 0; }
.delete { border: 0; background: transparent; color: var(--danger); font-size: 12px; cursor: pointer; }

.empty-state {
  min-height: 280px;
  padding: 40px 20px;
  display: grid;
  place-content: center;
  text-align: center;
  border: 1px solid var(--line);
}

.empty-state > span { color: #bbb; font-size: 36px; }
.empty-state h3 { margin: 8px 0 2px; font-size: 22px; }
.empty-state p { color: var(--muted); font-size: 14px; }

.login-page-main { min-height: 0; }
.login-page-main .notice { margin: -60px 0 56px; }

.login-screen { width: 100%; }

.back-link {
  display: inline-block;
  margin-bottom: 38px;
  color: var(--muted);
  font-size: 14px;
  text-decoration: none;
}

.back-link:hover { color: var(--ink); }
.login-intro .desc { margin-bottom: 56px; }

.login-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}

.login-info,
.login-card {
  min-height: 430px;
  padding: 40px;
  background: #fff;
}

.login-grid h2 { margin-bottom: 12px; font-size: 24px; }
.login-info > p { max-width: 440px; color: var(--muted); font-size: 15px; }

.auth-note { margin-top: 48px; border-top: 1px solid var(--light-line); }

.auth-note p {
  padding: 17px 0;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--light-line);
  font-size: 13px;
}

.auth-note strong { font-weight: 600; }
.auth-note span { color: var(--muted); text-align: right; }
.login-card h2 { margin-bottom: 24px; }
.login-help { margin-top: 18px; color: var(--subtle); font-size: 13px; }
.login-help a { color: var(--muted); }

.legal-page-main { min-height: 0; }
.legal-heading .desc { margin-bottom: 56px; }

.legal-content {
  border: 1px solid var(--line);
}

.legal-content section {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 0;
  border-bottom: 1px solid var(--line);
}

.legal-content section:last-child { border-bottom: 0; }

.legal-content section > span {
  padding: 30px 20px;
  border-right: 1px solid var(--line);
  color: #aaaaaa;
  font-size: 13px;
  font-weight: 600;
}

.legal-content section > div { padding: 28px 32px 30px; }
.legal-content h2 { margin-bottom: 7px; font-size: 20px; letter-spacing: -.3px; }
.legal-content p { max-width: 850px; color: var(--muted); font-size: 15px; line-height: 1.8; }

.legal-contact {
  margin-top: 36px;
  padding: 30px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  background: var(--ink);
  color: #fff;
}

.legal-contact h2 { margin-bottom: 4px; font-size: 22px; }
.legal-contact p { color: #b8b8b8; font-size: 14px; }
.legal-contact a {
  flex: 0 0 auto;
  padding: 11px 17px;
  border: 1px solid #fff;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.legal-contact a:hover { background: #fff; color: var(--ink); }
.legal-date { margin-top: 18px; color: #aaaaaa; font-size: 12px; text-align: right; }

footer {
  margin-top: 100px;
  padding: 40px 0 20px;
  border-top: 1px solid var(--light-line);
  color: #bbbbbb;
  font-size: 13px;
  text-align: center;
}

footer span,
footer a { display: inline-block; margin: 0 6px; }
footer a { text-decoration: none; }
footer a:hover { color: var(--muted); }

@media (max-width: 1050px) {
  nav { gap: 17px; }
  nav a { font-size: 14px; }
  .resource-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  h1 { font-size: 38px; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .admin-panel,
  .login-grid { grid-template-columns: 1fr; }
  .login-info,
  .login-card { min-height: 0; }
  .site-header { align-items: flex-start; gap: 24px; }
  nav { flex-wrap: wrap; justify-content: flex-end; }
}

@media (max-width: 600px) {
  .page-shell { padding: 24px 16px; }
  .site-header {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 60px;
  }
  nav { gap: 14px 18px; justify-content: flex-start; }
  h1 { font-size: 30px; }
  .desc { margin-bottom: 36px; }
  .hero-stats { grid-template-columns: 1fr; margin-bottom: 70px; }
  .hero-stats div { min-height: auto; padding: 28px 20px; }
  .admin-panel { margin-bottom: 70px; }
  .admin-panel > div,
  .admin-panel > form,
  .login-info,
  .login-card { padding: 28px 20px; }
  .library-head { align-items: stretch; flex-direction: column; }
  .library h2 { font-size: 30px; }
  .search-form { width: 100%; }
  .resource-grid { grid-template-columns: 1fr; }
  .preview { height: min(72vw, 340px); }
  .login-intro .desc { margin-bottom: 36px; }
  .auth-note p { align-items: flex-start; flex-direction: column; gap: 4px; }
  .auth-note span { text-align: left; }
  .legal-content section { grid-template-columns: 48px 1fr; }
  .legal-content section > span { padding: 24px 12px; }
  .legal-content section > div { padding: 22px 18px 24px; }
  .legal-contact { align-items: flex-start; flex-direction: column; padding: 24px 20px; }
  .legal-date { text-align: left; }
  footer { margin-top: 70px; }
  footer span,
  footer a { display: block; margin: 3px 0; }
}
