/* ————— 朝暮集 2.0 ————— */

:root {
  --bg: #faf6ef;
  --card: #ffffff;
  --ink: #2b2733;
  --ink-soft: #6f6a78;
  --ink-faint: #a49eae;
  --line: #ece5d8;
  --accent: #f4694c;           /* 当前板块主色，切换板块时被覆盖 */
  --accent-soft: #fdeae4;
  --coral: #f4694c;   --coral-soft: #fdeae4;
  --plum: #8b5cf6;    --plum-soft: #f1eafe;
  --teal: #0eaf9e;    --teal-soft: #e0f6f3;
  --amber: #ee9d1e;   --amber-soft: #fdf2dd;
  --green: #61a53f;   --green-soft: #ebf5e3;
  --rose: #e0507a;    --rose-soft: #fce8ef;
  --radius: 18px;
  --shadow: 0 4px 20px rgba(80, 60, 40, 0.07);
  --shadow-lg: 0 12px 48px rgba(60, 40, 20, 0.16);
  --sans: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --kai: "LXGW WenKai", var(--sans);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--sans);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 40% at 15% 0%, rgba(244, 105, 76, 0.06), transparent),
    radial-gradient(ellipse 50% 35% at 90% 10%, rgba(139, 92, 246, 0.05), transparent);
  background-attachment: fixed;
  color: var(--ink);
  line-height: 1.7;
  min-height: 100vh;
}

.hidden { display: none !important; }

button { font-family: inherit; cursor: pointer; }

img { max-width: 100%; }

/* ————— 登录 / 初始化 ————— */

.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  background: var(--card);
  border-radius: 24px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  text-align: center;
}

.auth-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px; height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--coral), #f89d2a);
  color: #fff;
  font-family: var(--kai);
  font-size: 20px;
  writing-mode: vertical-rl;
  margin-bottom: 16px;
}

.auth-card h1 {
  font-family: var(--kai);
  font-size: 26px;
  letter-spacing: 0.2em;
  margin-bottom: 6px;
}

.auth-card .auth-sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin-bottom: 28px;
}

.auth-card .field { text-align: left; }

.auth-error {
  color: var(--coral);
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 8px;
}

.auth-card .btn { width: 100%; justify-content: center; }

/* ————— 顶栏 ————— */

.app-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px clamp(16px, 5vw, 48px);
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--coral), #f89d2a);
  color: #fff;
  font-family: var(--kai);
  font-size: 12px;
  writing-mode: vertical-rl;
  line-height: 1.1;
}

.brand-name {
  font-family: var(--kai);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.head-right { display: flex; align-items: center; gap: 10px; }

.days-pill {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 5px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--coral);
  box-shadow: var(--shadow);
}

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 17px;
  color: var(--ink-soft);
  transition: all 0.15s;
}

.icon-btn:hover { color: var(--ink); border-color: var(--ink-faint); }

/* ————— 导航 ————— */

.tabs {
  display: flex;
  gap: 8px;
  padding: 8px clamp(16px, 5vw, 48px) 16px;
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.18s;
}

.tab:hover { border-color: var(--tab-color, var(--accent)); color: var(--tab-color, var(--accent)); }

.tab.active {
  background: var(--tab-color, var(--accent));
  border-color: var(--tab-color, var(--accent));
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--tab-color, var(--accent)) 40%, transparent);
}

/* ————— 主视图 ————— */

.view {
  max-width: 960px;
  margin: 0 auto;
  padding: 8px clamp(16px, 5vw, 48px) 72px;
  width: 100%;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 18px 0 20px;
}

.view-title h2 {
  font-family: var(--kai);
  font-size: 26px;
  letter-spacing: 0.1em;
}

.view-title p { color: var(--ink-soft); font-size: 13.5px; }

.view-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ————— 按钮 ————— */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.18s;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn.primary:hover { filter: brightness(1.08); transform: translateY(-1px); }

.btn.ghost {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

.btn.ai {
  background: linear-gradient(120deg, #8b5cf6, #d6549f);
  color: #fff;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}

.btn.ai:hover { filter: brightness(1.08); transform: translateY(-1px); }

.btn.small { padding: 6px 14px; font-size: 13px; }

.btn:disabled { opacity: 0.55; cursor: wait; transform: none; }

/* ————— 筛选 chips ————— */

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

.fchip {
  padding: 5px 15px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  font-size: 13px;
  color: var(--ink-soft);
  transition: all 0.15s;
}

.fchip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ————— 卡片 ————— */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
}

.card:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(80, 60, 40, 0.11); }

.card-photo {
  width: calc(100% + 40px);
  margin: -18px -20px 14px;
  height: 150px;
  object-fit: cover;
  border-radius: var(--radius) var(--radius) 0 0;
  cursor: zoom-in;
  display: block;
}

.card h3 {
  font-size: 16.5px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card .meta {
  font-size: 12.5px;
  color: var(--ink-faint);
  margin-bottom: 8px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.card .note {
  font-size: 14px;
  color: var(--ink-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.card-actions {
  position: absolute;
  top: 12px; right: 12px;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.15s;
}

.card:hover .card-actions { opacity: 1; }

.mini-btn {
  width: 28px; height: 28px;
  border-radius: 9px;
  border: none;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  font-size: 13px;
  color: var(--ink-soft);
}

.mini-btn:hover { color: var(--accent); }

/* 标签 */

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.tag.gray { background: #f1eee9; color: var(--ink-faint); }

/* 星星 */

.stars { color: #f5a623; font-size: 14px; letter-spacing: 2px; }
.stars .off { color: #e4ddd0; }

/* ————— 手记时间线 ————— */

.j-entry {
  display: flex;
  gap: 16px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 14px;
  position: relative;
}

.j-date {
  flex: 0 0 52px;
  text-align: center;
  padding-top: 2px;
}

.j-day { font-size: 26px; font-weight: 800; line-height: 1.15; color: var(--accent); }
.j-md { font-size: 12px; color: var(--ink-faint); }

.j-body { min-width: 0; flex: 1; }

.j-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }

.j-text { font-size: 14.5px; white-space: pre-wrap; word-break: break-word; }

.j-photo {
  margin-top: 12px;
  max-height: 300px;
  border-radius: 12px;
  cursor: zoom-in;
  display: block;
}

.j-entry .card-actions { top: 16px; right: 16px; }

.year-sep {
  font-family: var(--kai);
  font-size: 17px;
  color: var(--ink-faint);
  letter-spacing: 0.2em;
  margin: 26px 4px 14px;
}

/* ————— 训练 ————— */

.fit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 640px) { .fit-grid { grid-template-columns: 1fr; } }

.profile-card h3 { margin-bottom: 10px; }

.profile-rows { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13.5px; color: var(--ink-soft); }

.profile-rows b { color: var(--ink); font-weight: 600; }

.plan-card { margin-bottom: 20px; }

.plan-empty { color: var(--ink-faint); font-size: 14px; padding: 8px 0; }

.log-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  margin-bottom: 10px;
  position: relative;
}

.log-date { font-size: 12.5px; color: var(--ink-faint); flex: 0 0 76px; }

.log-main { flex: 1; font-size: 14px; min-width: 0; }

.log-main b { font-weight: 600; }

.log-row .card-actions { position: static; opacity: 0; margin-left: auto; }

.log-row:hover .card-actions { opacity: 1; }

/* ————— Markdown 渲染 ————— */

.md { font-size: 14.5px; line-height: 1.8; }

.md h1, .md h2, .md h3 {
  font-family: var(--kai);
  margin: 16px 0 8px;
  line-height: 1.4;
}

.md h1 { font-size: 20px; }
.md h2 { font-size: 17.5px; }
.md h3 { font-size: 15.5px; }

.md p { margin: 8px 0; }

.md ul, .md ol { margin: 8px 0; padding-left: 22px; }

.md table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 13.5px;
}

.md th, .md td {
  border: 1px solid var(--line);
  padding: 7px 10px;
  text-align: left;
}

.md th { background: var(--accent-soft); color: var(--ink); font-weight: 600; }

.md strong { font-weight: 700; }

.md hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }

/* ————— 空状态 ————— */

.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--ink-faint);
  font-size: 14.5px;
}

.empty .big { font-size: 40px; display: block; margin-bottom: 12px; }

/* ————— 私密遮挡 ————— */

.pin-gate {
  text-align: center;
  padding: 72px 24px;
}

.pin-gate .big { font-size: 44px; display: block; margin-bottom: 14px; }

.pin-gate p { color: var(--ink-soft); margin-bottom: 20px; }

.pin-input {
  font-size: 22px;
  letter-spacing: 12px;
  text-align: center;
  width: 200px;
  padding: 10px;
  border: 2px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: var(--card);
}

.pin-input:focus { border-color: var(--accent); }

.pin-error { color: var(--rose); font-size: 13px; min-height: 20px; margin-top: 10px; }

/* ————— 弹层 ————— */

.dlg {
  border: none;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow-lg);
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  padding: 0;
}

.dlg::backdrop { background: rgba(43, 39, 51, 0.5); backdrop-filter: blur(4px); }

.dlg-inner { padding: 28px 28px 24px; overflow-y: auto; max-height: calc(100vh - 64px); }

.dlg-title {
  font-family: var(--kai);
  font-size: 20px;
  letter-spacing: 0.12em;
  margin-bottom: 20px;
}

.dlg-ai { width: min(640px, calc(100vw - 32px)); }

.ai-loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-soft);
  font-size: 14.5px;
  padding: 24px 4px;
}

.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--line);
  border-top-color: var(--plum);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.ai-content {
  background: #fbf9f5;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  max-height: 50vh;
  overflow-y: auto;
}

/* ————— 表单 ————— */

.field { display: block; margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 7px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14.5px;
  padding: 10px 14px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fdfcfa;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s;
}

.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); }

.field textarea { resize: vertical; line-height: 1.7; }

.field-hint { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }

.seg { display: flex; flex-wrap: wrap; gap: 8px; }

.seg-item {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font-size: 13.5px;
  transition: all 0.15s;
}

.seg-item:hover { border-color: var(--ink-faint); }

.seg-item.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.stars-input { display: flex; gap: 4px; font-size: 26px; }

.stars-input span { cursor: pointer; color: #e4ddd0; transition: color 0.1s, transform 0.1s; }

.stars-input span.on { color: #f5a623; }

.stars-input span:hover { transform: scale(1.15); }

.photo-row { display: flex; gap: 10px; align-items: center; }

.photo-preview {
  margin-top: 10px;
  max-height: 180px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
}

.textarea-tools { display: flex; justify-content: flex-end; margin-top: 8px; }

.dlg-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ————— 提示条 ————— */

.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  padding: 11px 24px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-width: calc(100vw - 48px);
}

.toast.error { background: var(--rose); }

/* ————— 大图 ————— */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(30, 26, 36, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: 28px;
}

.lightbox img { max-width: 100%; max-height: 100%; border-radius: 14px; }

/* ————— 页脚 ————— */

.app-foot {
  text-align: center;
  padding: 32px 24px 48px;
  color: var(--ink-faint);
  font-size: 12.5px;
  letter-spacing: 0.12em;
}

/* ————— 移动端 ————— */

@media (max-width: 640px) {
  .view-head { align-items: flex-start; flex-direction: column; }
  .card-actions, .log-row .card-actions { opacity: 1; }
  .j-entry { padding: 16px; gap: 12px; }
  .cards { grid-template-columns: 1fr; }
}
