/* 暖心军师 · 样式
   派生自 MIT 许可开源项目 狗头军师 / Goutoujunshi（原作者 powerycy）的配色与语气基调。 */

:root {
  color-scheme: light;
  --bg: #fdf7f1;
  --bg-soft: #f7ece2;
  --surface: #ffffff;
  --surface-2: #fffaf5;
  --ink: #3b2f29;
  --ink-soft: #6b5a50;
  --muted: #9a887c;
  --line: #f0e0d3;
  --line-strong: #e6d0bf;
  --accent: #d9714f;
  --accent-soft: #fbe7de;
  --accent-deep: #b8543a;
  --calm: #6f9e86;
  --calm-soft: #e6f1ea;
  --warn: #c98a2e;
  --warn-soft: #fdf1dc;
  --danger: #c4453c;
  --danger-soft: #fce9e7;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 2px 4px rgba(90, 60, 45, 0.04), 0 10px 30px rgba(90, 60, 45, 0.07);
  --shadow-soft: 0 1px 2px rgba(90, 60, 45, 0.04), 0 6px 16px rgba(90, 60, 45, 0.05);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 15px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }

a { color: var(--accent-deep); }

.app { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 246px;
  flex: 0 0 246px;
  background: linear-gradient(180deg, #fff9f3 0%, #fdf2e9 100%);
  border-right: 1px solid var(--line);
  padding: 22px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { padding: 0 8px; }
.brand h1 {
  font-size: 20px;
  margin: 0;
  letter-spacing: 0.5px;
}
.brand p {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.nav { display: flex; flex-direction: column; gap: 3px; }

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  text-align: left;
  font-size: 14.5px;
  transition: background 0.15s, color 0.15s;
}
.nav button:hover { background: rgba(217, 113, 79, 0.08); color: var(--ink); }
.nav button.active {
  background: var(--surface);
  color: var(--accent-deep);
  font-weight: 600;
  box-shadow: var(--shadow-soft);
}
.nav .ico { width: 18px; text-align: center; font-size: 15px; }

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  padding: 0 8px;
}
.sos-link {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f4d4d1;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
.sos-link:hover { background: #f9ddda; }

/* ---------- 主区域 ---------- */
.main {
  flex: 1 1 auto;
  min-width: 0;
  padding: 30px 38px 80px;
  max-width: 1000px;
}

.view { display: none; animation: fade 0.28s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head { margin-bottom: 22px; }
.view-head h2 {
  margin: 0 0 6px;
  font-size: 25px;
  letter-spacing: 0.3px;
}
.view-head p { margin: 0; color: var(--ink-soft); max-width: 66ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 16px;
}
.card h3 {
  margin: 0 0 12px;
  font-size: 16.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h3 .sub { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.card p { margin: 0 0 10px; }
.card > p:last-child, .card > div:last-child { margin-bottom: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-deep); }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

.btn-row { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 13.5px;
  transition: all 0.15s;
  user-select: none;
}
.chip:hover { border-color: var(--accent); color: var(--accent-deep); }
.chip.on {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-deep);
  font-weight: 600;
}
.chip.sm { padding: 4px 11px; font-size: 12.5px; }
.chip.calm.on { background: var(--calm-soft); border-color: var(--calm); color: #40715a; }
.chip.warn.on { background: var(--warn-soft); border-color: var(--warn); color: #90621c; }
.chip.danger.on { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  font-weight: 600;
}
label.field > span em { font-style: normal; font-weight: 400; color: var(--muted); }

input[type="text"], input[type="date"], textarea, select {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  line-height: 1.7;
}
input[type="text"]:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 113, 79, 0.13);
  background: var(--surface);
}
textarea { resize: vertical; min-height: 84px; }

input[type="range"] {
  width: 100%;
  height: 28px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background-color: #f6e8dd;
  background-image: linear-gradient(90deg, #e6f1ea 0%, #fdf1dc 45%, #fbe7de 70%, #fce9e7 100%);
  border: 1px solid var(--line);
}
input[type="range"]:focus,
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 5px rgba(217, 113, 79, 0.18), 0 2px 6px rgba(90, 60, 45, 0.22);
}
input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 5px rgba(217, 113, 79, 0.18), 0 2px 6px rgba(90, 60, 45, 0.22);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  margin-top: -8px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 6px rgba(90, 60, 45, 0.22);
  transition: transform 0.12s;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }
input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e6f1ea 0%, #fdf1dc 45%, #fbe7de 70%, #fce9e7 100%);
  border: 1px solid var(--line);
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 6px rgba(90, 60, 45, 0.22);
}

.hint { font-size: 12.5px; color: var(--muted); line-height: 1.65; }
.divider { height: 1px; background: var(--line); margin: 18px 0; border: 0; }

/* ---------- 提示条 ---------- */
.note {
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  font-size: 13.5px;
  line-height: 1.7;
  border: 1px solid var(--line);
  background: var(--surface-2);
  margin-bottom: 14px;
}
.note.calm { background: var(--calm-soft); border-color: #cfe4d8; color: #33604c; }
.note.warn { background: var(--warn-soft); border-color: #f0dcb8; color: #8a5c14; }
.note.danger { background: var(--danger-soft); border-color: #f3d3d0; color: #9d332c; }
.note b { font-weight: 700; }

/* ---------- 情绪温度计 ---------- */
.thermo-value {
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  transition: color 0.25s;
}
.thermo-row { display: flex; align-items: center; gap: 18px; margin-bottom: 6px; }
.thermo-msg { flex: 1; font-size: 14px; color: var(--ink-soft); }
.thermo-scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: -4px; }

/* ---------- 呼吸 ---------- */
.breath-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 8px 0 4px; }
.breath-stage {
  position: relative;
  width: 200px;
  height: 200px;
  display: grid;
  place-items: center;
}
.breath-ball {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd9c9, var(--accent));
  box-shadow: 0 10px 30px rgba(217, 113, 79, 0.3);
  transition: transform 4s cubic-bezier(0.4, 0, 0.2, 1);
  transform: scale(0.7);
}
.breath-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px dashed var(--line-strong);
}
.breath-label {
  position: absolute;
  font-size: 15px;
  font-weight: 600;
  color: var(--accent-deep);
  background: rgba(255, 255, 255, 0.86);
  padding: 3px 12px;
  border-radius: 999px;
  bottom: 6px;
}
.breath-count { font-size: 13px; color: var(--muted); }

/* ---------- 待办 / 清单 ---------- */
.check-item {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  cursor: pointer;
}
.check-item:last-child { border-bottom: 0; }
.check-item .box {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  margin-top: 4px;
  border-radius: 5px;
  border: 1.6px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: transparent;
  background: var(--surface);
}
.check-item.on .box { background: var(--accent); border-color: var(--accent); color: #fff; }
.check-item .txt { flex: 1; font-size: 14px; }
.check-item.on .txt { color: var(--muted); }

.dot-list { margin: 0; padding-left: 18px; }
.dot-list li { margin-bottom: 6px; }

/* ---------- 结果区 ---------- */
.result { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px 18px; }
.result h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--accent-deep);
  letter-spacing: 0.4px;
}
.result h4:not(:first-child) { margin-top: 18px; }
.result .quote {
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  margin: 8px 0;
  font-size: 14.5px;
}
.result .quote strong { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.three-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.three-col > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; }
.three-col h5 { margin: 0 0 6px; font-size: 12.5px; color: var(--muted); }
.three-col ul { margin: 0; padding-left: 16px; font-size: 13.5px; }

/* ---------- 知识库 ---------- */
.search-row { display: flex; gap: 10px; margin-bottom: 12px; }
.search-row input { flex: 1; }
.kb-hit {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  margin-bottom: 9px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.kb-hit:hover { border-color: var(--accent); }
.kb-hit .t { font-weight: 600; font-size: 14.5px; }
.kb-hit .m { font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.kb-hit .s { font-size: 13.5px; color: var(--ink-soft); }
mark { background: #ffe9a8; padding: 0 2px; border-radius: 3px; }

.layer-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  background: var(--bg-soft);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.layer-tag.skill { background: var(--accent-soft); color: var(--accent-deep); border-color: #f2cdbd; }
.layer-tag.knowledge { background: var(--calm-soft); color: #3f6f58; border-color: #cfe4d8; }
.layer-tag.practical { background: var(--warn-soft); color: #8a5c14; border-color: #f0dcb8; }

/* ---------- 阅读器 ---------- */
.reader-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(59, 47, 41, 0.42);
  backdrop-filter: blur(2px);
  display: none;
  z-index: 40;
}
.reader-backdrop.open { display: block; }
.reader {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(760px, 94vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: -14px 0 40px rgba(90, 60, 45, 0.16);
  z-index: 41;
  display: flex;
  flex-direction: column;
  transform: translateX(102%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.reader.open { transform: none; }
.reader header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.reader header .t { flex: 1; font-weight: 600; font-size: 15.5px; }
.reader .body { padding: 22px 30px 60px; overflow-y: auto; }

.md { font-size: 14.6px; line-height: 1.85; }
.md h1 { font-size: 22px; margin: 6px 0 14px; }
.md h2 { font-size: 18px; margin: 26px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 16px; margin: 20px 0 8px; }
.md h4 { font-size: 14.5px; margin: 16px 0 6px; color: var(--ink-soft); }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 22px; }
.md li { margin-bottom: 4px; }
.md code {
  background: var(--bg-soft);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 13px;
  font-family: "Cascadia Mono", Consolas, monospace;
}
.md pre { background: var(--bg-soft); padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md blockquote {
  margin: 0 0 12px;
  padding: 8px 14px;
  border-left: 3px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--ink-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.md table { border-collapse: collapse; width: 100%; margin: 0 0 14px; font-size: 13.6px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 11px; text-align: left; vertical-align: top; }
.md th { background: var(--bg-soft); font-weight: 600; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.md a { word-break: break-all; }

/* ---------- 记录 ---------- */
.spark { width: 100%; height: 90px; }
.log-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
}
.log-item:last-child { border-bottom: 0; }
.log-item .date { flex: 0 0 82px; font-size: 12.5px; color: var(--muted); padding-top: 3px; }
.log-item .score {
  flex: 0 0 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  background: var(--accent-soft);
  color: var(--accent-deep);
}
.log-item .content { flex: 1; min-width: 0; }
.log-item .content .note-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.lock-pill {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 9px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: #8a5c14;
  border: 1px solid #f0dcb8;
}
.lock-pill.ready { background: var(--calm-soft); color: #3f6f58; border-color: #cfe4d8; }

/* ---------- 安全 ---------- */
.redflag { border-color: #f3d3d0; background: #fffbfa; }
.hotline {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.hotline:last-child { border-bottom: 0; }
.hotline .num {
  flex: 0 0 128px;
  font-weight: 700;
  font-size: 15px;
  color: var(--danger);
  letter-spacing: 0.5px;
}
.hotline .desc { flex: 1; font-size: 13.6px; color: var(--ink-soft); }

/* ---------- 输出预览 ---------- */
.out-box {
  background: #fffdfb;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 44vh;
  overflow-y: auto;
}

/* ---------- 提示气泡 ---------- */
.site-footer {
  margin-top: 44px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
  font-size: 12.6px;
  line-height: 1.85;
  color: var(--muted);
}
.site-footer h4 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.6px;
  color: var(--ink-soft);
}
.site-footer p { margin: 0 0 9px; }
.site-footer b { color: var(--ink-soft); }
.site-footer details { margin-top: 12px; }
.site-footer summary {
  cursor: pointer;
  color: var(--accent-deep);
  font-weight: 600;
  list-style: none;
  padding: 3px 0;
}
.site-footer summary::-webkit-details-marker { display: none; }
.site-footer summary::before { content: "▸ "; }
.site-footer details[open] summary::before { content: "▾ "; }
.site-footer summary:hover { text-decoration: underline; }
.site-footer ol {
  margin: 14px 0 0;
  padding-left: 20px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 16px 18px 16px 36px;
}
.site-footer li { margin-bottom: 9px; }
.site-footer li:last-child { margin-bottom: 0; }
.site-footer .meta {
  margin: 14px 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s;
  z-index: 90;
  box-shadow: 0 8px 24px rgba(59, 47, 41, 0.28);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 移动端 ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar {
    width: auto;
    flex: none;
    height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 16px 14px 12px;
  }
  .nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .nav button { white-space: nowrap; padding: 7px 12px; font-size: 13.5px; }
  .nav button span.label { display: inline; }
  .sidebar-foot { margin-top: 0; flex-direction: row; align-items: center; justify-content: space-between; font-size: 11.5px; }
  .main { padding: 20px 16px 70px; }
  .view-head h2 { font-size: 21px; }
  .card { padding: 16px; }
}

@media print {
  .sidebar, .btn-row, .sos-link { display: none; }
  .main { padding: 0; }
}
