:root {
  --bg: #fff6f5;
  --card: #ffffff;
  --accent: #e2606b;
  --accent-2: #f7a8b0;
  --accent-soft: #fde8ea;
  --text: #4a3b3b;
  --muted: #a58f8f;
  --line: #f3e2e1;
  --danger: #d9534f;
  --shadow: 0 6px 24px rgba(180, 90, 100, 0.12);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, #ffe9ec 0%, var(--bg) 40%, #fff0f3 100%);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
}

.hidden { display: none !important; }

/* ===== 通用控件 ===== */
input, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  outline: none;
  font-family: inherit;
}
input:focus, textarea:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(226, 96, 107, 0.08); }
textarea { resize: vertical; min-height: 110px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 20px; border: none; border-radius: 12px;
  font-size: 15px; cursor: pointer; width: 100%;
  font-family: inherit; transition: opacity .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #ef8b96); color: #fff; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn.danger { background: #fdecea; color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }

/* ===== 登录 / 建空间 界面 ===== */
.screen { min-height: 100vh; padding: 24px 16px; }
.screen:not(.hidden) { display: flex; align-items: center; justify-content: center; }

.auth-box {
  width: 100%; max-width: 380px;
  background: var(--card); border-radius: 20px;
  padding: 32px 24px; box-shadow: var(--shadow);
  text-align: center;
}
.logo { font-size: 46px; }
.auth-box h1 { font-size: 24px; margin: 8px 0 4px; }
.sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }

.tabs { display: flex; gap: 8px; background: var(--accent-soft); padding: 4px; border-radius: 12px; margin-bottom: 16px; }
.tab {
  flex: 1; padding: 8px; border: none; background: transparent;
  border-radius: 9px; font-size: 14px; color: var(--muted); cursor: pointer; font-family: inherit;
}
.tab.active { background: #fff; color: var(--accent); font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,.05); }

.auth-box input { margin-bottom: 10px; }
.msg { margin-top: 12px; font-size: 13px; color: var(--danger); min-height: 18px; }

/* ===== 顶栏 ===== */
#screen-journal { display: flex; flex-direction: column; padding: 0; }
#screen-journal:not(.hidden) { display: flex; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: linear-gradient(135deg, var(--accent), #ef8b96);
  color: #fff; position: sticky; top: 0; z-index: 20;
}
.space-name { font-size: 18px; font-weight: 700; }
.days { font-size: 12px; opacity: .9; margin-top: 2px; }
.menu-btn { background: rgba(255,255,255,.2); border: none; color: #fff; font-size: 20px; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; }

/* ===== 日期栏 ===== */
.datebar {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 62px; z-index: 15;
}
.nav { width: 38px; height: 38px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font-size: 20px; color: var(--text); cursor: pointer; }
.date-center { flex: 1; display: flex; flex-direction: column; align-items: center; }
.date-label { font-weight: 600; font-size: 15px; }
.date-input { border: none; padding: 0; text-align: center; font-size: 12px; color: var(--muted); width: 120px; background: transparent; }
.today-btn { border: none; background: var(--accent-soft); color: var(--accent); padding: 8px 14px; border-radius: 10px; font-size: 13px; cursor: pointer; }

/* ===== 日历 ===== */
.calendar-wrap { background: #fff; border-bottom: 1px solid var(--line); padding: 8px 12px 12px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.cal-title { font-weight: 600; font-size: 14px; }
.cal-nav { border: none; background: none; font-size: 18px; color: var(--accent); cursor: pointer; padding: 0 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wd { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal-day {
  position: relative; text-align: center; padding: 6px 0; font-size: 13px;
  border-radius: 8px; cursor: pointer; color: var(--text);
}
.cal-day.empty { cursor: default; }
.cal-day:hover { background: var(--accent-soft); }
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-day.sel { background: var(--accent); color: #fff; font-weight: 700; }
.cal-day .dot { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--accent-2); }
.cal-day.sel .dot { background: #fff; }

/* ===== 记录列表 ===== */
.entries { flex: 1; padding: 16px; max-width: 680px; width: 100%; margin: 0 auto; padding-bottom: 110px; }

.entry {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px; position: relative;
}
.entry-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.author { font-weight: 700; color: var(--accent); font-size: 14px; }
.time { color: var(--muted); font-size: 12px; }
.edit-hint { margin-left: auto; font-size: 12px; color: var(--muted); cursor: pointer; }
.entry-content { white-space: pre-wrap; word-break: break-word; margin-bottom: 10px; }
.entry-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.entry-photos a { display: block; aspect-ratio: 1; overflow: hidden; border-radius: 10px; }
.entry-photos img { width: 100%; height: 100%; object-fit: cover; }

.check-item { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; }
.check-item input { width: auto; margin-top: 4px; }
.check-item .txt { flex: 1; }
.check-item .txt.done { text-decoration: line-through; color: var(--muted); }

.empty-state { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; }

/* ===== 浮动按钮 ===== */
.fab {
  position: fixed; right: 20px; bottom: 28px; width: 56px; height: 56px;
  border-radius: 50%; border: none; background: linear-gradient(135deg, var(--accent), #ef8b96);
  color: #fff; font-size: 30px; cursor: pointer; box-shadow: 0 8px 20px rgba(226, 96, 107, .4);
  z-index: 30;
}

/* ===== 菜单 ===== */
.menu {
  position: fixed; top: 58px; right: 12px; background: #fff; border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; z-index: 40; min-width: 160px;
  display: none;
}
.menu.open { display: block; }
.menu-item { padding: 10px 14px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.menu-item:hover { background: var(--accent-soft); }
.menu-item.danger { color: var(--danger); }

/* ===== 编辑面板 ===== */
.compose {
  position: fixed; left: 0; right: 0; bottom: 0; top: 0; z-index: 50;
  background: rgba(0,0,0,.35); display: none; align-items: flex-end; justify-content: center;
}
.compose.open { display: flex; }
.compose-inner {
  width: 100%; max-width: 560px; background: #fff; border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto;
}
.compose-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.compose-title { font-size: 17px; font-weight: 700; }
.close-btn { border: none; background: var(--accent-soft); color: var(--accent); width: 34px; height: 34px; border-radius: 10px; font-size: 16px; cursor: pointer; }
.compose-date { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.compose-section { margin-top: 16px; }
.section-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.mini-x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border: none;
  background: rgba(0,0,0,.55); color: #fff; border-radius: 50%; font-size: 12px; cursor: pointer;
}
.check-row { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.check-row input { flex: 1; }
.check-add { display: flex; gap: 6px; margin-top: 4px; }
.check-add .btn { width: auto; padding: 10px 16px; }
.compose-foot { display: flex; gap: 10px; margin-top: 20px; }
.compose-foot .btn.danger { width: auto; }

/* ===== 弹窗 ===== */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 60;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal.open { display: flex; }
.modal-box { background: #fff; border-radius: 18px; padding: 24px; width: 100%; max-width: 340px; }
.modal-title { font-size: 17px; font-weight: 700; margin-bottom: 14px; }
#modal-body { margin-bottom: 16px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; }
.modal-foot .btn { width: auto; }
.invite-code {
  text-align: center; font-size: 30px; font-weight: 800; letter-spacing: 4px;
  color: var(--accent); background: var(--accent-soft); border-radius: 12px; padding: 14px; margin: 10px 0;
}

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%) translateY(20px);
  background: rgba(60, 40, 40, .92); color: #fff; padding: 10px 18px; border-radius: 20px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 桌面端 ===== */
@media (min-width: 720px) {
  .compose { align-items: center; }
  .compose-inner { border-radius: 20px; }
  .entries { padding-top: 24px; }
  .fab { right: calc(50% - 340px + 24px); }
}
