:root {
  --bg: #121419;
  --panel: #1a1d25;
  --panel-2: #20242e;
  --line: #2b303c;
  --text: #e6e8ee;
  --muted: #8d94a5;
  --accent: #9a86ff;
  --accent-2: #6ee7b7;
  --danger: #ff6b81;
  --ok: #6ee7b7;
  --warn: #f5c26b;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding: max(12px, env(safe-area-inset-top)) 14px calc(28px + env(safe-area-inset-bottom));
  max-width: 780px;
  margin: 0 auto;
}

h1 { font-size: 17px; margin: 0; font-weight: 650; letter-spacing: .3px; }
h2 { font-size: 14px; margin: 0 0 10px; font-weight: 600; color: var(--text); letter-spacing: .3px; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { width: 40px; height: 40px; color: var(--accent); flex: none; }
.status { margin: 1px 0 0; font-size: 12px; color: var(--muted); }

.ghost {
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  border-radius: 10px; padding: 6px 10px; font-size: 14px;
}
.ghost:active { background: var(--panel-2); }

.tabs {
  display: flex; gap: 6px;
  margin: 14px 0 12px; padding: 4px; background: var(--panel); border-radius: 12px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 1 0 auto; white-space: nowrap; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 6px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
}
.tab.active { background: var(--panel-2); color: var(--text); }

.view.hidden, .reader.hidden { display: none; }
.hidden { display: none !important; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.hint { color: var(--muted); font-size: 12px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
  min-width: 0; overflow: hidden;
}
.danger-card { border-color: #3a2a33; }

/* 今天页顶部两张卡：通道 + 额度 */
.meter {
  height: 8px; border-radius: 4px; background: rgba(255, 255, 255, 0.06);
  overflow: hidden; margin: 10px 0 6px;
}
.meter > i {
  display: block; height: 100%; width: 0; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent), #5b4fd6);
  transition: width 0.35s ease;
}
.meter > i.warn { background: linear-gradient(90deg, var(--warn), #b98a3a); }
.meter > i.danger { background: linear-gradient(90deg, var(--danger), #b8445a); }

/* 额度卡：到了预算的提示条 + 调节行 */
.banner {
  border-radius: 10px; padding: 10px 12px; margin: 8px 0 2px;
  font-size: 13px; line-height: 1.5;
  background: rgba(245, 194, 107, 0.12);
  border: 1px solid rgba(245, 194, 107, 0.35);
  color: #f0d3a0;
  overflow-wrap: anywhere;
}
.banner.danger {
  background: rgba(255, 107, 129, 0.12);
  border-color: rgba(255, 107, 129, 0.38);
  color: #ffb3c0;
}
.budget-edit {
  margin-top: 10px; gap: 8px; flex-wrap: nowrap;
}
.budget-edit input {
  flex: 1 1 auto; min-width: 0;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px;
  color: var(--text); font: inherit; font-size: 14px;
}
.budget-edit input:focus { outline: none; border-color: var(--accent); }
.btn {
  flex: 0 0 auto;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 14px;
  color: var(--text); font: inherit; font-size: 14px;
  cursor: pointer;
}
.btn:active { background: var(--line); }
.btn.accent { border-color: var(--accent); color: var(--accent); }
.btn[disabled] { opacity: 0.5; }

.timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.timeline li {
  position: relative; padding: 8px 0 8px 16px; border-left: 1px solid var(--line);
  margin-left: 6px;
}
.timeline li::before {
  content: ""; position: absolute; left: -4.5px; top: 15px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--muted);
}
.timeline li[data-kind="watch"]::before { background: var(--accent); }
.timeline li[data-kind="like"]::before,
.timeline li[data-kind="coin"]::before,
.timeline li[data-kind="favorite"]::before,
.timeline li[data-kind="comment"]::before,
.timeline li[data-kind="dynamic"]::before { background: var(--accent-2); }
.timeline li[data-kind="task"]::before { background: #f0b866; }
.tl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-time { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); }
.tl-who { font-size: 12px; font-weight: 650; }
.tl-who.her { color: var(--accent); }
.tl-who.owner { color: var(--accent-2); }
.tl-body { margin: 2px 0 0; white-space: pre-wrap; word-break: break-word; }
.tl-body a { color: #cfc6ff; text-decoration: none; border-bottom: 1px solid rgba(154,134,255,.35); }
.act-note { margin: 4px 0 0; font-size: 12.5px; color: #a9adbd; line-height: 1.55; }
.act-tag { font-size: 11.5px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; }

/* 今天做了什么：汇总小条 + 分组标题 */
.today-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.today-chips .chip {
  font-size: 11.5px; color: var(--muted); background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px;
  display: inline-flex; gap: 4px; align-items: baseline;
}
.today-chips .chip b { color: var(--text); font-weight: 650; }
.timeline li.tl-group {
  border-left: none; margin: 18px 0 2px; padding: 0;
}
.timeline li.tl-group::before { display: none; }
.tl-group { display: flex; gap: 8px; align-items: baseline; }
.tl-gicon { font-size: 14px; }
.tl-gname { font-weight: 650; font-size: 13.5px; }
.tl-gcount { font-size: 11.5px; color: var(--muted); }
.timeline li[data-kind="chat"]::before { background: #6fc3ff; }
.timeline li[data-kind="idea"]::before { background: #f0b866; }
.timeline li[data-kind="game"]::before { background: #7bd88f; }
.timeline li[data-kind="self"]::before { background: #d98ad9; }
.timeline li[data-kind="asset"]::before { background: #9aa3b2; }


.section-gap { margin-top: 26px; }
.thoughts { display: grid; gap: 10px; margin-top: 8px; }
.thought {
  background: linear-gradient(180deg, rgba(154,134,255,.06), rgba(154,134,255,.015));
  border: 1px solid var(--line); border-left: 2px solid rgba(154,134,255,.55);
  border-radius: 10px; padding: 12px 13px;
}
.thought p { margin: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.65; }
.thought footer, .thought-meta { margin-top: 8px; font-size: 11.5px; color: var(--muted); text-align: right; }

.filelist { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 6px; min-width: 0; }
.filelist li {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.filelist li:active { background: var(--panel-2); }
.filelist .meta { color: var(--muted); font-size: 11.5px; }
.filelist li.book { border-left: 2px solid rgba(154,134,255,.5); }
.filelist li.note, .filelist li.life, .filelist li.kb { border-left: 2px solid rgba(255,214,140,.45); }
.filelist li.note .meta, .filelist li.life .meta, .filelist li.kb .meta { color: rgba(255,214,140,.7); }

.toc { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; max-height: 60vh; overflow: auto; }
.toc li {
  border-bottom: 1px dashed var(--line); padding: 8px 2px;
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
}
.toc li:last-child { border-bottom: 0; }
.toc .meta { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

.reader { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 10px; }
.reader pre {
  white-space: pre-wrap; word-break: break-word; font: 13px/1.6 ui-monospace, Consolas, monospace;
  margin: 10px 0 0; max-height: 62vh; overflow: auto;
}

.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.plain li { border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.plain li:last-child { border-bottom: 0; padding-bottom: 0; }
.small li { font-size: 12.5px; color: var(--muted); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.hist { display: flex; align-items: stretch; gap: 3px; height: 90px; margin-top: 6px; }
.hist .bar { flex: 1; display: flex; align-items: flex-end; background: rgba(255,255,255,.035); border-radius: 3px; }
.hist .bar span { display: block; width: 100%; min-height: 2px; background: linear-gradient(180deg, var(--accent), #5b4fd6); border-radius: 3px 3px 0 0; }
.hist-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 10.5px; margin-top: 4px; }


.morning-list { margin: 6px 0 0; padding-left: 0; list-style: none; }
.morning-list li { padding: 2px 0; }
.morning-group { margin-top: 10px; color: var(--muted); font-size: 12px; letter-spacing: .02em; display: flex; align-items: center; gap: 6px; }
.morning-group:first-child { margin-top: 0; }
.morning-count { font-size: 11px; line-height: 1; padding: 2px 6px; border-radius: 99px; background: var(--line); color: var(--muted); }
.morning-item { padding: 3px 0 3px 2px; }
.morning-more { font-size: 11px; padding: 2px 0 0 2px; }
.morning-note { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; }
.switch span {
  position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: .18s;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px;
  border-radius: 50%; background: #fff; transition: .18s;
}
.switch input:checked + span { background: var(--danger); }
.switch input:checked + span::after { transform: translateX(22px); }

.caps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.caps label, .limits label {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; font-size: 13px;
}
.caps input { width: 18px; height: 18px; accent-color: var(--accent); }
.limits { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.limits input {
  width: 64px; background: #151821; color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 5px 8px; font-size: 13px; text-align: right;
}

input[type="search"], input[type="time"], .limits input {
  font-family: inherit;
}
input[type="search"] {
  width: 100%; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
input[type="time"] {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 8px;
}
.check { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 13px; color: var(--muted); }

.actions { position: sticky; bottom: 8px; display: flex; gap: 10px; align-items: center; margin-top: 4px; }
.primary {
  flex: 1; background: var(--accent); color: #14121f; border: 0; border-radius: 12px;
  padding: 12px; font-size: 15px; font-weight: 700;
}
.primary:active { filter: brightness(.92); }

footer { margin-top: 14px; color: var(--muted); font-size: 11.5px; text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #2a2f3c; color: var(--text); border: 1px solid var(--line);
  padding: 9px 14px; border-radius: 999px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.4);
  z-index: 50;
}

@media (min-width: 620px) {
  .caps { grid-template-columns: repeat(3, 1fr); }
  .limits { grid-template-columns: repeat(3, 1fr); }
}

/* ── 口令 ─────────────────────────────────────────────── */
.login {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 24px;
  background: rgba(13, 15, 21, .98);
}
.login > * { width: min(340px, 100%); flex: none; }
.login h2 { font-size: 20px; margin: 0; }
.login p { margin: 0; line-height: 1.5; }
.login code { color: var(--accent-2); word-break: break-all; }
.login input {
  padding: 13px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  letter-spacing: 1px;
}
.login input:focus { outline: none; border-color: var(--accent); }
.login button {
  height: 46px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #14161c;
  font-size: 16px;
  font-weight: 600;
}
.login button:active { filter: brightness(.92); }

/* 日记·缩略图 */
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.thumb { display: block; aspect-ratio: 1 / 1; border-radius: 10px; overflow: hidden; background: var(--card2, #1b1f27); border: 1px solid var(--line, #262b36); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 2px; border-bottom: 1px solid var(--line, #262b36); min-width: 0; overflow-wrap: anywhere; word-break: break-word; }
.file-item p { margin: 2px 0 0; }

/* 移动端：长网址、长标题一律折行，不许撑破卡片 */
.file-item strong, .file-item a, .file-item span, .file-item p {
  min-width: 0; max-width: 100%;
  overflow-wrap: anywhere; word-break: break-word;
  white-space: normal;
}
.file-item a { color: var(--accent-2, #8ab4ff); text-decoration: none; }
.file-item a:active { text-decoration: underline; }
.card, .view, .filelist, .file-item { box-sizing: border-box; }
.thumbs { min-width: 0; }

/* 移动端：卡片头部那行统计（书 x · 笔记 y · …）不许贴边裁掉 */
.row.between { align-items: flex-start; }
.row.between > * { min-width: 0; }
.row.between .hint { overflow-wrap: anywhere; }
/* 「打开小屋」这种用 a 装作按钮的入口 */
.btn.link {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; margin: 4px 0 10px;
}


.now-doing { margin: 6px 0 2px; font-size: 15px; line-height: 1.5; }
.now-doing.muted { color: var(--muted); font-size: 13px; }

.thoughts { display: block; margin-top: 8px; }
.thought-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line);
}
.thought-row:last-child { border-bottom: 0; padding-bottom: 0; }
.thought-main {
  grid-column: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
.thought-sub {
  grid-column: 1;
  font-size: 12px;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.thought-meta { grid-column: 2; grid-row: 1 / span 2; font-size: 11.5px; color: var(--muted); white-space: nowrap; align-self: start; }

.acts-flat { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 7px; }
.acts-flat .act-row {
  display: grid;
  grid-template-columns: 42px 44px 1fr;
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
  line-height: 1.45;
}
.acts-flat .act-time { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.acts-flat .act-kind { color: var(--muted); font-size: 12px; }
.acts-flat .act-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acts-flat .act-more { font-size: 12px; padding-top: 2px; }

.sub { font-size: 12px; color: var(--muted); font-weight: 650; letter-spacing: .02em; margin: 14px 0 4px; }
.card > h2 + .sub { margin-top: 8px; }
.fails { margin-top: 6px; }
.fails summary { cursor: pointer; list-style: none; }
.fails summary::-webkit-details-marker { display: none; }
.fails[open] summary { margin-bottom: 4px; }

.sched-list { margin: 8px 0 0; }
.sched-row {
  display: grid;
  grid-template-columns: 76px 32px 1fr auto;
  gap: 8px;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}
.sched-row:last-child { border-bottom: 0; }
.sched-row.done { opacity: .45; }
.sched-when { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sched-badge { font-size: 11px; color: var(--accent); border: 1px solid var(--line); border-radius: 4px; padding: 0 3px; text-align: center; }
.sched-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-tail { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* 作息 + 她调过的 */
.sched-phase { margin: 4px 0 6px; font-size: 15px; }
.sched-bar {
  position: relative;
  height: 12px;
  margin: 6px 0 10px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.sched-sleep { position: absolute; top: 0; bottom: 0; background: #4b5b86; opacity: .8; }
.sched-now { position: absolute; top: -1px; bottom: -1px; width: 2px; background: var(--danger); box-shadow: 0 0 4px var(--danger); }
.tune-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; }
.tune-row { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; font-size: 13px; }
.tune-when { color: var(--muted); }
.tune-what { color: var(--ink, #e8eaf0); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tune-delta { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 560px) {
  .tune-row { grid-template-columns: 54px minmax(0, 1fr); }
  .tune-delta { grid-column: 2; }
}
