/* Jerry 日历 — 双主题 / 全设备适配 */
:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #1e293b;
  --text-2: #64748b;
  --text-3: #94a3b8;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-2: #3b82f6;
  --brand-soft: rgba(37, 99, 235, 0.10);
  --danger: #ef4444;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 14px;
}
html.dark {
  --bg: #0b1220;
  --panel: #111a2c;
  --panel-2: #16213a;
  --text: #e2e8f0;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --line: #243049;
  --brand: #3b82f6;
  --brand-2: #60a5fa;
  --brand-soft: rgba(96, 165, 250, 0.14);
  --danger: #f87171;
  --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .25s, color .25s;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px clamp(14px, 4vw, 28px);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo { display: inline-flex; }
.brand h1 { font-size: 18px; margin: 0; font-weight: 700; letter-spacing: .5px; }
.top-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text-2); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, transform .1s;
}
.icon-btn:hover { background: var(--brand-soft); color: var(--brand); }
.icon-btn:active { transform: scale(.94); }
.text-btn {
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text-2); cursor: pointer; font-size: 14px;
  transition: background .15s, color .15s;
}
.text-btn:hover { background: var(--brand-soft); color: var(--brand); }
html.dark .ic-moon { display: block; }
html:not(.dark) .ic-moon { display: block; }

/* ---------- 布局 ---------- */
.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  padding: 18px clamp(12px, 3vw, 28px);
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}
.cal-panel, .day-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- 月视图 ---------- */
.cal-panel { padding: clamp(12px, 2.5vw, 22px); }
.cal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.cal-nav { display: flex; gap: 6px; }
.cal-title { margin: 0; font-size: clamp(18px, 3vw, 24px); font-weight: 700; flex: 1; text-align: center; }
.cal-spacer { width: 96px; }
@media (max-width: 560px) { .cal-spacer { width: 0; } }

.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-hint { font-size: 12px; color: var(--text-3); margin: 12px 0 0; word-break: break-all; }
.cal-week span { text-align: center; font-size: 12.5px; color: var(--text-3); padding: 6px 0; font-weight: 600; }
.cal-week span.weekend { color: var(--danger); opacity: .75; }

.cal-grid { min-height: 0; min-width: 0; }
.day {
  position: relative;
  min-width: 0;
  aspect-ratio: 1 / 0.92;
  border-radius: 11px;
  border: 1px solid transparent;
  background: var(--panel-2);
  padding: 6px 7px;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  transition: border-color .12s, background .12s, transform .08s;
  overflow: hidden;
  user-select: none;
}
.day:hover { border-color: var(--brand-2); }
.day:active { transform: scale(.97); }
.day .num { font-size: clamp(13px, 1.6vw, 15px); font-weight: 600; line-height: 1; }
.day.out { opacity: .32; }
.day.weekend .num { color: var(--danger); }
.day.today {
  background: var(--brand-soft);
  border-color: var(--brand);
}
.day.today .num {
  background: var(--brand); color: #fff;
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
}
.day.selected { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.day .evs { display: flex; flex-direction: column; gap: 2px; margin-top: auto; }
.day .ev {
  font-size: 10.5px; line-height: 1.35; padding: 1.5px 5px;
  border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: #fff;
}
.day .more { font-size: 10.5px; color: var(--text-3); padding-left: 4px; }
.day .fest { font-size: 10px; color: var(--brand-2); line-height: 1.2; }

/* ---------- 侧栏 ---------- */
.day-panel { padding: 18px; position: sticky; top: 76px; }
.day-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.day-head h3 { margin: 0; font-size: 18px; }
.day-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--text-3); }
.event-list { display: flex; flex-direction: column; gap: 8px; max-height: 46vh; overflow-y: auto; min-height: 60px; }
.event-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.event-item .bar { width: 4px; align-self: stretch; border-radius: 2px; flex: none; }
.event-item .info { flex: 1; min-width: 0; }
.event-item .t { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-item .meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.event-item .del {
  border: none; background: none; color: var(--text-3); cursor: pointer;
  width: 28px; height: 28px; border-radius: 8px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
}
.event-item .del:hover { color: var(--danger); background: rgba(239, 68, 68, .1); }
.empty-tip { color: var(--text-3); font-size: 13px; text-align: center; padding: 18px 0; }

.event-form { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.event-form input[type="text"] {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font-size: 14px; outline: none;
}
.event-form input[type="text"]:focus { border-color: var(--brand); }
.form-row { display: flex; align-items: center; gap: 10px; }
.event-form input[type="time"] {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-size: 13.5px; outline: none;
}
.color-pick { display: flex; gap: 7px; }
.color-pick button {
  width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer;
  transition: transform .1s;
}
.color-pick button.on { border-color: var(--text); transform: scale(1.15); }
.primary-btn {
  flex: 1; padding: 11px; border: none; border-radius: 10px; cursor: pointer;
  background: linear-gradient(135deg, var(--brand-2), var(--brand));
  color: #fff; font-size: 14.5px; font-weight: 600;
  transition: opacity .15s, transform .08s;
}
.primary-btn:hover { opacity: .92; }
.primary-btn:active { transform: scale(.98); }

/* ---------- 页脚 / 杂项 ---------- */
.foot {
  text-align: center; padding: 16px; font-size: 12.5px; color: var(--text-3);
}
.foot a { color: var(--text-3); text-decoration: none; }
.foot a:hover { color: var(--brand); }
.foot .dot { margin: 0 6px; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg);
  padding: 9px 18px; border-radius: 20px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 99;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 移动端 / 窄屏 ---------- */
.only-mobile { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .day-panel { position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    border-radius: 18px 18px 0 0; max-height: 72vh; overflow-y: auto;
    transform: translateY(105%); transition: transform .25s ease; z-index: 50;
    padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .day-panel.open { transform: translateY(0); }
  .only-mobile { display: inline-flex; }
  .event-list { max-height: 34vh; }
}
@media (max-width: 480px) {
  .day { padding: 4px 4px; border-radius: 8px; }
  .day .ev { font-size: 9.5px; padding: 1px 4px; }
  .day .num { font-size: 12.5px; }
  .day.today .num { width: 22px; height: 22px; }
}
/* 横屏矮屏 */
@media (max-height: 560px) and (orientation: landscape) {
  .day-panel { position: static; transform: none; max-height: none; }
  .event-list { max-height: 24vh; }
}
