/* ============================================================
   备忘录 · 样式
   目标：简洁、字体醒目(20–24px)、动画轻微、不卡顿
   ============================================================ */

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #1c2434;
  --text-soft: #6b7689;
  --line: #e6eaf2;
  --accent: #4f6ef7;
  --accent-soft: #eef1fe;
  --done: #22a06b;
  --danger: #e5534b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 6px 18px rgba(20, 30, 60, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

/* ---------- 布局 ---------- */
.app {
  max-width: 720px;
  min-height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom));
}

.app-header {
  padding: 26px 4px 14px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-title {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: .5px;
}

/* 右上角同步按钮 */
.sync-open {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color .18s ease, background-color .18s ease, border-color .18s ease, transform .12s ease;
  -webkit-tap-highlight-color: transparent;
}

.sync-open:hover { color: var(--accent); background: var(--accent-soft); border-color: #d6ddef; }
.sync-open:active { transform: scale(.92); }

/* 同步状态一行 */
.sync-status {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-soft);
  min-height: 18px;
}

.sync-status.on { color: var(--done); }

/* ---------- 同步设置面板 ---------- */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 45, .38);
  opacity: 0;
  transition: opacity .18s ease;
  z-index: 80;
}

.sheet-mask.open { opacity: 1; }

.sheet {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%) scale(.98);
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: 18px;
  box-shadow: 0 12px 44px rgba(20, 30, 60, .22);
  opacity: 0;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 81;
}

.sheet.open { opacity: 1; transform: translate(-50%, -50%) scale(1); }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 18px 6px;
}

.sheet-title { margin: 0; font-size: 19px; font-weight: 700; }

.sheet-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text-soft);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease;
}

.sheet-close:hover { background: #f1f4fa; color: var(--text); }

.sheet-body { padding: 4px 18px 20px; }

.sheet-note {
  margin: 6px 0 16px;
  padding: 11px 13px;
  background: #f7f9fe;
  border-radius: 11px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-soft);
}

.sheet-note strong { color: var(--text); }

.sheet-label {
  margin: 14px 0 7px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.sheet-hint {
  margin: 10px 0 0;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.5;
}

.code-row { display: flex; gap: 8px; }

.code-input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 15px;
  letter-spacing: .4px;
  color: var(--text);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.code-input:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.code-input::placeholder { font-size: 13px; letter-spacing: 0; }

.code-warn {
  margin: 9px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #c2410c;
  background: #fff7ed;
  border-radius: 9px;
  padding: 9px 11px;
}

.mini-btn {
  flex: 0 0 auto;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  border: none;
  border-radius: 10px;
  padding: 0 14px;
  cursor: pointer;
  transition: background-color .16s ease, transform .12s ease;
  -webkit-tap-highlight-color: transparent;
}

.mini-btn:hover { background: #e3e8fd; }
.mini-btn:active { transform: scale(.95); }
.mini-btn.danger { color: var(--danger); background: #fdeceb; }
.mini-btn.danger:hover { background: #fbdcd9; }

.primary-btn {
  width: 100%;
  margin-top: 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  padding: 13px;
  cursor: pointer;
  transition: background-color .18s ease, transform .12s ease, opacity .18s ease;
}

.primary-btn:hover { background: #4462f0; }
.primary-btn:active { transform: scale(.985); }
.primary-btn:disabled { opacity: .6; cursor: default; }

.sync-actions { display: flex; gap: 8px; margin-top: 12px; }
.sync-actions .mini-btn { height: 38px; flex: 1 1 0; }

.sheet-error {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--danger);
  background: #fdeceb;
  border-radius: 9px;
  padding: 9px 11px;
  line-height: 1.5;
}

/* ---------- 页面主体 ---------- */

.app-sub {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--text-soft);
  min-height: 18px;
  transition: color .25s ease;
}

.app-sub.saving { color: var(--accent); }
.app-sub.saved  { color: var(--done); }

.app-main {
  flex: 1;
  padding-top: 4px;
}

/* ---------- 列表 ---------- */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 新增行动画：轻微上浮淡入 */
@keyframes rowIn {
  from { opacity: 0; transform: translateY(-6px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

.row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 14px 14px 16px;
  animation: rowIn .18s ease-out both;
  transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease;
}

.row:hover {
  border-color: #d6ddef;
}

.row.editing {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow);
}

/* 删除时轻微收缩淡出 */
@keyframes rowOut {
  to { opacity: 0; transform: scale(.97); }
}
.row.removing {
  animation: rowOut .16s ease-in both;
  pointer-events: none;
}

/* ---------- 圆形勾选框 ---------- */
.check {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  margin-top: 2px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #c3cbdd;
  background: transparent;
  cursor: pointer;
  position: relative;
  display: grid;
  place-items: center;
  transition: border-color .18s ease, background-color .18s ease, transform .12s ease;
  -webkit-tap-highlight-color: transparent;
}

.check:hover { border-color: var(--accent); }

.check:active { transform: scale(.9); }

.check .tick {
  width: 15px;
  height: 15px;
  stroke: #fff;
  stroke-width: 3.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
  transition: stroke-dashoffset .22s ease;
}

.row.done .check {
  background: var(--done);
  border-color: var(--done);
}

.row.done .check .tick { stroke-dashoffset: 0; }

/* 勾选瞬间的轻微弹跳 */
@keyframes pop {
  0%   { transform: scale(.9); }
  55%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.row.just-done .check { animation: pop .26s ease-out; }

/* ---------- 内容 ---------- */
.content {
  flex: 1 1 auto;
  min-width: 0;
  cursor: text;
}

.entry-time {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--accent);
  word-break: break-word;
  transition: color .2s ease;
}

.entry-text {
  font-size: 22px;          /* 醒目：22px */
  line-height: 1.45;
  font-weight: 500;
  margin-top: 2px;
  word-break: break-word;
  white-space: pre-wrap;
  transition: color .2s ease, opacity .2s ease;
}

.entry-text.is-empty,
.entry-time.is-empty {
  color: #b6bdcc;
  font-weight: 400;
}

.row.done .entry-time,
.row.done .entry-text {
  color: var(--text-soft);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  opacity: .72;
}

/* ---------- 编辑态输入 ---------- */
.editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
}

.editor input,
.editor textarea {
  width: 100%;
  font-family: inherit;
  color: var(--text);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.editor input { font-size: 20px; font-weight: 700; color: var(--accent); }

.editor textarea {
  font-size: 22px;
  font-weight: 500;
  line-height: 1.45;
  resize: none;
  min-height: 52px;
  overflow: hidden;
}

.editor input:focus,
.editor textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.editor input::placeholder,
.editor textarea::placeholder { color: #b6bdcc; font-weight: 400; }

/* ---------- 日期填写（可手填，也可点选） ---------- */
.time-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
}

.pick {
  font-family: inherit;
  color: var(--accent);
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.pick-text {
  flex: 1 1 200px;
  min-width: 0;
  font-size: 19px;
  font-weight: 600;
  padding: 9px 11px;
  cursor: text;
}

.pick-text::placeholder {
  color: #b6bdcc;
  font-weight: 400;
  font-size: 16px;
}

.pick-text:hover { border-color: #cfd8ee; }

.pick-text:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* 原生日期选择器隐藏起来，由按钮唤起 */
.pick-native {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
  left: 0;
  bottom: 0;
}

.pick-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  color: var(--accent);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color .16s ease, border-color .16s ease, transform .12s ease;
  -webkit-tap-highlight-color: transparent;
}

.pick-btn:hover {
  background: var(--accent-soft);
  border-color: #cfd8ee;
}

.pick-btn:active { transform: scale(.9); }

/* 输入后的日期预览 */
.pick-hint {
  flex: 1 1 100%;
  font-size: 13px;
  color: var(--text-soft);
  padding-left: 2px;
  min-height: 0;
  line-height: 1.4;
}

.pick-hint:empty { display: none; }

.pick-hint.ok { color: var(--accent); font-weight: 600; }

@media (max-width: 420px) {
  .pick-text { font-size: 18px; }
}

/* ---------- 行内按钮 ---------- */
.row-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: #9aa4b8;
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background-color .16s ease, color .16s ease, transform .12s ease;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover { background: #f1f4fa; color: var(--text); }
.icon-btn:active { transform: scale(.9); }
.icon-btn.del:hover { background: #fdeceb; color: var(--danger); }

/* ---------- 底部按钮 ---------- */
.app-footer {
  position: sticky;
  bottom: 0;
  padding: 14px 0 calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, rgba(244, 246, 251, 0));
}

.add-btn {
  width: 100%;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 19px;
  font-weight: 600;
  padding: 15px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  box-shadow: 0 4px 14px rgba(79, 110, 247, .3);
  transition: transform .14s ease, box-shadow .2s ease, background-color .2s ease;
  -webkit-tap-highlight-color: transparent;
}

.add-btn:hover { background: #4462f0; box-shadow: 0 6px 18px rgba(79, 110, 247, .38); }
.add-btn:active { transform: scale(.985); }

.add-btn-plus {
  font-size: 21px;
  line-height: 1;
  transition: transform .2s ease;
}

.add-btn:hover .add-btn-plus { transform: rotate(90deg); }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-soft);
  animation: rowIn .2s ease-out both;
}

.empty-icon { font-size: 40px; }
.empty-title { margin: 10px 0 4px; font-size: 17px; font-weight: 600; color: var(--text); }
.empty-hint { margin: 0; font-size: 14px; }

/* ---------- 提示条 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translate(-50%, 12px);
  background: rgba(28, 36, 52, .94);
  color: #fff;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 新版本提示条 ---------- */
.update-bar {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translate(-50%, 16px);
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1c2434;
  color: #fff;
  font-size: 14px;
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 26px rgba(20, 30, 60, .28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 60;
  max-width: calc(100vw - 32px);
}

.update-bar.show {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.update-msg { white-space: nowrap; }

.update-btn {
  flex: 0 0 auto;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background-color .16s ease, opacity .16s ease;
}

.update-btn:hover { background: #4462f0; }
.update-btn:disabled { opacity: .6; cursor: default; }

/* ---------- 无障碍 / 减少动画 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media (max-width: 420px) {
  .entry-time { font-size: 19px; }
  .entry-text { font-size: 21px; }
  .app-title  { font-size: 23px; }
}
