* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; overflow: hidden; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  /* 磨砂风格背景：柔和渐变 + 点阵网格 */
  background:
    radial-gradient(1200px 800px at 15% 20%, rgba(147, 197, 253, .35), transparent 60%),
    radial-gradient(1000px 700px at 85% 75%, rgba(196, 181, 253, .30), transparent 60%),
    radial-gradient(900px 600px at 60% 10%, rgba(110, 231, 183, .25), transparent 60%),
    linear-gradient(135deg, #e8eef7 0%, #f3f0fa 100%);
  color: #2d3748;
}

/* 网格点阵，跟随画布平移 */
#viewport {
  position: absolute; inset: 0;
  cursor: grab;
  background-image: radial-gradient(rgba(100, 116, 139, .18) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: 0 0;
}
#viewport:active { cursor: grabbing; }

#world { position: absolute; top: 0; left: 0; will-change: transform; }

/* ===== 组件通用磨砂卡片 ===== */
.widget {
  position: absolute;
  border-radius: 16px;
  background: rgba(255, 255, 255, .45);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, .55);
  box-shadow: 0 8px 32px rgba(31, 38, 135, .12);
  padding: 14px;
  user-select: none;
  touch-action: none;
  transition: box-shadow .15s;
}
.widget:hover { box-shadow: 0 12px 40px rgba(31, 38, 135, .20); }
.widget.dragging { box-shadow: 0 18px 48px rgba(31, 38, 135, .28); opacity: .92; }

.widget-content { pointer-events: auto; user-select: text; }

.widget-close {
  position: absolute; top: 6px; right: 8px;
  width: 20px; height: 20px;
  border: none; border-radius: 50%;
  background: rgba(0,0,0,.08);
  color: #475569;
  font-size: 13px; line-height: 18px;
  cursor: pointer; opacity: .25;
  transition: opacity .15s, background .15s;
}
.widget:hover .widget-close, .widget-close:hover { opacity: 1; }
/* 触屏设备没有 hover：关闭按钮始终可见 */
@media (hover: none) {
  .widget-close { opacity: .6; }
}
.widget-close:hover { background: rgba(239, 68, 68, .25); color: #b91c1c; }

/* ===== 日历 ===== */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-weight: 600; font-size: 15px; }
.cal-nav {
  border: none; background: rgba(0,0,0,.06); border-radius: 6px;
  width: 24px; height: 24px; cursor: pointer; font-size: 14px; color: #475569;
}
.cal-nav:hover { background: rgba(0,0,0,.12); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.cal-week { font-size: 11px; color: #94a3b8; padding: 3px 0; }
.cal-day { font-size: 12px; padding: 2px 0; border-radius: 6px; display: flex; flex-direction: column; align-items: center; line-height: 1.25; }
.cal-solar { font-weight: 600; }
.cal-lunar { font-size: 9.5px; color: #64748b; white-space: nowrap; }
.cal-fest { color: #ef4444; }
.cal-today .cal-lunar { color: rgba(255,255,255,.85); }
.cal-today .cal-fest { color: #fecaca; }
.cal-sub { font-size: 11.5px; color: #64748b; text-align: center; margin-bottom: 6px; }

/* ===== 便签纸 ===== */
.widget-note {
  background: rgba(255, 246, 189, .55);
  border-color: rgba(255, 255, 255, .7);
}
.pin {
  position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  width: 18px; height: 18px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f87171, #b91c1c);
  box-shadow: 0 3px 5px rgba(0,0,0,.3);
}
.note-text {
  width: 100%; height: 110px; resize: none;
  border: none; background: transparent; outline: none;
  font: inherit; font-size: 13px; color: #59420f;
  line-height: 1.6;
}
.note-foot { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.note-remind {
  flex: 1; font-size: 11px; padding: 3px 6px;
  border: 1px solid rgba(0,0,0,.12); border-radius: 6px;
  background: rgba(255,255,255,.5); color: #59420f; outline: none;
}
.note-clear {
  border: none; background: rgba(0,0,0,.08); border-radius: 6px;
  width: 20px; height: 22px; cursor: pointer; color: #59420f;
}
.note-alert {
  margin-top: 6px; font-size: 12px; padding: 5px 8px;
  border-radius: 6px; background: rgba(239, 68, 68, .15); color: #b91c1c;
}
.note-alert-on { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* ===== 天气 ===== */
.weather-city { font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.weather-change {
  border: none; background: rgba(0,0,0,.06); border-radius: 6px;
  width: 22px; height: 22px; cursor: pointer; font-size: 12px;
}
.weather-now { display: flex; align-items: baseline; gap: 10px; margin: 10px 0 6px; }
.weather-temp { font-size: 34px; font-weight: 700; color: #1e293b; }
.weather-desc { font-size: 15px; color: #475569; }
.weather-extra { display: flex; justify-content: space-between; font-size: 12px; color: #64748b; }
.weather-loading, .weather-error { padding: 30px 0; text-align: center; font-size: 13px; color: #64748b; }
.weather-retry {
  border: none; background: rgba(0,0,0,.08); border-radius: 6px;
  padding: 3px 10px; cursor: pointer; margin-left: 6px;
}

/* 便签颜色主题（只作用于便签自身） */
.note-colors { display: flex; gap: 6px; justify-content: center; margin-bottom: 6px; }
.note-dot {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.9); cursor: pointer; padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.3);
}
.note-dot-on { border-color: #1e293b; transform: scale(1.2); box-shadow: 0 0 0 2px rgba(30,41,59,.15); }
.widget-note.note-c-pink { background: rgba(249, 168, 212, .75); }
.widget-note.note-c-blue { background: rgba(147, 197, 253, .75); }
.widget-note.note-c-green { background: rgba(110, 231, 183, .75); }
.widget-note.note-c-purple { background: rgba(196, 154, 250, .75); }
.widget-note.note-c-pink .note-text, .widget-note.note-c-blue .note-text,
.widget-note.note-c-green .note-text, .widget-note.note-c-purple .note-text { color: #3b3630; }

/* ===== AI 运势 ===== */
.fortune-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 8px; }
.fortune-form label { font-size: 12px; color: #475569; display: flex; align-items: center; gap: 4px; }
.fortune-date, .fortune-zodiac {
  font-size: 12px; padding: 3px 6px; border: 1px solid rgba(0,0,0,.12);
  border-radius: 6px; background: rgba(255,255,255,.6); color: #1e293b; outline: none;
}
.fortune-btn {
  border: none; border-radius: 8px; padding: 5px 12px; cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff;
  font-size: 12px; font-weight: 600;
}
.fortune-btn:disabled { opacity: .5; cursor: wait; }
.fortune-body { font-size: 12.5px; line-height: 1.6; color: #334155; user-select: text; }
.fortune-sec { margin-bottom: 7px; }
.fortune-sec b { color: #6366f1; }
.fortune-sec p, .fortune-body > p { margin: 0; }
.fortune-loading, .fortune-empty, .fortune-error { padding: 18px 0; text-align: center; color: #64748b; font-size: 12.5px; }
.fortune-error { color: #b91c1c; }
.fortune-time { margin-top: 8px; font-size: 11px; color: #94a3b8; text-align: right; }

.fortune-key { display: none; margin-bottom: 8px; }
.fortune-key.fortune-key-open { display: block; }
.fortune-key-input {
  width: 100%; font-size: 11px; padding: 4px 6px;
  border: 1px solid rgba(0,0,0,.12); border-radius: 6px;
  background: rgba(255,255,255,.6); outline: none; user-select: text;
}
.fortune-key-save {
  border: none; border-radius: 6px; padding: 3px 10px; margin-top: 4px;
  background: rgba(99, 102, 241, .15); color: #4f46e5; cursor: pointer; font-size: 11px;
}
.fortune-key-hint { font-size: 10px; color: #94a3b8; margin-top: 3px; }
.fortune-key-btn {
  border: none; background: rgba(0,0,0,.06); border-radius: 6px;
  width: 24px; height: 24px; cursor: pointer; font-size: 12px;
}
.fortune-body a { color: #4f46e5; }

/* ===== 右键菜单 ===== */
#context-menu {
  display: none; position: fixed; z-index: 1000;
  min-width: 160px;
  background: rgba(255, 255, 255, .75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 12px;
  box-shadow: 0 10px 36px rgba(31, 38, 135, .22);
  padding: 6px;
}
.menu-header { font-size: 11px; color: #94a3b8; padding: 6px 10px 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px;
  border: none; background: transparent; border-radius: 8px;
  font: inherit; font-size: 13px; color: #334155;
  cursor: pointer; text-align: left;
}
.menu-item:hover { background: rgba(99, 102, 241, .12); }
.menu-icon { width: 18px; height: 18px; color: #6366f1; }
.menu-icon svg { width: 100%; height: 100%; }

/* ===== 提醒 toast ===== */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: rgba(30, 41, 59, .9);
  color: #fff; font-size: 14px;
  padding: 12px 22px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.3);
  z-index: 2000;
  animation: toast-in .3s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
