:root {
  --glass: rgba(18, 22, 32, 0.55);
  --glass-strong: rgba(14, 18, 26, 0.82);
  --line: rgba(255, 255, 255, 0.14);
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.68);
  --accent: #4c8dff;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

/* hidden 属性必须压过下面的 display 规则，否则遮罩会一直挡在页面上 */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  overflow-x: hidden;
  background: #0b1220;
}

/* ---------- 背景 ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-size: cover;
  background-position: center;
  transition: background-image .4s ease, background-color .4s ease;
}

.wallpaper-aurora .bg {
  background-image:
    radial-gradient(1200px 700px at 15% 10%, #2b5876 0%, transparent 60%),
    radial-gradient(900px 600px at 85% 20%, #4e4376 0%, transparent 55%),
    radial-gradient(900px 700px at 50% 100%, #1c3b52 0%, transparent 60%),
    linear-gradient(160deg, #0f2027 0%, #203a43 45%, #2c5364 100%);
}

.wallpaper-sunset .bg {
  background-image:
    radial-gradient(900px 600px at 20% 15%, #ff9a6b 0%, transparent 55%),
    radial-gradient(1000px 700px at 80% 25%, #ff5f6d 0%, transparent 55%),
    linear-gradient(160deg, #2b1055 0%, #7597de 40%, #ff8a5c 100%);
}

.wallpaper-forest .bg {
  background-image:
    radial-gradient(900px 600px at 25% 20%, #2f7336 0%, transparent 55%),
    radial-gradient(1100px 800px at 80% 80%, #14532d 0%, transparent 60%),
    linear-gradient(150deg, #0b1d16 0%, #1d3b2a 50%, #26543a 100%);
}

.wallpaper-ink .bg {
  background-image:
    radial-gradient(1000px 700px at 50% 0%, #2b2b33 0%, transparent 60%),
    linear-gradient(180deg, #0a0a0c 0%, #141418 100%);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.28) 0%, rgba(0,0,0,.06) 35%, rgba(0,0,0,.5) 100%);
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  gap: 12px;
}

.clock {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  text-shadow: 0 2px 12px rgba(0,0,0,.45);
}

.clock-time { font-size: 26px; font-weight: 600; letter-spacing: .5px; }
.clock-date { font-size: 12px; color: var(--muted); }

.actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(14px);
  transition: background .15s, border-color .15s, transform .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.22); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.small { width: 30px; height: 30px; font-size: 13px; background: transparent; }
body[data-editing="1"] #btnEdit { background: var(--accent); }

.sync {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  color: rgba(255,255,255,.85);
  backdrop-filter: blur(14px);
  white-space: nowrap;
}
.sync[data-state="ok"] { background: rgba(46, 160, 67, .35); }
.sync[data-state="busy"] { background: rgba(255, 196, 0, .3); }
.sync[data-state="err"] { background: rgba(220, 53, 69, .38); }

/* ---------- 主区 ---------- */
.stage {
  max-width: 780px;
  margin: 0 auto;
  padding: 4vh 20px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  min-height: calc(100vh - 80px);
}

.search {
  width: 100%;
  max-width: 640px;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 54px;
  padding: 0 8px 0 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.18);
  border: 1px solid rgba(255,255,255,.28);
  backdrop-filter: blur(20px) saturate(1.2);
  box-shadow: 0 8px 30px rgba(0,0,0,.22);
  transition: background .2s, border-color .2s;
}
.search:focus-within { background: rgba(255,255,255,.26); border-color: rgba(255,255,255,.5); }

.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font-size: 16px;
}
.search input::placeholder { color: rgba(255,255,255,.66); }
.search input::-webkit-search-cancel-button { filter: invert(1); opacity: .6; }

.engine, .go {
  flex: none;
  border: 0;
  cursor: pointer;
  color: #fff;
  background: rgba(255,255,255,.14);
  border-radius: 999px;
  height: 42px;
  display: grid;
  place-items: center;
}
.engine { padding: 0 14px; font-size: 13px; letter-spacing: .3px; }
.engine:hover, .go:hover { background: rgba(255,255,255,.26); }
.go { width: 42px; }
.go svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* ---------- 快捷方式网格 ---------- */
.grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px 8px;
  align-content: start;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  transition: background .15s, transform .15s;
}
.tile:hover { background: rgba(255,255,255,.14); }
.tile:active { transform: scale(.97); }
.tile.dragging { opacity: .4; }
.tile.drop-target { background: rgba(76, 141, 255, .35); outline: 1px dashed rgba(255,255,255,.6); }

.tile-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.92);
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  overflow: hidden;
}
.tile-icon img { width: 100%; height: 100%; object-fit: contain; padding: 5px; }
.tile-icon .letter {
  font-size: 20px; font-weight: 700; color: #fff;
  display: none;
  width: 100%; height: 100%;
  place-items: center;
  background: linear-gradient(135deg, #4c8dff, #7c5cff);
}
.tile-icon.noimg img { display: none; }
.tile-icon.noimg .letter { display: grid; }

.tile-title {
  max-width: 100%;
  font-size: 12.5px;
  line-height: 1.3;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,.5);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-all;
}

/* 文件夹磁贴 */
.folder-preview {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  padding: 5px;
  background: rgba(255,255,255,.24);
  border: 1px solid rgba(255,255,255,.3);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  overflow: hidden;
}
.folder-preview span {
  border-radius: 3px;
  background: rgba(255,255,255,.9);
  display: grid; place-items: center;
  overflow: hidden;
  font-size: 8px;
  color: #333;
}
.folder-preview img { width: 100%; height: 100%; object-fit: contain; }

.tile-del {
  position: absolute;
  top: 0; right: -2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 0;
  background: #e5484d;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: none;
  place-items: center;
}
body[data-editing="1"] .tile-del { display: grid; }

.tile-add .tile-icon {
  background: rgba(255,255,255,.1);
  border: 1px dashed rgba(255,255,255,.5);
  box-shadow: none;
  font-size: 26px;
  color: #fff;
  font-weight: 300;
}

.hint {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

/* ---------- 抽屉 ---------- */
.drawer {
  position: fixed;
  top: 0; right: 0;
  width: min(380px, 92vw);
  height: 100%;
  z-index: 60;
  background: var(--glass-strong);
  backdrop-filter: blur(24px) saturate(1.2);
  border-left: 1px solid var(--line);
  transform: translateX(102%);
  transition: transform .28s cubic-bezier(.22,.61,.36,1);
  display: flex;
  flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-mask {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0,0,0,.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 10px;
  font-size: 15px;
}
.drawer-body { padding: 4px 18px 30px; overflow-y: auto; }

.field { padding: 14px 0; border-top: 1px solid var(--line); }
.field:first-child { border-top: 0; }
.label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; letter-spacing: .4px; }

.swatches { display: flex; gap: 8px; margin-bottom: 10px; }
.sw {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  background-size: cover;
}
.sw.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(76,141,255,.7); }
.sw-aurora { background: linear-gradient(160deg, #0f2027, #2c5364); }
.sw-sunset { background: linear-gradient(160deg, #2b1055, #ff8a5c); }
.sw-forest { background: linear-gradient(160deg, #0b1d16, #26543a); }
.sw-ink { background: linear-gradient(160deg, #0a0a0c, #2b2b33); }

.row { display: flex; gap: 8px; align-items: center; }
.row input[type="url"], .row input[type="text"], .row input[type="email"], .row input[type="password"] {
  flex: 1; min-width: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.08);
  color: #fff;
  font-size: 13px;
  outline: 0;
}
.row input:focus { border-color: rgba(76,141,255,.8); }

.btn {
  height: 38px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: rgba(255,255,255,.1); border-color: var(--line); }
.btn.block { width: 100%; }

.segmented {
  display: flex;
  background: rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--line);
}
.segmented button {
  flex: 1;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.segmented button.active { background: rgba(255,255,255,.2); color: #fff; }

.check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: rgba(255,255,255,.86);
  padding: 6px 0;
  cursor: pointer;
}
.check input { accent-color: var(--accent); width: 15px; height: 15px; }

.account { font-size: 13px; color: var(--muted); line-height: 1.6; }
.account .who { color: #fff; font-size: 13.5px; margin-bottom: 8px; }
.account .form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.account .form input { height: 38px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255,255,255,.08); color: #fff; outline: 0; font-size: 13px; }
.account .form .two { display: flex; gap: 8px; }
.account .form .two .btn { flex: 1; }
.tip { font-size: 11.5px; color: var(--muted); margin-top: 8px; line-height: 1.5; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.45);
  display: grid; place-items: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal {
  width: min(380px, 100%);
  max-height: 62vh;
  overflow-y: auto;
  background: var(--glass-strong);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
}
.modal h3 { margin: 0 0 10px; font-size: 14px; font-weight: 600; }
.modal .field { border-top: 0; padding: 0 0 12px; }
.modal .field input[type="text"], .modal .field input[type="url"], .modal .field select {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--line); background: rgba(255,255,255,.08); color: #fff;
  font-size: 13px; outline: 0;
}
.modal .field select option { background: #1b2029; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.modal-actions .del { margin-right: auto; background: #e5484d; }

.folder-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.folder-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 7px;
  border-radius: 8px;
  cursor: pointer;
}
.folder-item:hover { background: rgba(255,255,255,.1); }
.folder-item img { width: 20px; height: 20px; object-fit: contain; background: #fff; border-radius: 5px; padding: 2px; }
.folder-item .nm { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item .x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; }
.folder-item .x:hover { color: #ff6b6b; }
.folder-empty { font-size: 12.5px; color: var(--muted); padding: 8px 2px 12px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 90;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(20,24,32,.92);
  border: 1px solid var(--line);
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toastIn .2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 560px) {
  .topbar { padding: 14px 16px; }
  .clock-time { font-size: 22px; }
  .stage { padding-top: 3vh; gap: 20px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px 4px; }
  .tile-icon, .folder-preview { width: 42px; height: 42px; }
}
