:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f3efe9;
  --line: #e3dcd2;
  --line-soft: #efe9e1;
  --ink: #1b1a18;
  --muted: #6c6359;
  --accent: #9a2a2a;
  --accent-ink: #ffffff;
  --accent-soft: #f6e8e4;
  --link: #2f5d8c;
  --shadow: 0 1px 2px rgba(30, 24, 16, .05), 0 8px 24px -16px rgba(30, 24, 16, .28);
  --serif: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif CJK SC", "SimSun", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 10px;
  --wrap: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131419;
    --surface: #1a1c22;
    --surface-2: #22252d;
    --line: #31343d;
    --line-soft: #272a32;
    --ink: #e9e6e0;
    --muted: #9b968e;
    --accent: #d9836a;
    --accent-ink: #1b1310;
    --accent-soft: #2c211d;
    --link: #8ab4e8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .7);
  }
}

:root[data-theme="dark"] {
  --bg: #131419;
  --surface: #1a1c22;
  --surface-2: #22252d;
  --line: #31343d;
  --line-soft: #272a32;
  --ink: #e9e6e0;
  --muted: #9b968e;
  --accent: #d9836a;
  --accent-ink: #1b1310;
  --accent-soft: #2c211d;
  --link: #8ab4e8;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px -16px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }

/* ---------- header ---------- */

.site-head {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-head .wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 60px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.brand-mark {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1;
  padding: 7px 8px 6px;
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 4px;
  letter-spacing: .06em;
}
.brand-name { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: .02em; color: var(--ink); }
.brand-name:hover { text-decoration: none; }
.brand-sub { font-size: 12px; color: var(--muted); }

.nav { display: flex; align-items: center; gap: 4px; }
.nav a, .nav button {
  font: inherit;
  font-size: 13.5px;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 6px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.nav a:hover, .nav button:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.on { color: var(--ink); background: var(--surface-2); }
.nav .admin-on { color: var(--accent); font-weight: 600; }

/* ---------- generic ---------- */

main { padding: 0 0 96px; }

.hero { padding: 56px 0 36px; border-bottom: 1px solid var(--line-soft); margin-bottom: 40px; }
.hero h1 { font-family: var(--serif); font-size: 38px; line-height: 1.3; margin: 0 0 10px; letter-spacing: .01em; }
.hero .lede { font-size: 16px; color: var(--muted); max-width: 62ch; margin: 0 0 20px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  font-size: 12.5px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 11px;
  background: var(--surface);
}
.chip strong { color: var(--ink); font-weight: 600; }

h2.sec { font-family: var(--serif); font-size: 15px; font-weight: 600; letter-spacing: .16em; color: var(--muted); text-transform: none; margin: 44px 0 18px; display: flex; align-items: center; gap: 12px; }
h2.sec::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- section grid ---------- */

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

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 18px 15px;
  color: inherit;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover { text-decoration: none; border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }

.card-top { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.badge {
  font-family: var(--serif);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
  white-space: nowrap;
}
.card-weeks { font-size: 12px; color: var(--muted); margin-left: auto; font-variant-numeric: tabular-nums; }
.card h3 { font-family: var(--serif); font-size: 19px; margin: 0 0 4px; font-weight: 600; line-height: 1.4; }
.card .sub { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.card .counts { display: flex; flex-wrap: wrap; gap: 6px; }
.count {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 5px;
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.count.zero { opacity: .45; }

/* ---------- section page ---------- */

.crumb { font-size: 13px; color: var(--muted); padding-top: 26px; }
.page-head { padding: 8px 0 26px; border-bottom: 1px solid var(--line-soft); margin-bottom: 30px; }
.page-head h1 { font-family: var(--serif); font-size: 31px; margin: 6px 0 6px; line-height: 1.32; }
.page-head .sub { color: var(--muted); font-size: 15px; margin: 0 0 14px; }

.weeks { display: grid; gap: 12px; }
.week {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.week-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.week-no {
  font-family: var(--serif); font-size: 12px; color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  background: var(--accent-soft); border-radius: 4px; padding: 1px 8px;
}
.week-topic { font-family: var(--serif); font-size: 16.5px; font-weight: 600; }
.periods { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.period { background: var(--surface-2); border-radius: 8px; padding: 11px 13px; }
.period .k { font-size: 11.5px; color: var(--muted); letter-spacing: .08em; margin-bottom: 3px; }
.period .v { font-size: 13.5px; line-height: 1.7; }
.dev {
  margin-top: 11px; padding: 9px 13px; border-left: 2px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 6px 6px 0; font-size: 13px;
}
.dev .k { font-size: 11.5px; color: var(--accent); font-weight: 600; margin-right: 8px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-top: 14px; }
.fact { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.fact .k { font-family: var(--serif); font-size: 13px; color: var(--accent); margin-bottom: 5px; letter-spacing: .06em; }
.fact .v { font-size: 13.5px; color: var(--ink); line-height: 1.72; }

/* ---------- materials ---------- */

.type-group { margin-bottom: 26px; }
.type-head { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.type-head .icon { font-family: var(--serif); color: var(--accent); font-size: 15px; width: 20px; text-align: center; }
.type-head .label { font-family: var(--serif); font-size: 15px; font-weight: 600; }
.type-head .n { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.files { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.file { display: flex; align-items: center; gap: 12px; padding: 11px 15px; border-top: 1px solid var(--line-soft); }
.file:first-child { border-top: 0; }
.file:hover { background: var(--surface-2); }
.file .ext {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  padding: 3px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted);
  min-width: 46px; text-align: center; border: 1px solid var(--line);
}
.file .meta { min-width: 0; flex: 1; }
.file .name { font-size: 14px; word-break: break-word; }
.file .note { font-size: 12px; color: var(--muted); }
.file .sec-tag { font-size: 11.5px; color: var(--muted); }
.file .info { font-size: 11.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.file .acts { display: flex; gap: 4px; }
.file .acts button, .file .acts a {
  font: inherit; font-size: 12px; color: var(--muted); background: none;
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 9px; cursor: pointer;
}
.file .acts button:hover, .file .acts a:hover { color: var(--ink); border-color: var(--muted); text-decoration: none; }
.file .acts .del:hover { color: var(--accent); border-color: var(--accent); }

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

/* ---------- upload ---------- */

.upload {
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
}
.upload h3 { font-family: var(--serif); font-size: 16px; margin: 0 0 4px; }
.upload .hint { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 180px; }
.field label { font-size: 12px; color: var(--muted); }
select, input[type="text"], input[type="password"] {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 10px; width: 100%;
}
select:focus, input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }

.drop {
  border: 1.5px dashed var(--line);
  border-radius: 9px;
  padding: 26px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.drop b { color: var(--ink); }

.btn {
  font: inherit; font-size: 14px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid transparent; border-radius: 7px; padding: 8px 18px;
}
.btn:hover { filter: brightness(1.08); }
.btn[disabled] { opacity: .5; cursor: default; filter: none; }
.btn.ghost { background: none; color: var(--muted); border-color: var(--line); }
.btn.ghost:hover { color: var(--ink); border-color: var(--muted); filter: none; }

.queue { margin-top: 12px; display: grid; gap: 6px; }
.qitem { display: flex; align-items: center; gap: 10px; font-size: 13px; padding: 6px 10px; background: var(--surface-2); border-radius: 7px; }
.qitem .qname { flex: 1; min-width: 0; word-break: break-word; }
.qitem .qstat { font-size: 12px; color: var(--muted); white-space: nowrap; }
.qitem.ok .qstat { color: #2e7d4f; }
.qitem.err .qstat { color: var(--accent); }

/* ---------- dialog ---------- */

dialog {
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink);
  padding: 22px; max-width: 380px; width: calc(100% - 40px); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(20, 16, 12, .45); backdrop-filter: blur(2px); }
dialog h3 { font-family: var(--serif); font-size: 17px; margin: 0 0 6px; }
dialog p { font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.dlg-acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); font-size: 13.5px;
  padding: 9px 18px; border-radius: 999px; z-index: 60; box-shadow: var(--shadow);
}

.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.filters button {
  font: inherit; font-size: 12.5px; color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; cursor: pointer;
}
.filters button:hover { color: var(--ink); }
.filters button.on { background: var(--accent); color: var(--accent-ink); border-color: transparent; }

footer.site-foot {
  border-top: 1px solid var(--line);
  padding: 22px 0 40px;
  font-size: 12.5px;
  color: var(--muted);
}

@media (max-width: 700px) {
  .hero { padding: 34px 0 26px; }
  .hero h1 { font-size: 28px; }
  .page-head h1 { font-size: 24px; }
  .periods { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
  .file { flex-wrap: wrap; }
  .file .info { order: 5; }
}
