/* 萤火 AI 人生记录 · 正式前端公共样式
   设计原则：手机优先；桌面下居中成手机宽度的卡片。无框架、无构建。 */

:root {
  --bg: #f2f3f5;
  --card: #ffffff;
  --line: #e3e5e8;
  --ink: #1f2329;
  --muted: #8a9099;
  --me: #95ec69;
  --accent: #2f6bff;
  --warn: #c0392b;
  --maxw: 460px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }

body {
  background: #dcdfe3;
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: var(--maxw);
  min-height: 100%;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

header.topbar {
  flex: none;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
header.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
header.topbar .who { font-size: 12px; color: var(--muted); }

main {
  flex: 1 1 auto;
  padding: 16px 14px;
  overflow-y: auto;
}

footer.site {
  flex: none;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: 12px 14px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  line-height: 1.9;
}
footer.site a { color: var(--muted); text-decoration: none; margin: 0 6px; }
footer.site .icp { display: block; margin-top: 4px; }

h2.page-title { font-size: 18px; margin: 4px 0 14px; }
.muted { color: var(--muted); }
.note { color: var(--muted); font-size: 13px; }

/* forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
.field input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  outline: none;
  background: #fff;
}
.field input:focus { border-color: var(--accent); }

button {
  font: inherit;
  font-size: 15px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; }
button.ghost { background: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }

.row-actions { display: flex; gap: 10px; margin-top: 8px; }
.row-actions button { flex: 1; }

.banner {
  display: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}
.banner.error { display: block; background: #fdecea; color: var(--warn); }
.banner.notice { display: block; background: #eaf3ff; color: #1f4fd8; }

/* hero / landing */
.hero { text-align: center; padding: 28px 8px 8px; }
.hero h2 { font-size: 22px; margin: 8px 0; }
.hero p { color: var(--muted); }

/* AI generation notice */
.ai-hint {
  background: #fffdf5;
  border: 1px solid #efe2bd;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  color: #8a6d3b;
  margin: 12px 0;
}

/* simple list (shells / terms etc.) */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 6px; font-size: 15px; }
.card .meta { color: var(--muted); font-size: 12px; }
.legal p, .legal li { color: var(--ink); }
.legal h3 { margin-top: 18px; }

/* chat */
#chatArea { display: flex; flex-direction: column; min-height: 0; }
#messages { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.msg {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user { align-self: flex-end; background: var(--me); border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
#composer { display: flex; gap: 8px; align-items: flex-end; }
#composer textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  outline: none;
  background: #fff;
}
#composer textarea:focus { border-color: var(--accent); }
#composer button { flex: none; border-radius: 10px; }
#status { font-size: 13px; color: var(--muted); min-height: 18px; margin: 6px 2px 0; }
#draftAction { margin-top: 12px; }

/* diary draft / confirm */
.draft-title { font-size: 18px; font-weight: 600; margin: 4px 0 10px; word-break: break-word; }
.draft-body {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
  line-height: 1.7;
}
.draft-meta { color: var(--muted); font-size: 13px; margin: 10px 0; }
.mem-list { list-style: none; padding: 0; margin: 8px 0 0; }
.mem-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.mem-item input { margin-top: 3px; }
.mem-item .mem-text { font-size: 14px; }
.mem-item .mem-type { color: var(--muted); font-size: 12px; }

/* diary list */
.diary {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.diary:hover { border-color: var(--accent); }
.diary .d-date { color: var(--muted); font-size: 12px; }
.diary .d-title { font-size: 16px; font-weight: 600; margin: 4px 0 6px; word-break: break-word; }
.diary .d-preview { color: #5a6068; font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* modal (diary detail) */
.modal-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  padding: 16px;
  overflow-y: auto;
  z-index: 20;
}
.modal-mask.open { display: block; }
.modal {
  max-width: 520px;
  margin: 24px auto;
  background: var(--bg);
  border-radius: 14px;
  padding: 16px;
}
.modal .d-date { color: var(--muted); font-size: 12px; }
.modal .d-body { white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.7; margin-top: 8px; }

/* 4C: 由模板内联 style= 迁移而来的工具类（CSP style-src 'self' 兼容，无内联样式） */
.hidden { display: none; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-18 { margin-top: 18px; }
.transcript-preview { max-height: 200px; overflow-y: auto; margin-bottom: 12px; }
.sub-title { font-size: 15px; }
.m-title { margin: 4px 0 10px; font-size: 15px; }
