/* 读书助手 — 全局样式（暗色优先 + 移动端友好） */

* { box-sizing: border-box; }
:root {
  --bg:        #0b1020;
  --panel:     #161c33;
  --panel-2:   #1f2745;
  --line:      #2a3358;
  --text:      #e6e9f5;
  --text-soft: #9aa3c4;
  --accent:    #7c9cff;
  --accent-2:  #a78bfa;
  --gold:      #f5c451;
  --green:     #4ade80;
  --red:       #f87171;
  --shadow:    0 8px 28px rgba(0,0,0,.35);
  --radius:    14px;
}

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft Yahei", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }

#app { max-width: 980px; margin: 0 auto; padding: 16px; padding-bottom: 80px; }

/* 顶栏 */
.topbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 4px 18px;
}
.topbar h1 {
  font-size: 18px; margin: 0; flex: 1;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-weight: 700;
}
.topbar .who { color: var(--text-soft); font-size: 13px; }
.topbar .icon-btn {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 6px 10px; border-radius: 10px; cursor: pointer; font-size: 13px;
}
.topbar .icon-btn:hover { background: var(--panel-2); }

/* 导航 tab */
.tabs {
  display: flex; gap: 4px; background: var(--panel); padding: 4px;
  border-radius: 12px; border: 1px solid var(--line); margin-bottom: 16px;
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 1; min-width: 80px; text-align: center; padding: 8px 10px;
  border-radius: 9px; cursor: pointer; color: var(--text-soft); font-size: 14px;
  white-space: nowrap;
}
.tab.active {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: white; font-weight: 600;
}

/* 卡片 / 区块 */
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 10px; font-size: 16px; }
.panel .row { display: flex; gap: 8px; flex-wrap: wrap; }

label { display: block; font-size: 13px; color: var(--text-soft); margin: 8px 0 4px; }
input, select, textarea {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

button.primary {
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  color: white; border: none; padding: 10px 16px; border-radius: 10px;
  font-weight: 600; cursor: pointer;
}
button.primary:disabled { opacity: .5; cursor: not-allowed; }
button.ghost {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 10px; cursor: pointer; font-size: 13px;
}
button.ghost:hover { background: var(--line); }
button.danger { color: var(--red); }

/* 文件投放区 */
.dropzone {
  border: 2px dashed var(--line); border-radius: 14px; padding: 22px;
  text-align: center; color: var(--text-soft); cursor: pointer;
  transition: all .2s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--panel-2); color: var(--text); }

/* 列表 */
.book-list { display: flex; flex-direction: column; gap: 8px; }
.book-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.book-row .meta { flex: 1; min-width: 0; }
.book-row .title { font-weight: 600; }
.book-row .sub { color: var(--text-soft); font-size: 12px; }
.book-row .badge {
  background: var(--bg); border: 1px solid var(--line);
  padding: 2px 8px; border-radius: 999px; font-size: 11px; color: var(--text-soft);
}

/* 卡片网格 */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.card {
  position: relative; padding: 14px; border-radius: 14px;
  background: var(--panel); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px;
  transition: transform .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--accent); }
.card .kind {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  align-self: flex-start;
}
.card[data-kind="knowledge"] .kind { background: rgba(124,156,255,.18); color: var(--accent); }
.card[data-kind="quote"] .kind     { background: rgba(245,196,81,.16);  color: var(--gold); }
.card[data-kind="summary"] .kind   { background: rgba(74,222,128,.16);  color: var(--green); }
.card[data-kind="composite"] .kind { background: rgba(167,139,250,.20); color: var(--accent-2); }

/* 复合卡：略大的留白 + 渐变描边 */
.card-composite {
  background: linear-gradient(150deg, var(--panel), var(--panel-2));
  border: 1px solid transparent;
  background-clip: padding-box;
  position: relative;
}
.card-composite::before {
  content: "";
  position: absolute; inset: -1px; border-radius: inherit; padding: 1px;
  background: linear-gradient(135deg, rgba(124,156,255,.55), rgba(167,139,250,.55), rgba(245,196,81,.45));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}

/* 复合卡的 Markdown 内容样式 */
.ccontent.md h2,
.ccontent.md h3 {
  margin: 14px 0 6px;
  font-size: 14px;
  color: var(--text-soft);
  font-weight: 600;
  letter-spacing: .5px;
}
.ccontent.md h2:first-child,
.ccontent.md h3:first-child { margin-top: 0; }
.ccontent.md p     { margin: 4px 0; }
.ccontent.md ul    { margin: 4px 0 4px 18px; padding: 0; }
.ccontent.md li    { margin: 2px 0; }
.ccontent.md strong { color: var(--accent); }
.ccontent.md blockquote {
  margin: 6px 0; padding: 10px 14px;
  border-left: 3px solid var(--gold);
  background: rgba(245,196,81,.08);
  border-radius: 0 8px 8px 0;
  color: var(--text);
  font-style: italic;
}
.ccontent.md blockquote p { margin: 0; }
.ccontent.md code {
  background: var(--bg); border: 1px solid var(--line);
  padding: 1px 6px; border-radius: 4px; font-size: 13px;
}
.card .ctitle { font-size: 16px; font-weight: 700; line-height: 1.35; }
.card .ccontent { color: var(--text); font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.card .ctags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.card .ctags span { font-size: 11px; color: var(--text-soft); background: var(--panel-2); padding: 2px 6px; border-radius: 6px; }
.card .cfoot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 6px; padding-top: 8px; border-top: 1px dashed var(--line);
  color: var(--text-soft); font-size: 11px;
}
.card .star {
  cursor: pointer; user-select: none; font-size: 18px; color: var(--text-soft);
}
.card .star.on { color: var(--gold); }

/* 大卡片（随机抽卡 / 每日推送 详情） */
.big-card {
  padding: 24px; border-radius: 18px;
  background: linear-gradient(140deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line);
  min-height: 220px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px;
}
.big-card .ctitle { font-size: 22px; }
.big-card .ccontent { font-size: 16px; line-height: 1.8; }

/* 工具条 */
.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 14px; align-items: center;
}
.toolbar select, .toolbar input {
  width: auto; flex: 0 1 auto; padding: 8px 10px; font-size: 13px;
}
.toolbar .grow { flex: 1; min-width: 180px; }

/* 章节多选 */
.chapter-pick {
  max-height: 240px; overflow: auto; border: 1px solid var(--line);
  border-radius: 10px; padding: 8px; background: var(--bg);
}
.chapter-pick label {
  display: flex; align-items: center; gap: 8px;
  margin: 0; padding: 4px 6px; cursor: pointer;
  color: var(--text); font-size: 13px;
}
.chapter-pick label:hover { background: var(--panel-2); border-radius: 6px; }
.chapter-pick input[type="checkbox"] { width: auto; }

/* 提示 */
.toast {
  position: fixed; left: 50%; top: 24px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow);
  z-index: 999; max-width: 88vw; font-size: 14px;
}
.toast.err { border-color: var(--red); color: var(--red); }
.toast.ok  { border-color: var(--green); color: var(--green); }

/* 空态 */
.empty {
  text-align: center; padding: 40px 20px; color: var(--text-soft);
}

/* 登录页 */
.auth-wrap {
  max-width: 360px; margin: 80px auto;
}
.auth-wrap h1 {
  text-align: center; margin-bottom: 8px;
  background: linear-gradient(120deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.auth-wrap .sub {
  text-align: center; color: var(--text-soft); margin-bottom: 24px;
}
.auth-wrap .switch {
  text-align: center; margin-top: 12px; color: var(--text-soft); font-size: 13px;
}

/* 媒体查询 */
@media (max-width: 600px) {
  #app { padding: 10px; }
  .topbar h1 { font-size: 16px; }
  .big-card { padding: 18px; }
  .big-card .ctitle { font-size: 18px; }
}

/* 加载 */
.spinner {
  display: inline-block; width: 14px; height: 14px;
  border: 2px solid var(--text-soft); border-top-color: transparent;
  border-radius: 50%; animation: spin .8s linear infinite;
  vertical-align: middle; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }
