/* ============================================================
   干支万年历 · 样式
   配色：单一主蓝 + 黑/白/灰，无第二种彩色
   ============================================================ */

:root {
  --accent: #2f6feb;
  --accent-strong: #1f55c0;
  --accent-soft: #eff4ff;

  --ink: #101828;
  --ink-2: #475467;
  --ink-3: #6b7280;
  --ink-4: #98a2b3;

  --bg: #ffffff;
  --bg-body: #f6f7f9;
  --surface: #ffffff;
  --line: #e4e7ec;
  --line-soft: #eef1f5;

  --danger: #d92d20;

  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);

  --font: 'PingFang SC', 'Noto Sans SC', 'Hiragino Sans GB', 'Microsoft YaHei', system-ui, sans-serif;
  --font-num: 'SF Mono', 'Menlo', 'Roboto Mono', system-ui, sans-serif;

  --nav-h: 52px;
}

:root[data-theme='dark'] {
  --accent: #4c8dff;
  --accent-strong: #7aa8ff;
  --accent-soft: #16233d;

  --ink: #eef1f6;
  --ink-2: #b6bfcd;
  --ink-3: #93a0b4;
  --ink-4: #7c8798;

  --bg: #0d1117;
  --bg-body: #080b10;
  --surface: #131822;
  --line: #232a36;
  --line-soft: #1a212c;

  --danger: #f97066;
  --shadow: none;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

a { color: var(--accent); text-decoration: none; }

/* ============ 顶栏 ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
}

.topbar h1 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .04em;
}

.topbar .brand-sub {
  font-size: 10px;
  font-weight: 400;
  opacity: .72;
  margin-left: 6px;
  letter-spacing: 0;
}

.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #fff;
  font-size: 15px;
  transition: background .15s;
}

.icon-btn:hover { background: rgba(255, 255, 255, .16); }

.topbar-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font-size: 12px;
  transition: background .15s;
}

.topbar-chip:hover { background: rgba(255, 255, 255, .26); }

/* ============ 布局 ============ */
.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 14px 84px;
}

.board {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

@media (min-width: 880px) {
  .layout { grid-template-columns: minmax(0, 1.6fr) minmax(292px, 1fr); }
}

/* ============ 月份导航 ============ */
.cal-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 8px 8px;
}

.nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--ink-2);
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-btn:hover { background: var(--accent-soft); color: var(--accent); }

.cal-title {
  flex: 1;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
}

.cal-title small {
  font-weight: 400;
  color: var(--ink-3);
  font-size: 12px;
  margin-left: 6px;
}

/* ============ 选项行 ============ */
.opts {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px 10px;
  flex-wrap: wrap;
}

.chip {
  padding: 4px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-2);
  background: var(--bg);
  transition: all .15s;
  white-space: nowrap;
}

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

.chip[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip-spacer { flex: 1; }

/* ============ 选中日信息条 ============ */
.selected-bar {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 12px;
  background: var(--accent-soft);
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  color: var(--ink);
}

.selected-bar .sb-date { font-weight: 600; }

.selected-bar .sb-gz {
  color: var(--accent);
  font-weight: 600;
  letter-spacing: .04em;
}

.selected-bar .sb-note {
  color: var(--ink-3);
  font-size: 12px;
}

/* ============ 星期表头 ============ */
.weekhead {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--line);
}

.weekhead span {
  padding: 7px 0;
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
}

.weekhead span.we { color: var(--ink-2); }

/* ============ 日历网格 ============ */
.grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cell {
  position: relative;
  min-height: 62px;
  padding: 6px 2px 5px;
  text-align: center;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background .12s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1px;
  background: var(--surface);
}

.cell:nth-child(7n) { border-right: 0; }
.cell:hover { background: var(--accent-soft); }

.cell.is-out { opacity: .34; }

.cell.is-today .c-day {
  background: var(--accent);
  color: #fff;
}

.cell.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.c-day {
  min-width: 21px;
  height: 21px;
  line-height: 21px;
  border-radius: 999px;
  font-size: 14px;
  font-family: var(--font-num);
  font-weight: 500;
  color: var(--ink);
}

.c-gz {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: .02em;
}

.cell.is-term .c-gz { color: var(--accent); }

.c-term {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 9.5px;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -.02em;
  white-space: nowrap;
}

.c-lunar {
  font-size: 10px;
  color: var(--ink-4);
  line-height: 1.2;
}

.c-events {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 6px;
  margin-top: 1px;
}

.c-dot {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: var(--accent);
}

.c-dot.more {
  width: auto;
  padding: 0 2px;
  font-size: 8px;
  line-height: 1;
  border-radius: 3px;
  color: var(--accent);
  background: none;
}

@media (min-width: 880px) {
  .cell { min-height: 74px; }
  .c-gz { font-size: 12px; }
  .c-lunar { font-size: 11px; }
}

/* ============ 日详情 ============ */
.detail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.detail-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.detail-head .d-date { font-size: 15px; font-weight: 600; }
.detail-head .d-week { font-size: 12px; color: var(--ink-3); }

.gz-line {
  display: flex;
  gap: 6px;
  margin: 12px 0 10px;
  flex-wrap: wrap;
}

.gz-pill {
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
}

.gz-pill .gz-sub {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--ink-3);
  margin: 0 2px;
}

.gz-pill .gz-arrow {
  font-size: 10px;
  color: var(--ink-4);
  margin: 0 1px;
}


.meta-list {
  display: grid;
  gap: 7px;
  font-size: 12.5px;
}

.meta-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.meta-row .k {
  width: 52px;
  flex: none;
  color: var(--ink-3);
  font-size: 12px;
}

.meta-row .v { color: var(--ink); }
.meta-row .v.mono { font-family: var(--font-num); }

.term-note {
  margin-top: 10px;
  padding: 8px 10px;
  border-left: 2px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.6;
}

.term-note b { color: var(--accent); }

.events-block {
  margin-top: 12px;
  border-top: 1px solid var(--line-soft);
  padding-top: 10px;
}

.events-block h3 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
}

.ev-item {
  display: flex;
  gap: 7px;
  align-items: baseline;
  padding: 4px 0;
  font-size: 12.5px;
  border-bottom: 1px dashed var(--line-soft);
}

.ev-item:last-child { border-bottom: 0; }

.ev-time {
  font-family: var(--font-num);
  font-size: 11px;
  color: var(--ink-3);
  flex: none;
}

.ev-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  flex: none;
  margin-top: 5px;
}

.ev-title { color: var(--ink); line-height: 1.4; }

.ev-cal {
  font-size: 10px;
  color: var(--ink-4);
  flex: none;
  margin-left: auto;
}

.empty-note {
  font-size: 12px;
  color: var(--ink-4);
  padding: 2px 0;
}

/* ============ 底部快捷链接 ============ */
.quicklinks {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 15;
  display: flex;
  gap: 1px;
  background: var(--line);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.quicklinks a,
.quicklinks button {
  flex: 1;
  padding: 11px 4px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--surface);
  transition: color .15s, background .15s;
}

.quicklinks a:hover,
.quicklinks button:hover { color: var(--accent); background: var(--accent-soft); }

/* ============ 抽屉（订阅 / 导入） ============ */
.sheet-mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(16, 24, 40, .38);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
}

.sheet-mask.open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  z-index: 41;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: var(--surface);
  border-left: 1px solid var(--line);
  transform: translateX(102%);
  transition: transform .22s ease;
  display: flex;
  flex-direction: column;
}

.sheet.open { transform: none; }

.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--accent);
  color: #fff;
}

.sheet-head h2 { flex: 1; margin: 0; font-size: 15px; font-weight: 600; }
.sheet-head button { color: #fff; font-size: 17px; opacity: .9; }

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  -webkit-overflow-scrolling: touch;
}

.field { margin-bottom: 18px; }

.field h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: .06em;
}

.hint {
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.65;
  margin: 6px 0 0;
}

.urlbox {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.urlbox input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 11px;
  font-family: var(--font-num);
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.urlbox input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.btn {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  border: 1px solid var(--line);
  color: var(--ink-2);
  background: var(--bg);
  white-space: nowrap;
  transition: all .15s;
}

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

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.dropzone {
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--ink-3);
  cursor: pointer;
  transition: all .15s;
  background: var(--bg);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.feed-list { display: grid; gap: 6px; }

.feed-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 13px;
}

.feed-item .cal-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.feed-item .btn { padding: 5px 12px; }

.cal-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}

.cal-item:last-child { border-bottom: 0; }

.cal-swatch {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex: none;
}

.cal-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-count { font-size: 11px; color: var(--ink-4); font-family: var(--font-num); }

.cal-del {
  font-size: 15px;
  color: var(--ink-4);
  padding: 0 3px;
  line-height: 1;
}

.cal-del:hover { color: var(--danger); }

.switch {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--line);
  flex: none;
  transition: background .15s;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  transition: transform .15s;
}

.switch[aria-pressed='true'] { background: var(--accent); }
.switch[aria-pressed='true']::after { transform: translateX(14px); }

textarea {
  width: 100%;
  min-height: 86px;
  padding: 8px 10px;
  font-size: 12px;
  font-family: var(--font-num);
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  resize: vertical;
}

/* ============ 添加到主屏幕提示 ============ */
.a2hs {
  position: fixed;
  left: 50%;
  bottom: 62px;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(420px, calc(100vw - 24px));
  padding: 8px 8px 8px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  font-size: 12.5px;
  color: var(--ink-2);
}

.a2hs[hidden] { display: none; }

.a2hs-text { flex: 1; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.a2hs-close {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  color: var(--ink-3);
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.a2hs-close:hover { background: var(--bg-body); color: var(--ink); }

/* ============ 提示条 ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 74px;
  transform: translate(-50%, 12px);
  z-index: 60;
  background: var(--ink);
  color: var(--bg);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 82vw;
  text-align: center;
}

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

/* ============ 说明页脚 ============ */
.footnote {
  margin: 14px 2px 0;
  font-size: 11.5px;
  color: var(--ink-4);
  line-height: 1.7;
}

.footnote code {
  font-family: var(--font-num);
  font-size: 11px;
  background: var(--bg-body);
  padding: 1px 4px;
  border-radius: 4px;
}

@media (max-width: 420px) {
  .cell { min-height: 56px; }
  .c-day { font-size: 13px; min-width: 19px; height: 19px; line-height: 19px; }
  .c-gz { font-size: 10px; }
  .c-term { font-size: 8px; }
}

@media (min-width: 880px) {
  .quicklinks {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(1080px, 100%);
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
    border-radius: 12px 12px 0 0;
  }
}
