/* =========================================================
 * 电子行事历 样式
 *
 * 目录：
 *  1. 颜色、字体（改颜色只要改这里）
 *  2. 基本设定
 *  3. 整体版面、下方分页
 *  4. 按钮
 *  5. 行事历工具列、筛选按钮
 *  6. 月视图
 *  7. 周视图
 *  8. 活动小标签（四种颜色）
 *  9. 弹出窗口（日期窗口、筛选窗口）
 * 10. 笔记本
 * 11. 我的
 * 12. 其他
 * ========================================================= */


/* ---------- 1. 颜色、字体 ---------- */

:root {
  /* 底色 */
  --color-background: #F7F2E8;     /* 米色背景 */
  --color-surface: #FFFDF8;        /* 卡片、格子 */
  --color-paper: #FFFFFF;          /* 输入框 */
  --color-border: #E6DCCB;
  --color-grid-line: #E2D7C4;
  --color-empty-cell: #F2ECE0;

  /* 文字 */
  --color-text: #2B2620;
  --color-text-muted: #5E564C;
  --color-text-faint: #8C8274;

  /* 主色（赭红） */
  --color-accent: #A8471A;
  --color-accent-dark: #7E3412;

  /* 特别标示 */
  --color-festival: #8A3A14;       /* 节日名称 */
  --color-fast-day: #2F4A36;       /* 斋日（深绿） */
  --color-fast-day-solid: #3D5C45;
  --color-note: #24427A;           /* 笔记的蓝字 */

  /* 四种活动的颜色：底色 / 字色 */
  --type-general-bg: #F3E3D6;   --type-general-text: #7A3211;   /* 普通活动：浅橙 */
  --type-meeting-bg: #2F4E78;   --type-meeting-text: #FFFFFF;   /* 会议：深蓝 */
  --type-reading-bg: #DDEBD8;   --type-reading-text: #24452B;   /* 导读班：浅绿 */
  --type-class-bg: #5B4580;     --type-class-text: #FFFFFF;     /* 班课：深紫 */

  /* 字体：用手机内建的中文字体，不用另外下载 */
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-serif: "Songti SC", "Noto Serif SC", "SimSun", serif;

  /* 大小 */
  --tab-bar-height: 64px;
  --radius-small: 8px;
  --radius-medium: 14px;
  --radius-large: 20px;
}


/* ---------- 2. 基本设定 ---------- */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--color-background);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body.has-open-sheet {
  overflow: hidden;
}

button,
input,
textarea {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1, h2, h3, p {
  margin: 0;
}

/* 给读屏软件看、但画面上不显示的文字 */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}


/* ---------- 3. 整体版面、下方分页 ---------- */

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 560px;      /* 平板、电脑上不要拉太宽 */
  margin: 0 auto;
  background: var(--color-background);
}

.app__main {
  flex: 1;
  min-height: 0;          /* 让内容可以在这里面上下滑 */
  overflow-y: auto;
  padding-bottom: 16px;
}

.tab-bar {
  display: flex;
  justify-content: space-around;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.tab-bar__button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 80px;
  min-height: 52px;
  padding: 4px 0;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  font-size: 12px;
}

.tab-bar__button.is-active {
  color: var(--color-accent);
  font-weight: 700;
}

.loading {
  padding: 40px 20px;
  text-align: center;
  color: var(--color-text-muted);
}


/* ---------- 4. 按钮 ---------- */

.primary-button,
.secondary-button {
  min-height: 52px;
  padding: 0 20px;
  border-radius: 26px;
  font-size: 16px;
  font-weight: 700;
}

.primary-button {
  border: none;
  background: var(--color-accent);
  color: #FFFFFF;
}

.secondary-button {
  border: 1px solid var(--color-accent);
  background: var(--color-surface);
  color: var(--color-accent);
}

.round-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: 22px;
  background: var(--color-surface);
}

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


/* ---------- 5. 行事历工具列、筛选按钮 ---------- */

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 12px 6px 18px;
}

.calendar-toolbar__titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.calendar-toolbar__temple,
.calendar-toolbar__subtitle {
  font-size: 12px;
  color: var(--color-text-muted);
}

.calendar-toolbar__title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
}

.calendar-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.view-switch {
  display: flex;
  gap: 2px;
  margin-right: 4px;
  padding: 3px;
  border-radius: 14px;
  background: #EFE7D9;
}

.view-switch__button {
  width: 42px;
  height: 38px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: #4A433B;
  font-size: 15px;
}

.view-switch__button.is-active {
  background: var(--color-surface);
  color: var(--color-text);
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(60, 40, 20, 0.15);
}

.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 12px 8px 14px;
}

.filter-bar__button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #D6C9B4;
  border-radius: 20px;
  background: var(--color-surface);
  font-size: 14px;
  font-weight: 700;
}

.filter-bar__button svg:first-child {
  color: var(--color-accent);
}

.filter-bar__hidden {
  font-size: 12px;
  color: var(--color-text-muted);
}


/* ---------- 6. 月视图 ---------- */

.month-view {
  padding: 0 6px;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  padding: 4px 0;
  text-align: center;
  font-size: 12px;
  color: var(--color-text-muted);
}

.weekday-row__name.is-sunday {
  color: var(--color-accent);
  font-weight: 700;
}

.month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--color-grid-line);
  border-radius: 10px;
  background: var(--color-grid-line);   /* 格子中间的线 */
}

.month-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  min-width: 0;
  height: 118px;
  padding: 4px 3px 3px;
  overflow: hidden;
  border: none;
  background: var(--color-surface);
  text-align: left;
}

.month-cell--empty {
  background: var(--color-empty-cell);
}

.month-cell__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1px;
  padding: 0 1px;
}

.month-cell__day {
  font-size: 15px;
  font-weight: 700;
  line-height: 18px;
}

.month-cell__lunar {
  overflow: hidden;
  font-size: 10px;
  line-height: 12px;
  white-space: nowrap;
  color: var(--color-text-muted);
}

.month-cell.is-sunday .month-cell__day {
  color: var(--color-accent);
}

.month-cell.is-festival .month-cell__lunar {
  color: var(--color-festival);
  font-weight: 700;
}

.month-cell.is-fast-day .month-cell__lunar {
  color: var(--color-fast-day);
  font-weight: 700;
}

.month-cell.is-today {
  box-shadow: inset 0 0 0 2px var(--color-accent);
}

.month-cell.is-today .month-cell__day {
  padding: 0 4px;
  border-radius: 9px;
  background: var(--color-accent);
  color: #FFFFFF;
}

.month-cell__more {
  align-self: flex-start;
  padding: 0 5px;
  border-radius: 7px;
  background: var(--color-text);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
}

.month-cell__note {
  display: -webkit-box;
  overflow: hidden;
  padding: 1px 2px 0;
  color: var(--color-note);
  font-size: 10px;
  line-height: 13px;
  word-break: break-all;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  padding: 12px 8px 4px;
  font-size: 12px;
  color: var(--color-text-muted);
}

.legend__item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend__festival { color: var(--color-festival); font-weight: 700; }
.legend__fast { color: var(--color-fast-day); font-weight: 700; }
.legend__note { color: var(--color-note); }


/* ---------- 7. 周视图 ---------- */

.week-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 12px;
}

.week-row {
  display: flex;
  gap: 12px;
  padding: 12px 12px 10px;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  background: var(--color-surface);
}

.week-row.is-today {
  border: 2px solid var(--color-accent);
}

.week-row__date {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  width: 56px;
  flex: none;
  padding-top: 2px;
}

.week-row__day {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 700;
  line-height: 32px;
}

.week-row__weekday {
  font-size: 14px;
  color: var(--color-text-muted);
}

.week-row__lunar {
  margin-top: 2px;
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
}

.week-row.is-sunday .week-row__day,
.week-row.is-sunday .week-row__weekday,
.week-row.is-today .week-row__day {
  color: var(--color-accent);
}

.week-row.is-festival .week-row__lunar {
  color: var(--color-festival);
  font-weight: 700;
}

.week-row.is-fast-day .week-row__lunar {
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--color-fast-day-solid);
  color: #FFFFFF;
  font-weight: 700;
}

.week-row__content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.week-row__events {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.week-row__toggle {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--color-text);
  border-radius: var(--radius-small);
  background: var(--color-paper);
  font-size: 14px;
  font-weight: 700;
}

/* 横线纸样式的书写区（周视图、日期窗口共用） */
.note-lines {
  width: 100%;
  resize: none;
  border: none;
  border-radius: var(--radius-small);
  background-color: transparent;
  background-image: linear-gradient(transparent 28px, #EFE7D9 29px);
  background-size: 100% 29px;
  background-position: 0 4px;
  color: var(--color-note);
  font-size: 17px;
  line-height: 29px;
}

.note-lines::placeholder {
  color: var(--color-text-faint);
}

.note-lines:focus {
  background-color: var(--color-paper);
}

.week-row__note {
  min-height: 62px;
  padding: 4px 6px;
}


/* ---------- 8. 活动小标签（四种颜色） ---------- */

.event-chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-small);
  font-size: 16px;
  font-weight: 700;
  line-height: 22px;
}

.event-chip__type {
  margin-right: 6px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.9;
}

/* 月历格子里的小号 */
.event-chip--compact {
  display: block;
  padding: 2px 3px;
  border-radius: 4px;
  font-size: 10px;
  line-height: 12px;
  word-break: break-all;
}

.event-chip--general { background: var(--type-general-bg); color: var(--type-general-text); }
.event-chip--meeting { background: var(--type-meeting-bg); color: var(--type-meeting-text); }
.event-chip--reading { background: var(--type-reading-bg); color: var(--type-reading-text); }
.event-chip--class   { background: var(--type-class-bg);   color: var(--type-class-text); }


/* ---------- 9. 弹出窗口（日期窗口、筛选窗口） ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.overlay__backdrop {
  flex: 1;
  border: none;
  background: rgba(43, 38, 32, 0.32);
}

.sheet {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  margin: 0 auto;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom));
  overflow-y: auto;
  border-radius: 22px 22px 0 0;
  background: var(--color-surface);
  box-shadow: 0 -8px 24px rgba(60, 40, 20, 0.18);
}

.sheet__handle {
  align-self: center;
  width: 40px;
  height: 5px;
  border-radius: 3px;
  background: #D6C9B4;
}

.sheet__header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sheet__title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
}

.sheet__subtitle,
.sheet__hint {
  font-size: 14px;
  line-height: 21px;
  color: var(--color-text-muted);
}

.sheet__events {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sheet__empty {
  font-size: 15px;
  color: var(--color-text-muted);
}

.sheet__label {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-note);
}

.sheet__note {
  height: 150px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  background-color: var(--color-paper);
  background-position: 0 10px;   /* 横线对齐文字 */
  font-size: 18px;
}

.sheet__section-title {
  padding-top: 4px;
  font-size: 15px;
  font-weight: 700;
}

.sheet__buttons {
  display: flex;
  gap: 10px;
}

.sheet__buttons > * {
  flex: 1;
}

/* 区的开关 */
.zone-list {
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 16px;
}

.zone-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 8px 14px;
  border: none;
  border-bottom: 1px solid #EFE7D9;
  background: var(--color-paper);
  text-align: left;
}

.zone-switch:last-child {
  border-bottom: none;
}

.zone-switch__symbol {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 16px;
  background: #EDE6F3;
  color: #45355C;
  font-size: 18px;
}

.zone-switch__name {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  font-size: 17px;
  font-weight: 700;
}

.zone-switch__mine {
  padding: 1px 7px;
  border-radius: 8px;
  background: var(--color-accent);
  color: #FFFFFF;
  font-size: 12px;
}

.zone-switch__state {
  font-size: 13px;
  color: var(--color-text-muted);
}

.zone-switch.is-on .zone-switch__state {
  color: var(--color-fast-day);
  font-weight: 700;
}

.toggle {
  position: relative;
  width: 50px;
  height: 30px;
  flex: none;
  border-radius: 15px;
  background: #CFC5B5;
}

.toggle__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 12px;
  background: #FFFFFF;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: left 0.15s;
}

.zone-switch.is-on .toggle {
  background: var(--color-fast-day-solid);
}

.zone-switch.is-on .toggle__knob {
  left: 23px;
}

/* 活动种类按钮 */
.type-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.type-button {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px dashed #C9BBAA;
  border-radius: 22px;
  background: var(--color-paper);
  color: var(--color-text-faint);
  font-size: 15px;
  text-decoration: line-through;
}

.type-button.is-on {
  border: 1px solid var(--color-text);
  color: var(--color-text);
  font-weight: 700;
  text-decoration: none;
}

.type-button__swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
}


/* ---------- 10. 笔记本 ---------- */

.page-header {
  padding: 20px 20px 10px;
}

.page-header__title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
}

.notebook {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px;
}

.search-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--color-border);
  border-radius: 24px;
  background: var(--color-surface);
  font-size: 16px;
}

.notebook__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.notebook__month {
  padding-top: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.note-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: 16px;
  background: var(--color-surface);
  text-align: left;
}

.note-card__date {
  font-size: 13px;
  color: var(--color-text-muted);
}

.note-card__text {
  color: var(--color-note);
  font-size: 16px;
  line-height: 24px;
  white-space: pre-wrap;
}

.empty-message {
  padding: 24px 4px;
  color: var(--color-text-muted);
  font-size: 15px;
  line-height: 24px;
}


/* ---------- 11. 我的 ---------- */

.profile {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 16px;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-large);
  background: var(--color-surface);
}

.card__title {
  font-size: 17px;
  font-weight: 700;
}

.card__text {
  font-size: 14px;
  line-height: 22px;
  color: #4A433B;
}

.zone-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.zone-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px 12px;
  border: 1px solid #D6C9B4;
  border-radius: var(--radius-medium);
  background: var(--color-paper);
  text-align: left;
}

.zone-option.is-selected {
  padding: 7px 11px;
  border: 2px solid var(--color-accent);
  background: #FFF7EE;
}

.zone-option__radio {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex: none;
  border: 2px solid #C9BBAA;
  border-radius: 11px;
}

.zone-option.is-selected .zone-option__radio {
  border-color: var(--color-accent);
}

.zone-option__dot {
  width: 10px;
  height: 10px;
  border-radius: 5px;
}

.zone-option.is-selected .zone-option__dot {
  background: var(--color-accent);
}

.zone-option__name {
  font-size: 17px;
  font-weight: 700;
}


/* ---------- 12. 其他 ---------- */

.load-error {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 60px 24px;
  text-align: center;
}

.load-error h1 {
  font-size: 20px;
}

.load-error__detail {
  font-size: 13px;
  color: var(--color-text-muted);
}
