:root {
  --bg: #f5f2ec; --card: #ffffff; --ink: #1d1b18; --muted: #6f6a61;
  --line: #e4ded3; --accent: #a8802f; --chip: #f1ebdf; --ph: #ebe5d9; --side: #efeae1;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141311; --card: #1e1c19; --ink: #f0ece4; --muted: #a39d92;
    --line: #2f2c27; --accent: #d1aa5a; --chip: #2a2620; --ph: #26231f; --side: #191816;
  }
}
:root[data-theme="dark"] {
  --bg: #141311; --card: #1e1c19; --ink: #f0ece4; --muted: #a39d92;
  --line: #2f2c27; --accent: #d1aa5a; --chip: #2a2620; --ph: #26231f; --side: #191816;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }

/* 登录 */
#login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
#login-form {
  width: min(360px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px 28px; display: flex; flex-direction: column; gap: 14px;
}
#login h1 { margin: 0 0 8px; font-size: 24px; }
#login input {
  font: inherit; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
}
#login input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#login button {
  padding: 10px; border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  font-weight: 600; cursor: pointer;
}
#login-err { margin: 0; min-height: 1.4em; color: #c0392b; font-size: 14px; }

/* 布局 */
#app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
aside {
  background: var(--side); border-right: 1px solid var(--line); padding: 24px 14px;
  display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 700; font-size: 18px; padding: 0 10px 18px; }
nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
nav a {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-weight: 600;
}
nav a small { color: var(--muted); font-weight: 400; font-size: 12px; }
nav a:hover { background: var(--chip); }
nav a[aria-current="page"] { background: var(--card); box-shadow: inset 3px 0 0 var(--accent); }
#logout {
  background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px;
  color: var(--muted); cursor: pointer; font-size: 14px;
}
main { padding: 40px 32px 80px; max-width: 1180px; width: 100%; min-width: 0; }

#ch-head h1 { font-size: clamp(28px, 4vw, 40px); margin: 0 0 4px; }
#ch-head p { margin: 0; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chip { background: var(--chip); border-radius: 999px; padding: 2px 12px; font-size: 13px; }

.tabs { display: flex; gap: 8px; border-bottom: 1px solid var(--line); margin: 28px 0 8px; overflow-x: auto; }
.tabs a {
  font-size: 17px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap;
  padding: 10px 6px 12px; margin-bottom: -1px; border-bottom: 3px solid transparent;
}
.tabs a[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { font-size: 13px; font-weight: 400; margin-left: 4px; }

section { margin-top: 40px; }
section > h2 { font-size: 22px; margin: 0 0 12px; display: flex; align-items: baseline; gap: 10px; }
section > h2 small { font-size: 14px; color: var(--muted); font-weight: 400; }
.series { margin: -6px 0 16px; color: var(--muted); font-size: 14px; }
.series b { color: var(--accent); }
.empty {
  border: 1px dashed var(--line); border-radius: 12px; padding: 20px; color: var(--muted);
  font-size: 14px; text-align: center;
}
.subtabs { display: flex; gap: 6px; margin-top: 20px; }
.subtabs a {
  font-size: 14px; padding: 4px 14px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); text-decoration: none;
}
.subtabs a[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* 计划：小卡片 */
.grid {
  list-style: none; margin: 0; padding: 0; display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.todo { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; }
.ph {
  position: relative; aspect-ratio: 16 / 9; background: var(--ph); overflow: hidden;
  display: flex; flex-direction: column; justify-content: flex-end; padding: 0 12px 10px;
}
.ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
.ph::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.78), rgba(0,0,0,0) 60%); }
.ph .t, .ph .y { position: relative; z-index: 1; }
.ph .t { font-size: 20px; font-weight: 700; line-height: 1.3; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.ph .y { font-size: 13px; color: #f0d08a; }
.todo .info { padding: 12px 14px 14px; font-size: 14px; color: var(--muted); }
.src { font-size: 12px; color: var(--muted); margin-top: 6px; display: inline-block; }

/* 日历 */
.month { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ev { display: grid; grid-template-columns: 70px 1fr auto; gap: 4px 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.ev .d { font-weight: 700; font-size: 18px; line-height: 1.2; }
.ev .d small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); }
.ev .name { font-weight: 600; }
.ev .note { color: var(--muted); font-size: 14px; }
.ev .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.ev .left { font-size: 13px; color: var(--muted); white-space: nowrap; }
.ev.past { opacity: .45; }
.ev.soon .left { color: var(--accent); font-weight: 600; }
.k { font-size: 12px; border-radius: 999px; padding: 0 8px; border: 1px solid var(--line); color: var(--muted); }
.k.hol { border-color: transparent; background: var(--chip); color: var(--ink); }
.k.round { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.k.rel { border-style: dashed; }

/* 成品 */
.products { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); margin-top: 24px; }
.prod { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; display: flex; flex-direction: column; }
.prod .cover { aspect-ratio: 16 / 9; background: #000; display: block; }
.prod .cover img, .prod .cover video { width: 100%; height: 100%; object-fit: cover; display: block; }
.prod .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.prod h3 { margin: 0; font-size: 19px; line-height: 1.35; }
.prod .date { color: var(--muted); font-size: 13px; }
.files { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.files li { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-top: 1px solid var(--line); }
.files a { text-decoration: none; font-weight: 600; }
.files .kind { color: var(--muted); font-size: 12px; white-space: nowrap; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; cursor: pointer; text-align: left; }

/* 信息来源 */
.src-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.src-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.src-list .note { color: var(--muted); font-size: 14px; }

/* 文章 */
.articles { list-style: none; margin: 24px 0 0; padding: 0; border-top: 1px solid var(--line); }
.articles li { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.articles .meta { color: var(--muted); font-size: 13px; }
.articles .status { font-size: 12px; border-radius: 999px; padding: 1px 10px; background: var(--chip); align-self: start; }

/* 阅读器 */
dialog#reader {
  width: min(820px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgba(0,0,0,.5); }
.reader-bar {
  position: sticky; top: 0; display: flex; gap: 14px; align-items: center; padding: 12px 18px;
  background: var(--card); border-bottom: 1px solid var(--line); font-size: 14px;
}
#reader-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#reader-close { background: none; border: 0; font-size: 18px; cursor: pointer; color: var(--muted); }
#reader-body { padding: 8px 28px 32px; line-height: 1.8; overflow-wrap: anywhere; }
#reader-body img { max-width: 100%; }
#reader-body blockquote { margin: 0; padding-left: 14px; border-left: 3px solid var(--line); color: var(--muted); }

@media (max-width: 760px) {
  #app { grid-template-columns: 1fr; }
  aside {
    position: static; height: auto; flex-direction: row; align-items: center; gap: 8px;
    padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto;
  }
  .brand { display: none; }
  nav { flex-direction: row; }
  nav a { white-space: nowrap; gap: 6px; }
  #logout { white-space: nowrap; }
  main { padding: 24px 16px 60px; }
  .products { grid-template-columns: 1fr; }
  .ev { grid-template-columns: 60px 1fr; }
  .ev .left { grid-column: 2; }
  #reader-body { padding: 8px 16px 24px; }
}
