:root {
  --ink: #1a1c22; --ink-soft: #4a4f5c; --muted: #888f9c;
  --paper: #fbfaf7; --card: #ffffff; --line: #e7e3da;
  --accent: #1f6f6b; --accent-soft: #e6f1f0; --accent-ink: #134f4b;
  --gold: #9a7b2e; --danger: #b3402e;
  --shadow: 0 1px 2px rgba(20,30,40,.04), 0 8px 28px rgba(20,30,40,.06);
  --serif: "Noto Serif SC", "Newsreader", Georgia, serif;
  --sans: "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); color: var(--ink); background: var(--paper); }
body.reader-open { overflow: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 1px solid var(--line);
  background: rgba(251,250,247,.9); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { color: var(--accent); display: flex; }
.brand-text .mark { font-family: var(--serif); font-weight: 900; font-size: 20px; letter-spacing: .5px; }
.brand-text .tag { font-size: 12px; color: var(--muted); margin-top: 1px; }
.head-right { display: flex; align-items: center; gap: 10px; }
.auto-status { font-size: 12px; color: var(--muted); white-space: nowrap; }
.auto-status.running { color: var(--accent-ink); font-weight: 600; }
@media (max-width: 720px) { .auto-status { display: none; } }
.btn {
  font-family: var(--sans); font-size: 13px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); border-radius: 9px; padding: 8px 14px; cursor: pointer;
  font-weight: 600; transition: .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .6; cursor: default; }
.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-ink); color: #fff; border-color: var(--accent-ink); }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- calendar ---------- */
.cal-wrap {
  max-width: 1080px; margin: 0 auto; padding: 34px clamp(16px, 4vw, 40px) 60px;
  display: grid; grid-template-columns: minmax(0,1fr) 260px; gap: 26px; align-items: start;
}
.cal-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 22px clamp(16px, 3vw, 30px) 26px; }
.cal-head { display: flex; align-items: center; justify-content: center; gap: 22px; margin-bottom: 18px; }
.cal-title { font-family: var(--serif); font-weight: 900; font-size: 24px; margin: 0; min-width: 180px; text-align: center; }
.nav-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-soft);
  width: 38px; height: 38px; border-radius: 11px; font-size: 22px; line-height: 1; cursor: pointer; transition: .15s;
}
.nav-btn:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-soft); }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-dow { text-align: center; font-size: 12px; font-weight: 700; color: var(--muted); padding-bottom: 6px; }
.cal-cell {
  position: relative; aspect-ratio: 1 / 1; border: 1px solid transparent; border-radius: 14px;
  padding: 8px 9px; display: flex; flex-direction: column; justify-content: space-between;
  background: #faf8f3; transition: .14s;
}
.cal-cell.empty { background: transparent; }
.cal-cell.none { color: var(--muted); }
.cal-cell.future { opacity: .5; }
.cal-cell .cell-num { font-family: var(--serif); font-weight: 700; font-size: 17px; }
.cal-cell.has {
  background: var(--accent-soft); border-color: rgba(31,111,107,.18);
  color: var(--accent-ink); cursor: pointer;
}
.cal-cell.has:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(31,111,107,.22); border-color: var(--accent); }
.cal-cell.today { box-shadow: inset 0 0 0 2px var(--gold); }
.cal-cell.today .cell-num { color: var(--gold); }
.cell-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-comb { font-size: 10px; font-weight: 800; letter-spacing: .5px; color: #fff; background: var(--accent); border-radius: 20px; padding: 2px 7px; }
.tag-cnt { font-size: 10px; font-weight: 700; color: var(--accent-ink); background: #fff; border: 1px solid rgba(31,111,107,.25); border-radius: 20px; padding: 2px 7px; }

.cal-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }
.cal-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend .lg-right { margin-left: auto; font-weight: 600; color: var(--ink-soft); }
.dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }
.dot-has { background: var(--accent-soft); border: 1px solid rgba(31,111,107,.3); }
.dot-comb { background: var(--accent); }
.ring { width: 12px; height: 12px; border-radius: 4px; box-shadow: inset 0 0 0 2px var(--gold); display: inline-block; }

.recent-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 20px 18px; position: sticky; top: 90px; }
.side-label { font-size: 11px; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin: 0 0 14px; }
.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
  display: flex; flex-direction: column; gap: 2px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); background: #fff; border-radius: 11px; padding: 10px 12px; transition: .12s; font-family: var(--sans);
}
.recent-item:hover { border-color: var(--accent); background: var(--accent-soft); }
.ri-date { font-family: var(--serif); font-weight: 700; font-size: 15px; color: var(--ink); }
.ri-meta { font-size: 12px; color: var(--muted); }

/* ---------- day reader overlay ---------- */
.reader { position: fixed; inset: 0; z-index: 60; background: var(--paper); display: flex; flex-direction: column; }
.reader[hidden] { display: none; }
[hidden] { display: none !important; }
.reader-bar {
  display: flex; align-items: center; gap: 14px; padding: 12px 20px;
  border-bottom: 1px solid var(--line); background: rgba(251,250,247,.95); backdrop-filter: blur(8px);
}
.rd-back { border: 1px solid var(--line); background: #fff; color: var(--ink-soft); border-radius: 9px; padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: var(--sans); }
.rd-back:hover { border-color: var(--accent); color: var(--accent-ink); }
.rd-title { font-family: var(--serif); font-weight: 700; font-size: 16px; }
.rd-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.rd-open { font-size: 13px; color: var(--accent-ink); text-decoration: none; font-weight: 600; border: 1px solid var(--line); padding: 8px 12px; border-radius: 9px; }
.rd-open:hover { border-color: var(--accent); background: var(--accent-soft); }
.rd-close { border: 1px solid var(--line); background: #fff; color: var(--ink-soft); width: 38px; height: 38px; border-radius: 9px; font-size: 16px; cursor: pointer; }
.rd-close:hover { border-color: var(--danger); color: var(--danger); }
.reader-body { flex: 1; min-height: 0; }
.rd-frame { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.rd-fallback { max-width: 640px; margin: 60px auto; text-align: center; color: var(--ink-soft); }
.rd-topics { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.rd-topic { text-decoration: none; color: var(--accent-ink); background: var(--accent-soft); border: 1px solid rgba(31,111,107,.25); border-radius: 11px; padding: 10px 16px; font-weight: 600; }
.rd-topic:hover { border-color: var(--accent); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 13px; opacity: 0; pointer-events: none; transition: .25s; z-index: 80; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .cal-wrap { grid-template-columns: 1fr; }
  .recent-card { position: static; }
}
@media (max-width: 560px) {
  .cal-cell { border-radius: 11px; padding: 6px; }
  .cal-cell .cell-num { font-size: 14px; }
  .tag-comb, .tag-cnt { font-size: 9px; padding: 1px 5px; }
}
