:root {
  --bg: #f7f4ec;
  --paper: rgba(255, 255, 255, 0.9);
  --paper-solid: #ffffff;
  --ink: #1f2328;
  --muted: #6e695f;
  --line: #e8dfd2;
  --accent: #9d6b42;
  --accent-strong: #7d4c25;
  --shadow: 0 18px 45px rgba(78, 59, 40, 0.12);
  --cycle-a: rgba(255, 236, 203, 0.50);
  --cycle-b: rgba(218, 237, 231, 0.56);
  --today: #c86f3c;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(157, 107, 66, 0.14), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(113, 155, 142, 0.15), transparent 28rem),
    var(--bg);
}

button, input { font: inherit; }
button { cursor: pointer; }

.app-shell {
  width: min(1360px, calc(100% - 28px));
  margin: 0 auto;
  padding: 18px 0 26px;
}

.hero { text-align: center; margin-bottom: 12px; }
.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.eyebrow.small { font-size: 0.72rem; margin-bottom: 3px; }
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 4px;
  font-size: clamp(2.35rem, 5.3vw, 4rem);
  line-height: 0.98;
  letter-spacing: -0.07em;
}
.subtitle, #cycleHint, .editor-actions p { color: var(--muted); }
.subtitle { margin-bottom: 0; font-size: 0.95rem; }

.toolbar, .calendar-card, .editor-card {
  background: var(--paper);
  border: 1px solid rgba(255,255,255,0.72);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}
.toolbar .soft-button:first-child { justify-self: start; }
.toolbar .soft-button:last-child { justify-self: end; }
.month-title-wrap { text-align: center; }
.month-title-wrap h2 { margin-bottom: 1px; font-size: 1.55rem; line-height: 1.08; }
#cycleHint { margin-bottom: 0; font-size: 0.86rem; }

.soft-button, .primary-button, .mark-button {
  border: 0;
  border-radius: 999px;
  padding: 8px 13px;
  transition: transform 0.15s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}
.soft-button { background: #eee8de; color: var(--ink); }
.primary-button { background: var(--accent); color: white; font-weight: 800; white-space: nowrap; }
.soft-button:hover, .primary-button:hover, .mark-button:hover { transform: translateY(-1px); }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: center;
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }
.dot-report { background: #7d4c25; }
.dot-cycle-a { background: #ffe1ad; }
.dot-cycle-b { background: #cce7dd; }
.dot-today { background: var(--today); }

.workspace {
  display: grid;
  grid-template-columns: minmax(720px, 1fr) minmax(300px, 360px);
  gap: 16px;
  align-items: start;
}

.calendar-card { padding: 14px; }
.weekdays, .calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}
.weekdays { margin-bottom: 7px; color: var(--muted); font-weight: 800; text-align: center; font-size: 0.9rem; }
.weekdays span { padding: 5px; }

.day-cell {
  position: relative;
  min-height: clamp(78px, calc((100vh - 302px) / 6), 104px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 9px 10px;
  text-align: left;
  color: var(--ink);
  background: var(--paper-solid);
  overflow: hidden;
}
.day-cell.cycle-a { background: linear-gradient(180deg, var(--cycle-a), rgba(255,255,255,0.96)); }
.day-cell.cycle-b { background: linear-gradient(180deg, var(--cycle-b), rgba(255,255,255,0.96)); }
.day-cell.outside { opacity: 0.38; }
.day-cell.selected { outline: 3px solid rgba(157, 107, 66, 0.28); border-color: rgba(157, 107, 66, 0.55); }
.day-cell.today::after {
  content: "今天";
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--today);
  color: white;
  font-size: 0.66rem;
  font-weight: 800;
}
.day-topline { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.day-number { font-size: 1.05rem; font-weight: 900; line-height: 1; }
.report-badge {
  display: none;
  padding: 2px 6px;
  border-radius: 999px;
  background: #efe1d2;
  color: var(--accent-strong);
  font-size: 0.66rem;
  font-weight: 900;
}
.day-cell.report-day .report-badge { display: inline-flex; }
.day-preview {
  min-height: 42px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.42;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}
.day-preview mark[data-color="yellow"] { background: #fff0a8; }
.day-preview mark[data-color="green"] { background: #d7f2d8; }
.day-preview mark[data-color="blue"] { background: #d9eaff; }
.day-preview mark[data-color="pink"] { background: #ffe0ea; }
.day-preview mark[data-color="orange"] { background: #ffd9b3; }
.day-preview mark[data-color="purple"] { background: #e7ddff; }
.day-preview mark[data-color="gray"] { background: #e6e3dd; }
.day-preview mark {
  border-radius: 4px;
  padding: 0 2px;
  color: inherit;
}

.editor-card {
  position: sticky;
  top: 12px;
  padding: 16px;
}
.editor-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; margin-bottom: 12px; }
.editor-head h2 { margin-bottom: 0; font-size: 1.12rem; line-height: 1.25; }
.save-status { color: var(--muted); font-size: 0.82rem; text-align: right; }
.highlight-tools { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.mark-button { background: #efe8de; color: var(--ink); padding: 7px 10px; font-size: 0.86rem; }
.mark-yellow { background: #fff0a8; }
.mark-green { background: #d7f2d8; }
.mark-blue { background: #d9eaff; }
.mark-pink { background: #ffe0ea; }
.mark-orange { background: #ffd9b3; }
.mark-purple { background: #e7ddff; }
.mark-gray { background: #e6e3dd; }

.editor {
  min-height: clamp(220px, calc(100vh - 402px), 360px);
  max-height: calc(100vh - 320px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 13px;
  background: white;
  line-height: 1.7;
  outline: none;
}
.editor:focus { border-color: rgba(157,107,66,0.7); box-shadow: 0 0 0 4px rgba(157,107,66,0.13); }
.editor:empty::before { content: attr(data-placeholder); color: #999187; }
.editor mark[data-color="yellow"] { background: #fff0a8; }
.editor mark[data-color="green"] { background: #d7f2d8; }
.editor mark[data-color="blue"] { background: #d9eaff; }
.editor mark[data-color="pink"] { background: #ffe0ea; }
.editor mark[data-color="orange"] { background: #ffd9b3; }
.editor mark[data-color="purple"] { background: #e7ddff; }
.editor mark[data-color="gray"] { background: #e6e3dd; }
.editor mark { border-radius: 4px; padding: 0 2px; color: inherit; }
.editor-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.editor-actions p { margin-bottom: 0; font-size: 0.82rem; }

@media (max-width: 1080px) {
  .app-shell { width: min(100% - 20px, 980px); padding-top: 18px; }
  .workspace { grid-template-columns: 1fr; }
  .editor-card { position: static; }
  .day-cell { min-height: 96px; }
  .editor { min-height: 180px; max-height: none; }
}

@media (max-width: 820px) {
  .toolbar { grid-template-columns: 1fr; }
  .toolbar .soft-button:first-child, .toolbar .soft-button:last-child { justify-self: stretch; }
  .weekdays, .calendar-grid { gap: 6px; }
  .day-cell { min-height: 92px; padding: 8px; border-radius: 14px; }
  .day-number { font-size: 1rem; }
  .day-preview { font-size: 0.76rem; -webkit-line-clamp: 3; }
  .editor-head, .editor-actions { flex-direction: column; align-items: stretch; }
  h1 { font-size: 2.7rem; }
}