/* ============ 甲历 · 样式（按参考图还原） ============ */
:root {
  --topbar-grad: linear-gradient(180deg, #17776f, #2fa08f);
  --header-teal: #2f9e93;
  --weekcol-bg: #e9d9e9;
  --bg-grad: linear-gradient(150deg, #cfe6f2 0%, #e3dced 45%, #f2d9e2 100%);
  --cell-bg: rgba(255,255,255,0.42);
  --cell-other-bg: rgba(150,110,100,0.30);
  --weekend-bg: rgba(222,168,128,0.28);
  --today-border: #f5d327;
  --sel-border: #2fa08f;
  --text-main: #2c3e40;
  --text-dim: #7d8a8c;
  --text-red: #d43c33;
  --text-green: #2e8b57;
  --chip-color: #1f6f66;
  --modal-bg: #fdfcff;
  --panel-border: rgba(47,160,143,0.35);
  --btn-bg: #2fa08f;
  --btn-text: #fff;
  --input-bg: #fff;
  --input-border: #c3d4d2;
}
body.dark {
  --topbar-grad: linear-gradient(180deg, #0f3f3b, #1c5c52);
  --header-teal: #1c5c52;
  --weekcol-bg: #3a3141;
  --bg-grad: linear-gradient(150deg, #22282e 0%, #2a2833 50%, #33262e 100%);
  --cell-bg: rgba(255,255,255,0.07);
  --cell-other-bg: rgba(0,0,0,0.25);
  --weekend-bg: rgba(210,140,90,0.12);
  --text-main: #dfe8e8;
  --text-dim: #8fa0a1;
  --text-red: #ff6f61;
  --text-green: #6fcf97;
  --chip-color: #7fd0c5;
  --modal-bg: #2a3436;
  --panel-border: rgba(127,208,197,0.35);
  --input-bg: #1e2628;
  --input-border: #3d4d4f;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  color: var(--text-main);
  background: var(--bg-grad);
  overflow: hidden;
}
#app { height: 100vh; display: flex; flex-direction: column; }

/* ---- 顶栏 ---- */
#topbar {
  display: flex; align-items: center; gap: 6px;
  background: var(--topbar-grad);
  color: #fff; padding: 8px 12px; flex: 0 0 auto;
  box-shadow: 0 2px 8px rgba(0,60,55,0.35);
}
#title-text {
  flex: 1; text-align: center; font-size: 17px; font-weight: 600;
  letter-spacing: 1px; text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  cursor: pointer; user-select: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.icon-btn {
  background: rgba(255,255,255,0.14); border: none; color: #fff;
  width: 32px; height: 32px; border-radius: 8px; font-size: 16px;
  cursor: pointer; line-height: 1; flex: 0 0 auto;
  transition: background .15s, transform .1s;
}
.icon-btn:hover { background: rgba(255,255,255,0.28); }
.icon-btn:active { transform: scale(0.94); }
.icon-btn.badge-dot { position: relative; }
#sync-status { font-size: 16px; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; border-radius: 8px; background: rgba(255,255,255,0.14); border: none; color: #fff; }
#sync-status.ok { color: #b8ffe9; }
#sync-status.err { color: #ffb3a8; }
#sync-status.off { opacity: .55; }
#sync-status.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 视图标签栏 ---- */
#view-tabs {
  display: flex; align-items: center; gap: 4px; padding: 6px 12px;
  background: rgba(255,255,255,0.35); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--panel-border); flex: 0 0 auto;
}
body.dark #view-tabs { background: rgba(0,0,0,0.25); }
.tab-btn {
  border: 1px solid transparent; background: transparent; color: var(--text-main);
  padding: 5px 14px; border-radius: 16px; cursor: pointer; font-size: 13px;
}
.tab-btn:hover { background: rgba(47,160,143,0.12); }
.tab-btn.active { background: var(--btn-bg); color: var(--btn-text); box-shadow: 0 2px 6px rgba(47,160,143,0.4); }
#view-label { margin-left: auto; font-size: 14px; font-weight: 600; color: var(--chip-color); }
#btn-today, #btn-new {
  border: none; cursor: pointer; border-radius: 16px; padding: 5px 14px; font-size: 13px;
}
#btn-today { background: rgba(47,160,143,0.18); color: var(--chip-color); }
#btn-new { background: var(--btn-bg); color: #fff; box-shadow: 0 2px 6px rgba(47,160,143,0.4); font-weight: 600; }

/* ---- 月视图 ---- */
#view-container { flex: 1; overflow: auto; padding: 8px 10px 12px; display: flex; flex-direction: column; }
.month-grid-wrap { flex: 1; display: flex; flex-direction: column; min-height: 480px; }
.month-header { display: grid; grid-template-columns: 34px repeat(7, 1fr); gap: 2px; margin-bottom: 2px; }
.month-header .mh {
  background: var(--header-teal); color: #fff; text-align: center;
  padding: 5px 0; font-size: 13px; border-radius: 4px; letter-spacing: 6px; text-indent: 6px;
}
.month-header .mh.we { background: #d98e6a; }
.month-body { flex: 1; display: grid; grid-template-columns: 34px repeat(7, 1fr); grid-auto-rows: 1fr; gap: 2px; min-height: 0; }
.wk-cell {
  background: var(--weekcol-bg); border-radius: 4px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-dim); writing-mode: initial;
}
.day-cell {
  background: var(--cell-bg); border: 2px solid transparent; border-radius: 4px;
  padding: 2px 4px; overflow: hidden; cursor: default; position: relative;
  display: flex; flex-direction: column; min-height: 78px;
  transition: border-color .12s, box-shadow .12s;
}
.day-cell.other { background: var(--cell-other-bg); }
.day-cell.other .solar, .day-cell.other .lunar { opacity: .55; }
.day-cell.weekend { background: var(--weekend-bg); }
.day-cell.today { border-color: var(--today-border); box-shadow: 0 0 10px rgba(245,211,39,0.55); }
.day-cell.selected { border-color: var(--sel-border); }
.day-cell.dragover { border-color: var(--btn-bg); box-shadow: inset 0 0 0 2px var(--btn-bg); }
.cell-head { display: flex; align-items: baseline; gap: 4px; flex: 0 0 auto; }
.solar { font-size: 14px; font-weight: 700; color: var(--text-main); }
.solar.red { color: var(--text-red); }
.lunar { font-size: 11px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lunar.fest { color: var(--text-red); }
.lunar.term { color: var(--text-green); }
.badge {
  margin-left: auto; font-size: 10px; color: #fff; border-radius: 50%;
  width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.badge.rest { background: #27ae60; }
.badge.ban { background: #e74c3c; }
.cell-events { flex: 1; overflow: hidden; margin-top: 1px; }
.ev-chip {
  font-size: 11px; line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer; padding: 0 2px; border-radius: 3px;
}
.ev-chip:hover { background: rgba(47,160,143,0.15); }
.ev-chip .tm { opacity: .7; font-size: 10px; margin-right: 3px; }

/* ---- 周/日视图 ---- */
.timegrid-wrap { flex: 1; overflow: auto; border-radius: 6px; background: var(--cell-bg); }
.timegrid { display: grid; grid-template-columns: 52px repeat(var(--cols,7), 1fr); min-width: 560px; }
.tg-head {
  position: sticky; top: 0; z-index: 3; background: var(--header-teal); color: #fff;
  text-align: center; padding: 6px 2px; font-size: 12px; border: 1px solid rgba(255,255,255,0.15);
}
.tg-head.today-col { background: #d98e6a; }
.tg-head .dh { font-size: 16px; font-weight: 700; }
.tg-hour { font-size: 10px; color: var(--text-dim); text-align: right; padding: 2px 6px 0 0; border-top: 1px solid var(--panel-border); height: 44px; }
.tg-col { flex: 1; position: relative; border-left: 1px solid var(--panel-border); height: 1056px; cursor: pointer; }
.tg-col:hover { background: rgba(47,160,143,0.06); }
.tg-lines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 43px, var(--panel-border) 43px, var(--panel-border) 44px);
}
.tg-ev {
  position: absolute; left: 2px; right: 2px; border-radius: 5px; padding: 3px 6px;
  font-size: 11px; color: #fff; overflow: hidden; cursor: pointer; z-index: 2;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25); border-left: 3px solid rgba(255,255,255,0.6);
}
.tg-ev .t { font-weight: 600; }
.allday-row {
  display: grid; grid-template-columns: 52px repeat(var(--cols,7), 1fr); min-width: 560px;
  border-bottom: 1px solid var(--panel-border);
}
.allday-cell { min-height: 22px; padding: 1px 2px; border-left: 1px solid var(--panel-border); }
.allday-chip { font-size: 10px; color: #fff; background: var(--chip-color); border-radius: 3px; padding: 0 4px; margin-bottom: 1px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- 议程视图 ---- */
.agenda { max-width: 760px; margin: 0 auto; width: 100%; }
.ag-day { margin-bottom: 14px; }
.ag-day-title { font-size: 14px; font-weight: 700; color: var(--chip-color); padding: 4px 8px; background: rgba(47,160,143,0.10); border-radius: 6px; }
.ag-ev {
  display: flex; gap: 10px; align-items: center; background: var(--cell-bg);
  border-left: 4px solid var(--chip-color); border-radius: 6px; padding: 8px 12px; margin: 6px 0;
  cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.ag-time { font-size: 12px; color: var(--text-dim); min-width: 92px; }
.ag-title { font-size: 14px; flex: 1; }
.ag-meta { font-size: 11px; color: var(--text-dim); }

/* ---- 弹窗 ---- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20,40,45,0.45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--modal-bg); border-radius: 14px; padding: 20px 22px;
  width: 100%; max-width: 460px; box-shadow: 0 12px 40px rgba(0,30,40,0.4);
  max-height: 86vh; overflow: auto; border: 1px solid var(--panel-border);
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: scale(.96) translateY(-8px); opacity: 0; } }
.modal h3 { font-size: 16px; margin-bottom: 14px; color: var(--chip-color); }
.form-row { margin-bottom: 10px; }
.form-row label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 4px; }
.form-row input[type=text], .form-row input[type=email], .form-row input[type=password],
.form-row input[type=date], .form-row input[type=time], .form-row select, .form-row textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--input-border); border-radius: 8px;
  background: var(--input-bg); color: var(--text-main); font-size: 13px; outline: none;
}
.form-row textarea { resize: vertical; min-height: 54px; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus { border-color: var(--btn-bg); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check-line { display: flex; align-items: center; gap: 6px; font-size: 13px; margin: 6px 0; }
.remind-box { display: flex; flex-wrap: wrap; gap: 6px; }
.remind-box label {
  display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--text-main);
  border: 1px solid var(--input-border); padding: 3px 8px; border-radius: 12px; cursor: pointer; margin: 0;
}
.remind-box label:has(input:checked) { background: var(--btn-bg); color: #fff; border-color: var(--btn-bg); }
.color-swatches { display: flex; gap: 8px; }
.color-swatches .sw { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; }
.color-swatches .sw.sel { border-color: var(--text-main); transform: scale(1.15); }
.modal-btns { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; }
.btn {
  border: none; border-radius: 8px; padding: 8px 18px; font-size: 13px; cursor: pointer;
  background: var(--btn-bg); color: #fff;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--input-border); }
.btn.danger { background: #e05b4c; }
.btn.warn { background: #e8963c; }

/* ---- 搜索 / 列表 ---- */
.search-input { width: 100%; padding: 9px 12px; font-size: 14px; border: 1px solid var(--input-border); border-radius: 10px; background: var(--input-bg); color: var(--text-main); outline: none; margin-bottom: 10px; }
.result-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; display: flex; gap: 8px; align-items: baseline; }
.result-item:hover { background: rgba(47,160,143,0.12); }
.result-item .rd { color: var(--text-dim); font-size: 11px; flex: 0 0 auto; }
.empty-tip { text-align: center; color: var(--text-dim); font-size: 13px; padding: 30px 0; }

/* ---- 提醒横幅 ---- */
#toast-root { position: fixed; top: 14px; right: 14px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--modal-bg); border-left: 4px solid #e8963c; border-radius: 10px;
  padding: 12px 16px; box-shadow: 0 8px 30px rgba(0,30,40,0.4); min-width: 260px; max-width: 340px;
  animation: slidein .25s ease-out;
}
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }
.toast .t-title { font-weight: 700; font-size: 14px; margin-bottom: 2px; }
.toast .t-body { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }
.toast .t-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.toast .t-btns button { font-size: 11px; padding: 3px 10px; border-radius: 10px; border: 1px solid var(--input-border); background: transparent; color: var(--text-main); cursor: pointer; }
.toast .t-btns button:hover { background: var(--btn-bg); color: #fff; }

/* ---- 菜单下拉 ---- */
#menu-pop {
  position: fixed; z-index: 200; background: var(--modal-bg); border: 1px solid var(--panel-border);
  border-radius: 10px; box-shadow: 0 8px 30px rgba(0,30,40,0.35); padding: 6px; display: none; min-width: 160px;
}
#menu-pop button { display: block; width: 100%; text-align: left; padding: 8px 12px; background: none; border: none; font-size: 13px; color: var(--text-main); cursor: pointer; border-radius: 6px; }
#menu-pop button:hover { background: rgba(47,160,143,0.12); }

@media (max-width: 640px) {
  #title-text { font-size: 14px; }
  .day-cell { min-height: 64px; }
  .lunar { display: none; }
  .day-cell.has-fest .lunar { display: inline; }
  .tab-btn { padding: 5px 9px; }
  #view-label { font-size: 12px; }
}
