/* ============================================================
   日课 · 网络日程表
   视觉：宣纸白底 · 墨色文字 · 朱砂点睛 · 宋体数字
   ============================================================ */

:root {
  --paper: #FAF9F5;
  --paper-2: #F2F0E9;
  --card: #FFFFFF;
  --ink: #221F1A;
  --ink-2: #6B665C;
  --ink-3: #A39D90;
  --line: #E8E4DA;
  --line-strong: #D5D0C2;
  --seal: #B93A28;
  --seal-deep: #982E1E;
  --seal-soft: #F8ECE8;
  --jade: #4E7A5F;
  --indigo: #3D5A80;
  --gold: #B8862D;
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", "Source Han Sans SC", system-ui, -apple-system, sans-serif;
  --font-serif: "Songti SC", "STSong", "SimSun", "Noto Serif CJK SC",
    "Source Han Serif SC", serif;
  --radius: 10px;
  --shadow: 0 18px 44px -20px rgba(34, 31, 26, 0.30);
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
}

.hidden { display: none !important; }

::selection { background: rgba(185, 58, 40, 0.15); }

:focus-visible {
  outline: 2px solid var(--seal);
  outline-offset: 2px;
}

/* ---------------------------------------------------------- 通用控件 */
.btn-primary {
  background: var(--seal);
  color: #FFF8F5;
  border-radius: 8px;
  padding: 9px 18px;
  font-weight: 500;
  letter-spacing: 0.5px;
  transition: background 0.15s ease;
}
.btn-primary:hover { background: var(--seal-deep); }
.btn-primary:disabled { opacity: 0.55; cursor: default; }

.btn-ghost {
  color: var(--ink-2);
  border-radius: 8px;
  padding: 8px 14px;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-ghost:hover { background: var(--paper-2); color: var(--ink); }

.btn-danger {
  color: var(--seal);
  border-radius: 8px;
  padding: 8px 14px;
  transition: background 0.15s ease;
}
.btn-danger:hover { background: var(--seal-soft); }

.btn-outline {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--ink-2);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.btn-outline:hover {
  border-color: var(--seal);
  color: var(--seal);
  background: var(--seal-soft);
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 20px;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }

.text-btn {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--ink-2);
  transition: background 0.15s ease, color 0.15s ease;
}
.text-btn:hover { background: var(--paper-2); color: var(--ink); }
.text-btn.accent { color: var(--seal); }

.input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus {
  outline: none;
  border-color: var(--seal);
  box-shadow: 0 0 0 3px rgba(185, 58, 40, 0.10);
}
.input::placeholder { color: var(--ink-3); }

select.input { appearance: auto; }

textarea.input { resize: vertical; min-height: 64px; }

/* ---------------------------------------------------------- 登录页 */
.auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.auth::after {
  content: "日";
  font-family: var(--font-serif);
  position: fixed;
  right: -6vw;
  bottom: -16vh;
  font-size: min(46vw, 560px);
  line-height: 1;
  color: rgba(185, 58, 40, 0.05);
  pointer-events: none;
  user-select: none;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 372px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 34px 32px 28px;
  box-shadow: 0 24px 60px -32px rgba(34, 31, 26, 0.25);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.seal {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--seal);
  color: #FFF6F2;
  font-family: var(--font-serif);
  font-size: 21px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  flex: none;
}

.wordmark {
  font-family: var(--font-serif);
  font-size: 21px;
  letter-spacing: 6px;
  padding-left: 2px;
}

.auth-title {
  margin: 26px 0 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-2);
  letter-spacing: 1px;
}

.tabs {
  display: flex;
  gap: 20px;
  margin-top: 18px;
  border-bottom: 1px solid var(--line);
}

.tab {
  padding: 8px 2px 10px;
  color: var(--ink-3);
  font-size: 15px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--seal);
  font-weight: 500;
}

.auth form { margin-top: 18px; }

.field { margin-bottom: 14px; }

.field label {
  display: block;
  font-size: 12.5px;
  color: var(--ink-2);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.auth-error {
  min-height: 20px;
  font-size: 12.5px;
  color: var(--seal);
  margin: 2px 0 10px;
}

.auth .btn-primary { width: 100%; padding: 10px; font-size: 15px; }

.auth-switch {
  margin-top: 16px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
}
.auth-switch button { color: var(--seal); padding: 0 2px; }

.demo-note {
  margin-top: 14px;
  padding: 8px 10px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  font-size: 12px;
  color: var(--ink-2);
  text-align: center;
  background: var(--paper);
}

/* ---------------------------------------------------------- 主框架 */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 20px 12px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  flex-wrap: wrap;
  row-gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  text-decoration: none;
  color: inherit;
}

.period { flex: 1; min-width: 150px; }

.period-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: 1px;
  line-height: 1.2;
  white-space: nowrap;
}

.period-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.nav-group {
  display: flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 9px;
  padding: 2px;
}
.nav-group .icon-btn { width: 28px; height: 28px; font-size: 17px; }
.nav-group .text-btn { padding: 4px 10px; font-size: 13px; }

.seg {
  display: flex;
  background: var(--paper-2);
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  padding: 4px 14px;
  border-radius: 7px;
  color: var(--ink-2);
  font-size: 13px;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.seg-btn.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(34, 31, 26, 0.10);
  font-weight: 500;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

#btn-notify { position: relative; }
#btn-notify.armed::after {
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

.user-area { position: relative; }

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0;
}

.menu {
  position: absolute;
  top: 40px;
  right: 0;
  z-index: 60;
  min-width: 168px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 6px;
  animation: pop 0.14s ease;
}

.menu-head {
  padding: 8px 10px 7px;
  font-size: 12px;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13.5px;
  color: var(--ink);
}
.menu-item:hover { background: var(--paper-2); }
.menu-item.danger { color: var(--seal); }

@keyframes pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------- 工作区 */
.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
}

.calendar-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.weekday-head {
  flex: none;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.weekday {
  padding: 7px 10px 6px;
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 2px;
  text-align: center;
}
.weekday.weekend { color: var(--seal); }

.calendar-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* 月视图 */
.month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  /* 整屏铺满，滚轮用于切换月份（见 app.js 的 wheel 处理） */
  grid-template-rows: repeat(6, minmax(96px, 1fr));
  height: 100%;
  border-left: 1px solid var(--line);
  margin-left: 1px;
}

/* 视图切换动效：方向感淡入 + 轻微滑入 */
.view-in-next {
  animation: view-in-next 0.34s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.view-in-prev {
  animation: view-in-prev 0.34s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
.view-in-fade {
  animation: view-in-fade 0.3s ease both;
}

@keyframes view-in-next {
  from { opacity: 0; transform: translateY(30px); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes view-in-prev {
  from { opacity: 0; transform: translateY(-30px); filter: blur(3px); }
  to { opacity: 1; transform: none; filter: none; }
}
@keyframes view-in-fade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.period-title.title-anim {
  animation: title-in 0.34s cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
@keyframes title-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .view-in-next, .view-in-prev, .view-in-fade, .period-title.title-anim {
    animation: none;
  }
}

.cell {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  margin-top: -1px;
  padding: 6px 7px 5px;
  min-width: 0;
  cursor: pointer;
  position: relative;
  transition: background 0.12s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.cell:hover { background: var(--paper-2); }

.cell.sel {
  background: #FBF0EB;
  box-shadow: inset 0 0 0 1.5px rgba(185, 58, 40, 0.38);
}

.cell.out .cell-num,
.cell.out .cell-label { opacity: 0.35; }
.cell.out .cell-events { opacity: 0.55; }

.cell-top {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 24px;
  flex: none;
}

.cell-num {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  line-height: 26px;
  width: 26px;
  height: 26px;
  text-align: center;
  border-radius: 50%;
  flex: none;
}

.cell.weekend:not(.today) .cell-num { color: var(--seal); }

.cell.today .cell-num {
  background: var(--seal);
  color: #FFF6F2;
}

.cell-label {
  font-size: 11px;
  color: var(--ink-3);
  line-height: 26px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.cell-label.fest {
  color: var(--seal);
  font-weight: 500;
}

.badge {
  flex: none;
  font-size: 10px;
  line-height: 15px;
  border-radius: 4px;
  padding: 0 3.5px;
  margin-top: 6px;
  letter-spacing: 0.5px;
}
.badge-off { color: var(--jade); background: rgba(78, 122, 95, 0.10); }
.badge-work { color: var(--ink-2); background: var(--paper-2); }

.cell-events {
  margin-top: 3px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.chip {
  display: flex;
  align-items: baseline;
  gap: 4px;
  padding: 1.5px 6px 1.5px 5px;
  border-radius: 4px;
  border-left: 3px solid var(--indigo);
  background: rgba(61, 90, 128, 0.08);
  font-size: 11.5px;
  line-height: 1.45;
  overflow: hidden;
  white-space: nowrap;
  flex: none;
}

.chip .chip-time {
  flex: none;
  color: var(--ink-2);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.chip .chip-title {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.chip-more {
  font-size: 11px;
  color: var(--ink-2);
  padding: 0 6px;
  border-radius: 4px;
  align-self: flex-start;
}
.chip-more:hover { color: var(--seal); background: var(--seal-soft); }

/* 周视图 */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(158px, 1fr));
  gap: 0;
  min-height: 100%;
  border-left: 1px solid var(--line);
  margin-left: 1px;
}

.week-col {
  border-right: 1px solid var(--line);
  border-top: 1px solid var(--line);
  margin-top: -1px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  cursor: pointer;
  transition: background 0.12s ease;
}
.week-col:hover { background: var(--paper-2); }
.week-col.sel { background: #FBF0EB; }

.week-col-head {
  padding: 10px 12px 9px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--paper);
}

.week-day-name {
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 1px;
}

.week-day-num {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
}

.week-col.today .week-day-num {
  background: var(--seal);
  color: #FFF6F2;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-size: 19px;
  margin: -2px 0;
}

.week-lunar {
  font-size: 11px;
  color: var(--ink-3);
  flex-basis: 100%;
  line-height: 1.2;
}
.week-lunar.fest { color: var(--seal); }

.week-col-body {
  padding: 8px 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.week-event {
  border-left: 3px solid var(--indigo);
  background: var(--card);
  border-radius: 6px;
  padding: 5px 8px 6px;
  box-shadow: 0 1px 2px rgba(34, 31, 26, 0.05);
  min-width: 0;
}

.week-ev-time {
  font-size: 11px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.week-ev-title {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
}

.week-ev-desc {
  font-size: 11.5px;
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-empty {
  font-size: 12px;
  color: var(--ink-3);
  padding: 6px 2px;
}

/* ---------------------------------------------------------- 侧栏 */
.rail {
  flex: none;
  width: 318px;
  border-left: 1px solid var(--line);
  padding: 16px 16px 24px;
  overflow-y: auto;
  background: var(--paper);
}

.rail-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 16px 14px;
  margin-bottom: 14px;
}

.day-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-2);
  letter-spacing: 1px;
}

.today-tag {
  font-size: 10.5px;
  color: var(--seal);
  border: 1px solid rgba(185, 58, 40, 0.45);
  border-radius: 4px;
  padding: 0 5px;
  line-height: 16px;
  letter-spacing: 2px;
}

.day-title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 6px;
}

.day-big {
  font-family: var(--font-serif);
  font-size: 54px;
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.day-meta {
  padding-top: 7px;
  min-width: 0;
}

.day-meta .ym {
  font-size: 12.5px;
  color: var(--ink-2);
}

.day-meta .lunar {
  font-size: 12.5px;
  color: var(--ink-2);
  margin-top: 1px;
}

.day-meta .lunar .fest { color: var(--seal); font-weight: 500; }

.holiday-line {
  margin-top: 8px;
  padding: 5px 9px;
  border-radius: 6px;
  background: var(--seal-soft);
  color: var(--seal-deep);
  font-size: 12px;
}

.day-sep {
  border: none;
  border-top: 1px solid var(--line);
  margin: 13px 0 10px;
}

.day-events { display: flex; flex-direction: column; }

.day-event {
  display: flex;
  align-items: baseline;
  gap: 9px;
  padding: 7px 4px;
  border-radius: 7px;
  cursor: pointer;
  min-width: 0;
  transition: background 0.12s ease;
}
.day-event:hover { background: var(--paper-2); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
  align-self: center;
}

.day-ev-time {
  flex: none;
  font-size: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  width: 84px;
}

.day-ev-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-empty {
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 14px 0 10px;
  text-align: center;
}

/* 待办 */
.todos-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.todos-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--ink-2);
}

.todo-count {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.todo-form {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.todo-input {
  flex: 1;
  min-width: 0;
  border: none;
  border-bottom: 1px solid var(--line-strong);
  border-radius: 0;
  padding: 6px 2px;
  background: transparent;
  transition: border-color 0.15s ease;
}
.todo-input:focus {
  outline: none;
  border-bottom-color: var(--seal);
}

.todo-add {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--seal);
  font-size: 19px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}
.todo-add:hover { background: var(--seal-soft); }

.todo-date {
  width: 100%;
  border: none;
  border-bottom: 1px dashed var(--line);
  padding: 4px 2px;
  font-size: 11.5px;
  color: var(--ink-2);
  background: transparent;
  margin-bottom: 10px;
}
.todo-date:focus { outline: none; border-bottom-color: var(--seal); }

.todo-list { display: flex; flex-direction: column; }

.todo-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 4px;
  border-radius: 7px;
  transition: background 0.12s ease;
  min-width: 0;
}
.todo-item:hover { background: var(--paper-2); }

.todo-check {
  flex: none;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.5px solid var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 11px;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.todo-check:hover { border-color: var(--jade); color: var(--jade); }
.todo-item.done .todo-check {
  background: var(--jade);
  border-color: var(--jade);
  color: #fff;
}

.todo-title {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.todo-due {
  flex: none;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.todo-due.overdue { color: var(--seal); }

.todo-del {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  color: var(--ink-3);
  font-size: 15px;
  line-height: 1;
  opacity: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
}
.todo-item:hover .todo-del { opacity: 1; }
.todo-del:hover { background: var(--seal-soft); color: var(--seal); }

.todo-item.done .todo-title {
  color: var(--ink-3);
  text-decoration: line-through;
}

.todos-done-toggle {
  margin-top: 6px;
  font-size: 12px;
  color: var(--ink-3);
  padding: 4px 2px;
}
.todos-done-toggle:hover { color: var(--ink-2); }

.todo-empty {
  font-size: 12.5px;
  color: var(--ink-3);
  text-align: center;
  padding: 10px 0 4px;
}

/* ---------------------------------------------------------- 弹窗 */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 27, 22, 0.42);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade 0.16s ease;
}

.modal {
  width: 100%;
  max-width: 470px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  background: var(--card);
  border-radius: 14px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise 0.18s ease;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 10px;
}

.modal-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 1px;
}

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--ink-3);
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover { background: var(--paper-2); color: var(--ink); }

.modal-body { padding: 4px 20px 16px; }

.modal-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
}
.modal-foot .spacer { flex: 1; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-row { margin-bottom: 13px; }

.form-row > label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 5px;
  letter-spacing: 0.5px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* 开关 */
.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}

.switch {
  display: inline-block;
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 10px;
  background: var(--line-strong);
  transition: background 0.16s ease;
  flex: none;
  vertical-align: middle;
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: transform 0.16s ease;
}
.switch-row input { display: none; }
.switch-row input:checked + .switch { background: var(--seal); }
.switch-row input:checked + .switch::after { transform: translateX(14px); }

/* 颜色 */
.swatches { display: flex; gap: 9px; }

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.6);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative;
}
.swatch:hover { transform: scale(1.12); }
.swatch.active {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink);
}

.form-error {
  min-height: 18px;
  font-size: 12.5px;
  color: var(--seal);
  margin-top: 4px;
}

/* 忙态 */
.loading { opacity: 0.6; pointer-events: none; }

.btn-danger.confirming { background: var(--seal); color: #fff; }

/* 导入/订阅弹窗 */
.subscribe-url {
  display: flex;
  gap: 6px;
}
.subscribe-url .input {
  font-size: 12px;
  color: var(--ink-2);
  background: var(--paper);
}
.subscribe-url .btn-primary { flex: none; padding: 8px 14px; }

.help-text {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.7;
  margin-top: 10px;
}
.help-text b { color: var(--ink-2); font-weight: 500; }

/* ---------------------------------------------------------- Toast */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: max-content;
  max-width: 90vw;
}

.toast {
  background: rgba(34, 31, 26, 0.92);
  color: #F7F4EC;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 9px;
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.18s ease;
  max-width: 90vw;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------- 响应式 */
@media (max-width: 1120px) {
  .workspace { flex-direction: column; overflow-y: auto; }
  .calendar-pane { flex: none; min-height: 62vh; }
  .calendar-body { overflow: visible; }
  .month-grid { height: auto; grid-template-rows: repeat(6, minmax(88px, auto)); }
  .week-col-body { min-height: 120px; }
  .rail {
    width: auto;
    border-left: none;
    border-top: 1px solid var(--line);
    overflow: visible;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    align-items: start;
  }
  .rail-card { margin-bottom: 0; }
}

@media (max-width: 720px) {
  .topbar { padding: 10px 12px; gap: 10px; }
  .brand .wordmark { display: none; }
  .period-title { font-size: 20px; }
  .period-sub { font-size: 11.5px; }
  .toolbar { gap: 6px; }
  .seg-btn { padding: 4px 10px; }
  .weekday { padding: 5px 6px; letter-spacing: 0; text-align: center; }
  .cell { padding: 4px 4px 3px; }
  .cell-top { flex-wrap: wrap; }
  .cell-num { font-size: 15px; width: 22px; height: 22px; line-height: 22px; }
  .cell-label { flex-basis: 100%; font-size: 10px; line-height: 1.35; }
  .badge { position: absolute; top: 5px; right: 5px; margin-top: 0; }
  .chip { font-size: 10px; padding: 1px 4px 1px 3px; border-left-width: 2px; }
  .chip .chip-time { display: none; }
  .rail { grid-template-columns: 1fr; padding: 12px; }
  .day-big { font-size: 44px; }
  .week-grid { grid-template-columns: repeat(7, 128px); overflow-x: auto; }
  .modal { max-width: 100%; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------------- 右键预设菜单 */
.preset-menu {
  position: fixed;
  z-index: 4000;
  min-width: 158px;
  padding: 6px;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--ink);
}

.preset-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.preset-menu button:hover { background: var(--paper-2); }

.preset-menu .preset-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}

.preset-menu .preset-sep {
  height: 1px;
  margin: 5px 6px;
  background: var(--line);
}

.preset-menu .preset-plus {
  width: 8px;
  text-align: center;
  color: var(--ink-3);
  flex: none;
}

/* ---------------------------------------------------------- 日视图 */
.day-view {
  padding: 22px 24px 48px;
  max-width: 780px;
}

.day-view-head {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.day-view-num {
  font-family: var(--font-serif);
  font-size: 62px;
  line-height: 1;
  font-weight: 600;
}

.day-view-meta { padding-bottom: 6px; }
.day-view-week { font-size: 13px; color: var(--ink-2); }
.day-view-lunar { margin-top: 4px; font-size: 12px; color: var(--ink-3); }
.day-view-lunar.fest { color: var(--seal); }

.day-view-list { display: flex; flex-direction: column; gap: 10px; }

.day-view-empty {
  padding: 36px 0;
  color: var(--ink-3);
  font-size: 13.5px;
  text-align: center;
}

.day-item {
  display: flex;
  gap: 14px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--indigo);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.day-item:hover { background: var(--paper-2); }

.day-item-time {
  flex: 0 0 108px;
  font-family: var(--font-serif);
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.5;
}

.day-item-title { font-size: 14.5px; font-weight: 600; }
.day-item-desc {
  margin-top: 3px;
  font-size: 12.5px;
  color: var(--ink-2);
  white-space: pre-wrap;
}

/* ---------------------------------------------------------- 年视图 */
.year-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  padding: 18px;
}

.year-month {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 10px 12px;
}

.year-month-head {
  display: block;
  width: 100%;
  padding: 2px 4px 8px;
  border: 0;
  background: none;
  text-align: left;
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.year-month-head:hover { color: var(--seal); }

.year-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.year-dow {
  padding-bottom: 2px;
  font-size: 9.5px;
  color: var(--ink-3);
  text-align: center;
}

.year-day {
  position: relative;
  padding: 3px 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--ink-2);
  text-align: center;
  cursor: pointer;
}

.year-day:hover { background: var(--paper-2); color: var(--ink); }
.year-day.out { opacity: 0; pointer-events: none; }

.year-day.today {
  background: var(--seal);
  color: #fff;
  border-radius: 50%;
}

.year-day.has-ev::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 1px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--seal);
  opacity: 0.75;
  transform: translateX(-50%);
}

.year-day.today.has-ev::after { background: #fff; }

@media (max-width: 1120px) {
  .year-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 720px) {
  .year-grid { grid-template-columns: repeat(2, 1fr); padding: 12px; gap: 10px; }
  .day-view { padding: 16px 14px 36px; }
  .day-view-num { font-size: 48px; }
  .day-item-time { flex-basis: 84px; }
}

/* ---------------------------------------------------------- 返回大厅 */
.hall-back {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 6px 11px;
  margin-left: 2px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.hall-back:hover {
  background: var(--paper-2);
  color: var(--ink);
  border-color: var(--ink-3);
}

.auth-hall {
  display: inline-block;
  margin-top: 18px;
  color: var(--ink-2);
  font-size: 12.5px;
  text-decoration: none;
  border-bottom: 1px dashed var(--line-strong);
  padding-bottom: 2px;
}

.auth-hall:hover { color: var(--seal); }

.gate-text {
  margin: 10px 0 20px;
  font-size: 13px;
  line-height: 1.75;
  color: var(--ink-2);
}

.gate-btn {
  display: block;
  text-align: center;
  text-decoration: none;
  padding: 11px 16px;
  border-radius: var(--radius);
  background: var(--seal);
  color: #fff6f2;
}

.gate-btn:hover { background: var(--seal-deep); }

a.avatar { text-decoration: none; }
.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
