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

html, body { height: 100%; }

body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: #fff;
  background: #0b1220;
  overflow: hidden;
  user-select: none;
}

/* ---------- 背景层：模糊垫底 + 完整Contain前景 ---------- */
.bg {
  position: fixed;
  inset: 0;
  opacity: 0;
  transition: opacity 1.1s ease;
}
.bg.show { opacity: 1; }

/* 垫底：同一张图放大铺满 + 高斯模糊，四边出血防白边 */
.bg::before {
  content: '';
  position: absolute;
  inset: -48px;
  background-image: var(--img);
  background-size: cover;
  background-position: center;
  filter: blur(30px) brightness(.72) saturate(1.2);
  transform: scale(1.12);
}

/* 前景：完整显示不裁切，缓慢 Ken Burns 呼吸感 */
.bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--img);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
  animation: kenburns 30s ease-in-out infinite alternate;
}
/* 渐变壁纸无「内容区」概念，直接铺满 */
.bg.grad::after { background-size: cover; animation: none; }

@keyframes kenburns {
  from { transform: scale(1) translateY(0); }
  to   { transform: scale(1.055) translateY(-.8%); }
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(to bottom, rgba(0,0,0,.38) 0%, rgba(0,0,0,0) 26%, rgba(0,0,0,0) 62%, rgba(0,0,0,.46) 100%),
    radial-gradient(120% 90% at 50% 50%, rgba(0,0,0,0) 55%, rgba(0,0,0,.28) 100%);
}

/* 中央文字可读性遮罩：浅色壁纸上也看得清时钟 */
.scrim {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(58% 46% at 50% 44%, rgba(0,0,0,.30) 0%, rgba(0,0,0,.13) 48%, rgba(0,0,0,0) 74%);
}

/* ---------- 中央区：分层入场 ---------- */
.center {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding-bottom: 6vh;
}
.center .clock  { animation: rise .8s .05s ease both; }
.center .date-line { animation: rise .8s .2s ease both; }
.center .search { animation: rise .8s .35s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.clock {
  font-size: clamp(72px, 13vw, 150px);
  font-weight: 200;
  letter-spacing: .04em;
  line-height: 1;
  text-shadow: 0 6px 40px rgba(0,0,0,.45);
  font-variant-numeric: tabular-nums;
}
.clock span { display: inline-block; }

/* 冒号呼吸 */
.colon { animation: blink 2s ease-in-out infinite; }
@keyframes blink {
  0%, 100% { opacity: 1; transform: translateY(0); }
  50%      { opacity: .25; transform: translateY(-2%); }
}

/* 翻分钟动效 */
#mm.tick { animation: tick .45s ease; }
@keyframes tick {
  0%   { transform: translateY(10%); opacity: .15; }
  100% { transform: translateY(0);   opacity: 1; }
}

.date-line {
  font-size: 17px;
  font-weight: 400;
  letter-spacing: .12em;
  opacity: .92;
  text-shadow: 0 2px 14px rgba(0,0,0,.5);
}
.date-line .dot { margin: 0 10px; opacity: .6; }

/* ---------- 搜索框 ---------- */
.search {
  margin-top: 26px;
  display: flex;
  align-items: center;
  width: min(580px, 84vw);
  height: 54px;
  padding: 0 8px 0 18px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.22);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: 0 10px 34px rgba(0,0,0,.22);
  transition: background .25s ease, box-shadow .25s ease, transform .25s ease;
}
.search:focus-within {
  background: rgba(255,255,255,.2);
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
  transform: translateY(-2px);
}

.engine {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  outline: none;
  padding-right: 4px;
}
.engine option { color: #111; }

.sep { width: 1px; height: 20px; background: rgba(255,255,255,.3); margin: 0 14px 0 6px; }

#q {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 16px;
  letter-spacing: .02em;
}
#q::placeholder { color: rgba(255,255,255,.65); }

.go {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.go:hover { background: rgba(255,255,255,.3); transform: scale(1.06); }
.go:active { transform: scale(.94); }

/* ---------- 底栏 ---------- */
.meta {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 0 26px 22px;
  animation: rise .9s .55s ease both;
}

.credit { display: flex; flex-direction: column; gap: 5px; max-width: 62vw; }
.brand { font-size: 13px; font-weight: 600; letter-spacing: .08em; opacity: .85; }
.credit-text { font-size: 12px; opacity: .75; text-shadow: 0 1px 8px rgba(0,0,0,.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.actions { display: flex; gap: 10px; }

.act {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.22);
  background: rgba(255,255,255,.13);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .2s ease, transform .15s ease;
}
.act:hover { background: rgba(255,255,255,.28); transform: translateY(-2px); }
.act:active { transform: translateY(0) scale(.94); }
.act.small { width: 34px; height: 34px; background: transparent; border: none; }
.act.faved { color: #ff5f7e; }
.act.faved svg { fill: #ff5f7e; stroke: #ff5f7e; }

/* 换一张：加载中旋转 */
.act.spinning svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 收藏：心跳一跳 */
.act.pop svg { animation: pop .45s ease; }
@keyframes pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.45); }
  70%  { transform: scale(.92); }
  100% { transform: scale(1); }
}

/* ---------- 设置面板 ---------- */
.panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(380px, 92vw);
  background: rgba(14, 18, 28, .72);
  backdrop-filter: blur(28px) saturate(1.3);
  -webkit-backdrop-filter: blur(28px) saturate(1.3);
  border-left: 1px solid rgba(255,255,255,.12);
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform .38s cubic-bezier(.32,.72,.24,1);
  z-index: 10;
}
.panel.open { transform: translateX(0); }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
}
.panel-title { font-size: 17px; font-weight: 600; letter-spacing: .06em; }

.panel-body { flex: 1; overflow-y: auto; padding: 4px 20px 12px; }
.panel-body::-webkit-scrollbar { width: 6px; }
.panel-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }

.panel-body section { margin-bottom: 26px; }
.panel-body h3 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .18em;
  opacity: .6;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.source {
  display: block;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.05);
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease, transform .15s ease;
}
.source:hover { background: rgba(255,255,255,.09); transform: translateX(2px); }
.source:has(input:checked) { border-color: #4ade80; background: rgba(74,222,128,.1); }
.source input { display: none; }
.src-name { display: block; font-size: 14px; font-weight: 600; }
.src-desc { display: block; font-size: 12px; opacity: .6; margin-top: 2px; }

.text-input, .select-input {
  width: 100%;
  margin-top: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.16);
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 13px;
  outline: none;
  transition: border-color .2s ease;
}
.text-input:focus, .select-input:focus { border-color: #4ade80; }
.text-input::placeholder { color: rgba(255,255,255,.4); }
.select-input option { color: #111; }

/* 自定义链接输入区：仅选中对应来源时展开 */
.custom-extra {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height .3s ease, opacity .3s ease;
}
.custom-extra.open { max-height: 80px; opacity: 1; }

.ghost-btn {
  margin-top: 10px;
  width: 100%;
  padding: 11px;
  border-radius: 12px;
  border: 1px dashed rgba(255,255,255,.3);
  background: transparent;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: background .2s ease;
}
.ghost-btn:hover { background: rgba(255,255,255,.08); }
.ghost-btn.danger { color: #ff8a9a; border-color: rgba(255,138,154,.45); }
.ghost-btn.danger:hover { background: rgba(255,138,154,.1); }

/* ---------- 收藏夹 ---------- */
.fav-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.fav-item {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,.12);
  transition: transform .18s ease, box-shadow .18s ease;
}
.fav-item:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.fav-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.fav-del {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  display: none;
  place-items: center;
}
.fav-item:hover .fav-del { display: grid; }
.fav-item.fav-item-gradient { display: grid; place-items: center; font-size: 11px; }

.fav-empty { font-size: 12px; opacity: .5; padding: 8px 0; }

.panel-foot {
  padding: 12px 20px 16px;
  font-size: 11px;
  line-height: 1.9;
  opacity: .55;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 16px);
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(20, 24, 34, .82);
  border: 1px solid rgba(255,255,255,.16);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 13px;
  letter-spacing: .03em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .clock { font-size: clamp(56px, 19vw, 96px); }
  .search { width: 92vw; height: 48px; margin-top: 18px; }
  #q { font-size: 15px; }
  .date-line { font-size: 14px; }
  .credit { max-width: 52vw; }
  .act { width: 40px; height: 40px; }
  .meta { padding: 0 16px 16px; }
  .panel { width: 100vw; }
  .center { gap: 12px; padding-bottom: 4vh; }
}

@media (max-height: 620px) {
  .clock { font-size: clamp(48px, 15vh, 96px); }
  .center { gap: 10px; padding-bottom: 2vh; }
  .search { margin-top: 12px; height: 46px; }
}
