/* 中考倒计时 - Airbnb 浅色风格 */
:root {
  --bg: #ffffff;
  --card-bg: #ffffff;
  --bg-soft: #f7f7f7;
  --bg-soft-2: #fafafa;
  --text: #222222;
  --text-muted: #717171;
  --text-faint: #b0b0b0;
  --border: #ebebeb;
  --border-strong: #dddddd;

  /* Airbnb-style 强调色 */
  --accent: #ff385c;
  --accent-hover: #e11d48;
  --accent-soft: #fff1f4;
  --accent-soft-2: #ffe4ea;

  /* 中考目标 */
  --target: #ff385c;
  --target-soft: #fff1f4;

  /* 今天 */
  --today: #00a699;

  /* 节假日 */
  --holiday-bg: #fff0f0;
  --holiday-text: #c13515;
  --holiday-border: #ffd6d6;

  --past: #c0c0c0;
  --past-bg: #f7f7f7;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 6px 20px rgba(0, 0, 0, 0.08);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Airbnb Cereal", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============ 顶栏 (圆角灰色卡片 + 倒计时红色 bar 在 target-box 内) ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: transparent;
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 16px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

/* target-box:拉通卡片 + 内部红色倒计时 bar */
.target-box {
  position: relative;
  flex: 1;
  min-width: 280px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-soft);
  padding: 12px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  min-height: 48px;
  box-shadow: var(--shadow-sm);
}

/* 倒计时红色 bar:贴在右边,宽度 = 剩余天数占比 */
.target-box::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--progress, 100%);
  background: linear-gradient(90deg, rgba(225, 29, 72, 0.92), rgba(255, 56, 92, 0.92));
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
}

/* target-box 内文字浮在 bar 之上 */
.target-box > * {
  position: relative;
  z-index: 1;
}

.target-box .label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.target-box .value {
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}

/* bar 覆盖时:左侧文字用白色背板提升可读性 */
.target-box .label,
.target-box .value {
  background: rgba(255, 255, 255, 0.88);
  padding: 2px 8px;
  border-radius: 4px;
}

.target-box .countdown {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-left: auto;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.add-btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 12px 22px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, transform 0.1s;
  box-shadow: 0 2px 6px rgba(255, 56, 92, 0.25);
  white-space: nowrap;
}

.add-btn:hover {
  background: var(--accent-hover);
}

.add-btn:active {
  transform: scale(0.97);
}

/* ============ 日历网格 ============ */
.calendar-grid {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 32px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 24px;
}

.month-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.month-card:hover {
  box-shadow: var(--shadow);
}

.month-header {
  background: var(--bg);
  color: var(--text);
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid var(--border);
}

.month-header .month-name {
  font-size: 18px;
  font-weight: 700;
}

.month-header .month-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg-soft-2);
  border-bottom: 1px solid var(--border);
}

.weekday {
  text-align: center;
  padding: 8px 0;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.3px;
}

.weekday.weekend { color: var(--accent); }

.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  background: transparent;
  padding: 8px;
}

.day-cell {
  background: transparent;
  aspect-ratio: 1.2 / 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  padding: 4px 2px;
  border: 0;
  font: inherit;
  color: inherit;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  margin: 1px;
}

.day-cell:hover:not(.past):not(.empty) {
  background: var(--bg-soft);
}

.day-cell .day-num {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.1;
}

.day-cell .day-sub {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  /* 默认隐藏,hover/selected/today 显示 */
  display: none;
  line-height: 1.2;
  white-space: nowrap;
}

.day-cell:hover:not(.past):not(.empty) .day-sub,
.day-cell.selected .day-sub,
.day-cell.today .day-sub {
  display: block;
}

.day-cell.empty {
  cursor: default;
}

.day-cell.past {
  color: var(--past);
  cursor: not-allowed;
}

.day-cell.past .day-num { color: var(--past); }
.day-cell.past:hover { background: transparent; }

.day-cell.weekend:not(.past) .day-num { color: var(--accent); }

/* 今天 */
.day-cell.today {
  background: var(--accent-soft);
  font-weight: 600;
}

.day-cell.today .day-num {
  color: var(--accent);
  font-weight: 700;
}

.day-cell.today .day-sub {
  color: var(--accent);
  font-weight: 600;
}

/* 中考目标日 */
.day-cell.target {
  background: var(--target-soft);
}

.day-cell.target .day-num {
  color: var(--target);
  font-weight: 800;
  font-size: 15px;
}

.day-cell.target .day-sub {
  color: var(--target);
  font-weight: 600;
}

.day-cell.target::after {
  content: "中考";
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 9px;
  background: var(--target);
  color: #fff;
  padding: 1px 5px;
  border-radius: 999px;
  line-height: 1.3;
  font-weight: 600;
}

/* 节假日(浅红色) */
.day-cell.holiday:not(.target) {
  background: var(--holiday-bg);
}

.day-cell.holiday:not(.target) .day-num {
  color: var(--holiday-text);
  font-weight: 600;
}

.day-cell.holiday:not(.target) .day-sub {
  color: var(--holiday-text);
}

.day-cell.holiday::before {
  content: attr(data-holiday);
  position: absolute;
  top: 4px;
  left: 4px;
  font-size: 9px;
  color: var(--holiday-text);
  font-weight: 600;
  letter-spacing: 0.2px;
}

.day-cell.holiday.past {
  background: var(--bg-soft);
}

.day-cell.holiday.past::before {
  color: var(--past);
}

/* 选中态 */
.day-cell.selected:not(.today):not(.target):not(.past) {
  background: var(--accent-soft-2);
}

.day-cell.selected:not(.today):not(.target):not(.past) .day-num {
  color: var(--accent);
  font-weight: 700;
}

.day-cell.selected:not(.today):not(.target):not(.past) .day-sub {
  color: var(--accent);
  font-weight: 600;
}

.event-dot {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
}

.event-dot.more::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 0;
  width: 4px;
  height: 4px;
  background: var(--accent);
  border-radius: 50%;
}

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: maskIn 0.2s ease-out;
}

/* 关键: hidden 属性要优先于上面的 display: flex */
.modal-mask[hidden] { display: none; }

@keyframes maskIn {
  from { background: rgba(0, 0, 0, 0); }
  to { background: rgba(0, 0, 0, 0.4); }
}

.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

.close-btn {
  background: var(--bg-soft);
  border: 0;
  font-size: 18px;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.close-btn:hover { background: var(--border); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.field > span {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.field input,
.field textarea {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--text);
  background: var(--bg);
}

.field input:focus,
.field textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea { resize: vertical; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.btn-primary,
.btn-secondary {
  border: 0;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

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

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.97); }

.btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.btn-secondary:hover { background: var(--bg-soft); }

/* 倒计时内容 */
.countdown-display {
  text-align: center;
  padding: 16px 0 8px;
}

.countdown-display .big {
  font-size: 56px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  letter-spacing: -1px;
}

.countdown-display .unit {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 500;
}

.countdown-display .unit strong {
  color: var(--text);
  font-weight: 700;
  margin: 0 2px;
}

.countdown-display .sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 14px;
}

.countdown-display .pass .big { color: var(--past); }

.day-events {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.day-events h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

.day-events .add-link {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.day-events .add-link:hover { color: var(--accent-hover); }

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.event-list li {
  padding: 12px 14px;
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  position: relative;
  padding-right: 36px;
}

.event-list li .event-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.event-list li .event-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: pre-wrap;
  word-break: break-word;
}

.event-list li .delete-btn {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 50%;
  line-height: 1;
}

.event-list li .delete-btn:hover { color: var(--accent); background: var(--accent-soft); }

.event-list .empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 20px 0;
  background: none;
}

/* 响应式 */
@media (max-width: 768px) {
  .topbar-inner { padding: 14px 16px; gap: 12px; }
  .brand { font-size: 17px; }
  .target-box { margin-left: 0; width: 100%; justify-content: space-between; }
  .calendar-grid { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
  .day-cell { aspect-ratio: 1.1 / 1; }
  .day-cell .day-num { font-size: 13px; }
}
