:root {
  --bg: #eef1f2;
  --paper: #ffffff;
  --paper-soft: #f7f8f8;
  --ink: #292c2f;
  --muted: #6d7276;
  --line: #d7d9d8;
  --accent: #586978;
  --accent-dark: #3e4f5d;
  --gold: #927642;
  --gold-soft: #f2eee5;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  line-height: 1.6;
}
button, input { font: inherit; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.page { width: calc(100% - 32px); max-width: 1040px; margin: 0 auto; padding: 26px 0 60px; }
.back {
  display: inline-flex;
  align-items: center;
  margin-bottom: 17px;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}
.back:hover { text-decoration: underline; text-underline-offset: 4px; }
.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 32px;
  padding: 30px 32px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--gold);
  background: var(--paper);
  box-shadow: 0 12px 32px rgba(39, 52, 58, 0.07);
}
.eyebrow { color: var(--gold); font-size: 12px; font-weight: 800; text-transform: uppercase; }
h1 { margin: 7px 0 10px; font-size: 34px; line-height: 1.2; }
h1 span { color: var(--gold); font-family: Georgia, serif; }
.lead { max-width: 680px; margin: 0; color: #4f5559; line-height: 1.75; }
.library-summary { min-width: 154px; padding-left: 22px; border-left: 1px solid var(--line); }
.library-summary strong { display: block; color: var(--gold); font: 700 32px/1 Georgia, serif; }
.library-summary span { display: block; margin-top: 5px; font-size: 14px; font-weight: 750; }
.library-summary small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.library { margin-top: 28px; }
.library-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  align-items: center;
  gap: 18px;
  padding-bottom: 13px;
  border-bottom: 1px solid var(--line);
}
.breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; min-width: 0; }
.crumb {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  padding: 3px 0;
  color: var(--accent-dark);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.crumb::after { content: "/"; color: #adb2b5; font-weight: 400; }
.crumb:last-child { color: var(--muted); cursor: default; }
.crumb:last-child::after { content: ""; }
.search-box {
  min-width: 0;
  height: 40px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(88, 105, 120, 0.12); }
.search-box input { min-width: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 13px; }
.search-box input::placeholder { color: #92979a; }
.view-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin: 23px 0 13px; }
.view-heading h2 { margin: 0; font-size: 20px; }
.view-heading p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.clear-search { border: 0; padding: 4px 0; color: var(--accent-dark); background: transparent; font-size: 12px; font-weight: 750; cursor: pointer; }
.clear-search:hover { text-decoration: underline; text-underline-offset: 3px; }
.library-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.folder-card, .file-card {
  min-width: 0;
  min-height: 112px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--item-accent, var(--accent));
  border-radius: 6px;
  background: var(--paper);
}
.folder-card {
  width: 100%;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 18px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform 0.14s, border-color 0.14s, box-shadow 0.14s;
}
.folder-card:hover { transform: translateY(-1px); border-color: var(--item-accent, var(--accent)); box-shadow: 0 8px 20px rgba(39, 52, 58, 0.07); }
.item-icon {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--item-soft, #edf1f3);
  color: var(--item-accent, var(--accent));
  font: 800 17px/1 Georgia, serif;
}
.item-copy { min-width: 0; }
.item-copy h3 { margin: 0; overflow-wrap: anywhere; font-size: 16px; }
.item-copy p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.item-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.item-meta span { padding: 2px 7px; background: var(--item-soft, #edf1f3); color: var(--item-accent, var(--accent)); font-size: 10px; font-weight: 750; }
.item-arrow { color: var(--item-accent, var(--accent)); font-size: 18px; }
.subject-step { --item-accent: #765f8b; --item-soft: #f0ebf3; }
.subject-tmua { --item-accent: #4f7186; --item-soft: #e9f0f3; }
.subject-math { --item-accent: #526f7d; --item-soft: #e8eff2; }
.subject-physics { --item-accent: #427397; --item-soft: #e5eef5; }
.subject-chemistry { --item-accent: #4c7b65; --item-soft: #e5f0eb; }
.subject-biology { --item-accent: #687944; --item-soft: #edf0e5; }
.subject-economics { --item-accent: #8a6c43; --item-soft: #f2ebe1; }
.file-card { display: flex; flex-direction: column; padding: 18px; }
.file-head { display: flex; align-items: flex-start; gap: 12px; }
.file-icon { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border: 1px solid #dfc9c7; background: #f7eceb; color: #9b4d48; font-size: 10px; font-weight: 850; }
.file-card h3 { margin: 0; overflow-wrap: anywhere; font-size: 15px; line-height: 1.45; }
.file-kind { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.file-location { margin: 11px 0 0; color: #7d8285; overflow-wrap: anywhere; font-size: 11px; }
.file-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 16px; }
.button { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--accent); padding: 7px 12px; color: var(--accent-dark); background: #fff; font-size: 12px; font-weight: 750; text-decoration: none; }
.button.primary { color: #fff; background: var(--accent); }
.button:hover { border-color: var(--accent-dark); background: #edf1f3; }
.button.primary:hover { background: var(--accent-dark); }
.contents-directory { grid-column: 1 / -1; margin-top: 12px; }
.contents-header { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; margin-bottom: 11px; }
.contents-header h3 { margin: 0; font-size: 17px; }
.contents-header span { color: var(--muted); font-size: 12px; }
.toc-group + .toc-group { margin-top: 18px; }
.toc-group-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 8px; }
.toc-group-title h4 { margin: 0; font-size: 13px; }
.toc-group-title span { color: var(--muted); font-size: 11px; }
.toc-list { display: flex; flex-wrap: wrap; gap: 1px; padding: 1px; background: var(--line); }
.toc-item { flex: 1 1 300px; min-width: 0; display: flex; align-items: baseline; gap: 9px; padding: 11px 13px; background: var(--paper); font-size: 12px; line-height: 1.55; }
.toc-item b { flex: none; color: var(--gold); font-size: 11px; font-variant-numeric: tabular-nums; }
.toc-item span { min-width: 0; overflow-wrap: anywhere; }
.empty-state { grid-column: 1 / -1; margin: 0; padding: 46px 18px; border: 1px solid var(--line); background: var(--paper); color: var(--muted); text-align: center; font-size: 14px; }

@media (max-width: 720px) {
  .page { width: calc(100% - 20px); padding-top: 16px; }
  .intro { grid-template-columns: 1fr; gap: 20px; padding: 23px 20px; }
  h1 { font-size: 28px; }
  .library-summary { padding: 13px 0 0; border-top: 1px solid var(--line); border-left: 0; }
  .library-summary strong { display: inline; margin-right: 5px; font-size: 24px; }
  .library-summary span { display: inline; }
  .library-summary small { margin-top: 0; }
  .library-toolbar { grid-template-columns: 1fr; gap: 10px; }
  .search-box { grid-row: 1; }
  .library-grid { grid-template-columns: 1fr; }
  .folder-card { grid-template-columns: 42px minmax(0, 1fr) auto; padding: 15px; }
  .item-icon { width: 42px; height: 42px; }
  .view-heading { align-items: flex-start; }
  .file-actions .button { flex: 1; }
  .contents-header, .toc-group-title { align-items: flex-start; flex-direction: column; gap: 2px; }
  .toc-item { flex-basis: 100%; }
}
