:root {
  --bg-grad: linear-gradient(135deg, #ffffff 0%, #ffffff 50%, #ffffff 100%);
  --surface: rgba(255, 255, 255, 0.96);
  --surface-strong: #ffffff;
  --text: #1c1c1e;
  --text-soft: #8e8e93;
  --line: rgba(60, 60, 67, 0.10);
  --accent: #007aff;
  --accent-soft: #eaf3ff;
  --star: #ff9500;
  --radius: 18px;
  --shadow: 0 10px 34px rgba(15, 23, 42, 0.08);
  --gap: 14px;
}

* { box-sizing: border-box; }

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

/* 背景层：默认白色渐变，支持自定义背景图 */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg-grad);
  background-size: cover;
  background-position: center;
  transition: background-image 0.6s ease, background-size 0.6s ease;
}
/* 默认无遮罩；有自定义背景图时 JS 加 .has-image 才启用暗化 */
.bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.18) 0%, rgba(15, 23, 42, 0.30) 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.bg-overlay.has-image { opacity: 1; }
/* 有背景图时这些文字转白，保证可读 */
body.has-bg .section-title { color: #fff; text-shadow: 0 1px 8px rgba(0,0,0,.4); }
body.has-bg .brand-name { color: #fff; }
body.has-bg .brand-slogan { color: rgba(255,255,255,.85); }

.view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  min-height: 100dvh;
}
.hidden { display: none !important; }

/* 品牌 */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-size: 22px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.4);
  flex-shrink: 0;
}
.brand-logo.small { width: 38px; height: 38px; font-size: 17px; border-radius: 11px; }
/* 图片版 logo */
.brand-logo-img { width: 150px; height: auto; max-height: 120px; object-fit: contain; }
.brand-mark-img { width: 42px; height: 42px; object-fit: contain; flex-shrink: 0; }
.brand-mark-img.small { width: 34px; height: 34px; }
.ai-fab-icon { width: 34px; height: 34px; object-fit: contain; }
.brand-name { margin: 0; font-size: 20px; font-weight: 700; color: #fff; }
.brand-name.small { font-size: 15px; }
.brand-slogan { margin: 2px 0 0; font-size: 12px; color: rgba(255, 255, 255, 0.78); }
.brand-slogan.small { font-size: 11px; }

/* 登录卡片 */
.auth-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  border-radius: 22px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.5s ease both;
}
.auth-tabs {
  display: flex;
  gap: 8px;
  margin: 20px 0 16px;
  background: rgba(15, 23, 42, 0.06);
  border-radius: 12px;
  padding: 4px;
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 0;
  border-radius: 9px;
  font-size: 14px;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.25s ease;
}
.auth-tab.active {
  background: var(--surface-strong);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.1);
}
.auth-hint {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-soft);
}
.auth-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 13px;
}

/* 表单 */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
input[type="text"], input[type="email"], input[type="password"], input[type="file"], select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
}
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14);
}
.row { display: flex; gap: 10px; align-items: center; }
.row input { flex: 1; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--text-soft); }

/* 按钮 */
.btn {
  border: none;
  border-radius: 11px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, opacity 0.2s ease;
  white-space: nowrap;
  font-family: inherit;
}
.btn:active { transform: scale(0.96); }
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.32);
}
.btn-primary:hover { background: #4338ca; }
.btn-ghost {
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: #fff; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* 顶栏 */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  color: #fff;
}
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.topbar .btn-ghost { background: rgba(255, 255, 255, 0.18); color: #fff; border-color: rgba(255, 255, 255, 0.35); }
.topbar .btn-ghost:hover { background: rgba(255, 255, 255, 0.28); }

/* 标签页 */
.tabs {
  display: flex;
  gap: 6px;
  padding: 0 18px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.85);
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s ease;
}
.tab.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
}

/* 内容区 */
.content { padding: 20px 18px 40px; }
.panel { animation: fadeUp 0.4s ease both; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.section-title {
  margin: 0 0 14px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}
.panel-head .section-title { margin-bottom: 0; }

/* 卡片网格 */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--gap);
}
.card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
  cursor: pointer;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  animation: fadeUp 0.4s ease both;
  position: relative;
}
.card:hover { transform: translateY(-5px); box-shadow: 0 16px 34px rgba(15, 23, 42, 0.12); }
.card:active { transform: scale(0.97); }
.card-icon {
  width: fit-content; height: fit-content;
  min-width: 46px; min-height: 46px;
  padding: 7px 8px;
  border-radius: 15px;
  margin: 0 auto 9px;
  background: var(--accent-soft);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.card-icon:hover { transform: scale(1.06); }
.card-icon:active { transform: scale(.95); }
.card-icon img { width: 30px; height: 30px; object-fit: contain; display: block; }
.card-icon .fallback {
  font-size: 20px; font-weight: 700; color: var(--accent);
}
.card-title {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.card-group {
  font-size: 11px;
  color: var(--text-soft);
  margin-top: 4px;
}
.card-star {
  position: absolute;
  top: 8px; right: 8px;
  font-size: 14px;
  cursor: pointer;
  opacity: 0.25;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.card-star.on { opacity: 1; }
.card-star:hover { transform: scale(1.25); }
.card.is-star { box-shadow: 0 6px 18px rgba(245, 158, 11, 0.35); }
.card-manage {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 9px;
}
.mini {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  color: var(--text-soft);
  border-radius: 8px;
  font-size: 11px;
  padding: 4px 9px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s ease;
}
.mini:hover { color: var(--accent); border-color: var(--accent); }
.mini.danger:hover { color: #b91c1c; border-color: #b91c1c; }

/* 内联表单 */
.inline-form {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  animation: fadeUp 0.3s ease both;
}
.inline-form input, .inline-form select, .inline-form textarea { margin-bottom: 10px; }
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
  outline: none;
  resize: vertical;
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.14); }

/* 笔记 */
.notes-list { display: flex; flex-direction: column; gap: 12px; }
.note-card {
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
  animation: fadeUp 0.35s ease both;
  transition: transform 0.2s ease;
}
.note-card:hover { transform: translateY(-2px); }
.note-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.note-title { font-size: 15px; font-weight: 700; margin: 0; }
.note-meta { font-size: 11px; color: var(--text-soft); }
.note-content {
  margin: 8px 0 0;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: #374151;
  max-height: 96px;
  overflow: hidden;
}
.note-actions { display: flex; gap: 8px; margin-top: 10px; }

.empty {
  margin: 20px 0;
  text-align: center;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
}

/* 开关 */
.switch-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}
.switch {
  appearance: none;
  width: 46px; height: 26px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.25);
  position: relative;
  cursor: pointer;
  transition: background 0.25s ease;
  flex-shrink: 0;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.25s ease;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
}
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(20px); }

/* 提示条 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  padding: 11px 20px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 99;
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease both;
  max-width: 86vw;
  text-align: center;
}

/* 动画 */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@media (min-width: 720px) {
  .content { padding: 24px 32px 56px; }
  .topbar { padding: 18px 32px; }
  .tabs { padding: 0 32px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px; }
  .auth-view { padding: 40px 20px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ===== 公告滚动条 ===== */
.announce-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 20px; background: rgba(255,255,255,.82);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  color: var(--text-soft); font-size: 13px; overflow: hidden;
  border-bottom: 1px solid var(--line);
}
body.has-bg .announce-bar { background: rgba(255,255,255,.16); color: #fff; border-bottom-color: rgba(255,255,255,.25); }
.announce-icon { flex: 0 0 auto; font-size: 15px; }
.announce-track { flex: 1; overflow: hidden; white-space: nowrap; min-width: 0; }
.announce-text { display: inline-block; padding-left: 100%; animation: announceScroll 26s linear infinite; }
@keyframes announceScroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* ===== 工作台组件 ===== */
.widget-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 16px; margin-bottom: 24px; }
.widget {
  background: rgba(255,255,255,.82); border-radius: 18px; padding: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.08); backdrop-filter: blur(10px);
  min-height: 150px; display: flex; flex-direction: column;
}
.widget-title { font-size: 13px; font-weight: 700; color: #6b7280; margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.widget-edit { margin-left: auto; border: none; background: none; cursor: pointer; font-size: 15px; color: #6b7280; }
.widget-edit:hover { color: #4f46e5; }
.widget-hint { margin-left: auto; font-size: 11px; font-weight: 400; color: #9ca3af; }
.widget-body { flex: 1; font-size: 14px; color: #1f2937; line-height: 1.6; }
.weather-main { font-size: 30px; font-weight: 700; color: #1f2937; }
.weather-desc { font-size: 13px; color: #6b7280; }
.weather-meta { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.weather-top { display: flex; align-items: center; gap: 14px; }
.weather-icon-lg { width: 54px; height: 54px; flex: 0 0 54px; }
.weather-icon-lg svg { width: 100%; height: 100%; }
.weather-hourly { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 12px; padding-top: 10px; border-top: 1px solid rgba(60,60,67,.08); }
.hour-item { text-align: center; font-size: 11px; color: #6b7280; }
.hour-time { color: #9ca3af; font-size: 10.5px; }
.hour-icon { width: 26px; height: 26px; margin: 2px auto; }
.hour-icon svg { width: 100%; height: 100%; }
.hour-temp { color: #1f2937; font-weight: 600; font-size: 12px; }
.hour-pop { color: #5ac8fa; font-size: 9.5px; min-height: 12px; }
.calendar-body { font-size: 12px; }
.cal-title { text-align: center; font-weight: 700; margin-bottom: 8px; font-size: 13px; }
.cal-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; text-align: center; }
.cal-cell { padding: 3px 0; border-radius: 6px; }
.cal-head { color: #9ca3af; font-size: 11px; }
.cal-today { background: #4f46e5; color: #fff; font-weight: 700; }
.quote-body { display: flex; flex-direction: column; justify-content: center; font-style: italic; }
.quote-text { font-size: 14px; color: #374151; }
.quote-author { margin-top: 8px; font-size: 12px; color: #9ca3af; text-align: right; }

/* ===== AI 助手浮窗：3D 立体悬浮 ===== */
.ai-fab {
  position: fixed; right: 24px; bottom: 24px; width: 64px; height: 64px;
  border: none; border-radius: 50%; cursor: pointer; z-index: 60;
  background: transparent;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  transform-style: preserve-3d;
  perspective: 600px;
  animation: fabFloat 3.6s ease-in-out infinite;
  transition: filter .25s ease;
}
/* 底部投影（独立层，随悬浮呼吸） */
.ai-fab::before {
  content: "";
  position: absolute; bottom: -10px; left: 50%;
  width: 46px; height: 12px;
  transform: translateX(-50%) rotateX(72deg);
  background: radial-gradient(ellipse, rgba(0,122,255,.45), transparent 70%);
  filter: blur(3px);
  animation: fabShadow 3.6s ease-in-out infinite;
}
/* 3D 球体本体：苹果蓝渐变 + 内高光 + 外发光 */
.ai-fab-icon {
  position: relative;
  width: 62px; height: 62px;
  border-radius: 50%;
  object-fit: contain;
  padding: 8px;
  background:
    radial-gradient(circle at 32% 26%, rgba(255,255,255,.92) 0%, rgba(255,255,255,.18) 26%, transparent 50%),
    linear-gradient(145deg, #6fb4ff 0%, #007aff 48%, #0056cc 100%);
  box-shadow:
    inset 0 3px 6px rgba(255,255,255,.65),
    inset 0 -6px 12px rgba(0,40,120,.45),
    0 10px 22px rgba(0,122,255,.45),
    0 0 0 1px rgba(255,255,255,.35);
  transform: translateZ(18px) rotateX(8deg) rotateY(-10deg);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), box-shadow .35s ease;
  will-change: transform;
}
/* 顶部高光点 */
.ai-fab-icon::after {
  content: "";
  position: absolute; top: 7px; left: 12px;
  width: 20px; height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,.55);
  filter: blur(2px);
  pointer-events: none;
}
.ai-fab:hover .ai-fab-icon {
  transform: translateZ(26px) rotateX(0) rotateY(0) scale(1.12);
  box-shadow:
    inset 0 3px 6px rgba(255,255,255,.7),
    inset 0 -6px 12px rgba(0,40,120,.42),
    0 18px 34px rgba(0,122,255,.55),
    0 0 24px rgba(111,180,255,.5),
    0 0 0 1px rgba(255,255,255,.5);
}
.ai-fab:active .ai-fab-icon { transform: translateZ(8px) scale(.96); }
@keyframes fabFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-9px) rotate(2deg); }
}
@keyframes fabShadow {
  0%, 100% { transform: translateX(-50%) rotateX(72deg) scale(1); opacity: .55; }
  50% { transform: translateX(-50%) rotateX(72deg) scale(.8); opacity: .32; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-fab, .ai-fab::before { animation: none; }
}
.ai-panel {
  position: fixed; right: 20px; bottom: 92px; width: 360px; max-width: calc(100vw - 32px);
  height: 520px; max-height: calc(100vh - 120px); z-index: 61;
  background: rgba(255,255,255,.97); border-radius: 20px; overflow: hidden;
  box-shadow: 0 18px 50px rgba(0,0,0,.25); display: flex; flex-direction: column;
  animation: fadeUp .25s ease;
}
.ai-panel-head {
  padding: 16px 18px; background: linear-gradient(135deg,#4f46e5,#7c3aed); color: #fff;
  display: flex; justify-content: space-between; align-items: center;
}
.ai-panel-name { font-weight: 700; font-size: 16px; }
.ai-panel-sub { font-size: 11px; opacity: .85; margin-top: 2px; }
.ai-close { border: none; background: rgba(255,255,255,.2); color: #fff; width: 28px; height: 28px; border-radius: 50%; cursor: pointer; font-size: 20px; line-height: 1; }
.ai-close:hover { background: rgba(255,255,255,.32); }
.ai-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-msg { max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.ai-msg.user { align-self: flex-end; background: #4f46e5; color: #fff; border-bottom-right-radius: 4px; }
.ai-msg.assistant { align-self: flex-start; background: #f3f4f6; color: #1f2937; border-bottom-left-radius: 4px; }
.ai-msg.assistant.degraded { background: #fef3c7; }
.ai-quick { display: flex; gap: 8px; padding: 0 14px 8px; }
.ai-quick-btn { flex: 1; border: 1px solid #e5e7eb; background: #fff; border-radius: 10px; padding: 6px 0; font-size: 12px; color: #4f46e5; cursor: pointer; }
.ai-quick-btn:hover { background: #eef2ff; }
.ai-input-bar { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid #f0f0f0; }
.ai-input-bar input { flex: 1; min-width: 0; border: 1px solid #e5e7eb; border-radius: 12px; padding: 10px 12px; font-size: 13px; outline: none; }
.ai-input-bar input:focus { border-color: #4f46e5; }
.ai-send { border: none; border-radius: 12px; padding: 0 16px; background: #4f46e5; color: #fff; font-size: 13px; cursor: pointer; }
.ai-send:hover { background: #4338ca; }
.ai-send:disabled { opacity: .6; cursor: default; }
.ai-typing { color: #9ca3af; font-size: 12px; font-style: italic; }

@media (max-width: 720px) {
  .ai-panel { right: 10px; bottom: 84px; width: calc(100vw - 20px); height: 60vh; }
  .ai-fab { right: 16px; bottom: 16px; width: 52px; height: 52px; }
  .widget-row { grid-template-columns: 1fr; }
}

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

/* ============================================================
   苹果风格 UI + 侧边栏（覆盖基础样式，放在文件末尾以获得优先级）
   ============================================================ */
:root {
  --apple-blue: #007aff;
  --apple-bg: #f2f2f7;
  --apple-label: #1c1c1e;
  --apple-secondary: #8e8e93;
  --apple-sep: rgba(60,60,67,.12);
  --sidebar-w: 248px;
}

/* 工作台外壳：桌面端左侧固定侧边栏 */
.app-shell { display: flex; min-height: 100vh; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 26px 16px 20px;
  background: rgba(255,255,255,.72);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-right: 1px solid rgba(255,255,255,.55);
  box-shadow: 4px 0 30px rgba(15,23,42,.10);
  z-index: 5;
  transition: width .32s cubic-bezier(.4,0,.2,1), flex-basis .32s cubic-bezier(.4,0,.2,1), padding .32s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
/* 折叠按钮 */
.sidebar-toggle {
  position: absolute;
  top: 22px; right: -13px;
  width: 26px; height: 26px;
  border: 1px solid var(--apple-sep);
  border-radius: 50%;
  background: #fff;
  color: var(--apple-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15,23,42,.14);
  z-index: 8;
  transition: transform .25s ease, color .2s ease, right .32s cubic-bezier(.4,0,.2,1);
}
.sidebar-toggle svg { width: 14px; height: 14px; }
.sidebar-toggle:hover { color: var(--apple-blue); }
/* 收起态 */
.sidebar.collapsed {
  width: 76px;
  flex-basis: 76px;
  padding-left: 12px;
  padding-right: 12px;
}
.sidebar.collapsed .sidebar-toggle { right: 8px; transform: rotate(180deg); }
.sidebar.collapsed .brand-meta,
.sidebar.collapsed .tab span,
.sidebar.collapsed .sidebar-user #user-nick,
.sidebar.collapsed .sidebar-user .btn-ghost { display: none; }
.sidebar.collapsed .sidebar-brand { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .tab { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sidebar-user { justify-content: center; }
/* 收起时悬浮显示文字提示 */
.sidebar.collapsed .tab { position: relative; }
.sidebar.collapsed .tab::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: rgba(28,28,30,.92); color: #fff;
  padding: 5px 9px; border-radius: 7px; font-size: 12px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .18s ease;
}
.sidebar.collapsed .tab:hover::after { opacity: 1; }
.sidebar-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 8px 20px;
}
.sidebar-brand .brand-logo {
  background: linear-gradient(135deg,#5b8cff,#7c5cff);
  border-radius: 13px;
  box-shadow: 0 6px 16px rgba(91,140,255,.38);
  font-size: 20px;
}
.sidebar-brand .brand-mark-img { background: transparent; border-radius: 0; box-shadow: none; }
.brand-meta { min-width: 0; }
.sidebar-brand .brand-name { color: var(--apple-label); font-size: 16px; line-height: 1.25; }
.sidebar-brand .brand-slogan {
  color: var(--apple-secondary); font-size: 10.5px; line-height: 1.35; margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* 侧边栏导航项：iOS 风格图标 + 文字 */
.sidebar .tabs { display: flex; flex-direction: column; gap: 4px; padding: 0; overflow: visible; }
.sidebar .tab {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--apple-label);
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background .2s ease, color .2s ease;
}
.sidebar .tab svg { width: 21px; height: 21px; flex: 0 0 21px; color: var(--apple-secondary); transition: color .2s ease; }
.sidebar .tab:hover { background: rgba(120,120,128,.08); }
.sidebar .tab.active {
  background: rgba(0,122,255,.12);
  color: var(--apple-blue);
  font-weight: 600;
}
.sidebar .tab.active svg { color: var(--apple-blue); }

.sidebar-user {
  margin-top: auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 10px 0;
  border-top: 1px solid var(--apple-sep);
  font-size: 13px;
  color: var(--apple-label);
  font-weight: 500;
}
.sidebar-user #user-nick {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-user .btn-ghost {
  padding: 6px 12px; font-size: 12px;
  background: rgba(120,120,128,.10);
  color: var(--apple-label);
  border: none; border-radius: 9px;
}
.sidebar-user .btn-ghost:hover { background: rgba(120,120,128,.18); }

/* 主区域 */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mobile-header { display: none; }

.app-main .announce-bar {
  margin: 14px 22px 0;
  border-radius: 13px;
  padding: 9px 16px;
  background: rgba(255,255,255,.62);
  border: 1px solid rgba(255,255,255,.7);
  color: var(--apple-label);
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  box-shadow: 0 4px 18px rgba(15,23,42,.06);
}
.app-main .announce-icon { filter: none; }

.app-main .content { padding: 20px 22px 40px; }

/* 苹果风：分区标题与卡片更圆润、细边框 */
.section-title { color: var(--apple-label); font-weight: 700; letter-spacing: -.2px; }
.widget { background: rgba(255,255,255,.86); border: 1px solid rgba(255,255,255,.9); box-shadow: 0 8px 28px rgba(15,23,42,.07); }
.card { background: rgba(255,255,255,.9); border: 1px solid rgba(255,255,255,.95); }
.btn-primary {
  background: var(--apple-blue);
  box-shadow: 0 4px 12px rgba(0,122,255,.28);
}
.btn-primary:hover { background: #0071e3; }

/* 移动端：侧边栏变底部标签栏（iOS Tab Bar） */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  /* 移动端忽略折叠态，底部 Tab Bar 始终完整展示 */
  .sidebar.collapsed {
    width: 100%; flex: none; padding-left: 8px; padding-right: 8px;
  }
  .sidebar.collapsed .brand-meta,
  .sidebar.collapsed .tab span,
  .sidebar.collapsed .sidebar-user #user-nick,
  .sidebar.collapsed .sidebar-user .btn-ghost { display: initial; }
  .sidebar-toggle { display: none; }
  .sidebar {
    width: 100%; height: auto; flex: none;
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    flex-direction: row; align-items: center;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    border-right: none;
    border-top: 1px solid var(--apple-sep);
    box-shadow: 0 -4px 24px rgba(15,23,42,.10);
    z-index: 40;
  }
  .sidebar-brand { display: none; }
  .sidebar-user { display: none; }
  .sidebar .tabs {
    flex-direction: row; justify-content: space-around; align-items: center;
    width: 100%; gap: 2px;
  }
  .sidebar .tab {
    flex-direction: column; gap: 3px;
    padding: 6px 10px;
    font-size: 10px;
    border-radius: 10px;
    min-width: 56px;
  }
  .sidebar .tab svg { width: 23px; height: 23px; flex-basis: 23px; }
  .sidebar .tab.active { background: transparent; color: var(--apple-blue); }
  .sidebar .tab.active svg { color: var(--apple-blue); }
  .app-main { padding-bottom: 72px; }

  .mobile-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 18px 6px;
  }
  .mobile-header .brand-logo { background: linear-gradient(135deg,#5b8cff,#7c5cff); box-shadow: 0 6px 16px rgba(91,140,255,.38); }
  .mobile-header .brand-mark-img { background: transparent; box-shadow: none; }
  .mobile-header .brand-name { color: var(--apple-label); font-size: 16px; }
  .mobile-user { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--apple-label); }
  .mobile-user .btn-ghost {
    padding: 5px 10px; font-size: 12px;
    background: rgba(120,120,128,.10); color: var(--apple-label); border: none; border-radius: 9px;
  }
  .app-main .announce-bar { margin: 10px 14px 0; }
  .app-main .content { padding: 16px 14px 30px; }

  /* 移动端 AI 浮窗上移，避免被底部栏遮挡 */
  .ai-fab { bottom: 84px; }
  .ai-panel { bottom: 146px; }

  /* 移动端安全区：顶部刘海/状态栏留白 */
  .mobile-header { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  /* 名言吸底上移，避开固定底部 Tab Bar */
  .site-footer { bottom: 64px; }
  /* 卡片网格与按钮在小屏下的触控优化 */
  .grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
  .card { padding: 12px 8px; }
  .mini { padding: 7px 10px; font-size: 12px; }
  .card-manage { gap: 5px; margin-top: 7px; }
  .drag-handle { font-size: 16px; line-height: 1; }
  /* 长链接/长标题不撑破布局 */
  .card-title, .vault-site, .vault-account, .vault-host, .brand-name, .section-title {
    overflow-wrap: anywhere; word-break: break-word;
  }
}

/* ===== 底部居中名言（去框，吸底常驻，与退出按钮横向对齐） ===== */
.site-footer {
  position: sticky; z-index: 3; bottom: 0;
  margin-top: auto;
  display: flex; align-items: center; justify-content: center;
  padding: 12px 24px 0;
  background: linear-gradient(180deg, rgba(255,255,255,0) 0%, rgba(255,255,255,.92) 60%, rgba(255,255,255,.98) 100%);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid rgba(60,60,67,.06);
}
.footer-quote {
  display: inline-block;
  max-width: 720px;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--text-soft);
  font-style: italic;
  letter-spacing: .2px;
  animation: quoteFade 1.1s ease both;
}
.footer-quote .quote-author {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #b0b0b5;
  font-style: normal;
}
body.has-bg .site-footer { background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(15,23,42,.42) 100%); border-top-color: rgba(255,255,255,.12); }
body.has-bg .footer-quote { color: rgba(255,255,255,.92); text-shadow: 0 1px 6px rgba(0,0,0,.45); }
body.has-bg .footer-quote .quote-author { color: rgba(255,255,255,.7); }
@keyframes quoteFade {
  from { opacity: 0; transform: translateY(8px); filter: blur(3px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

/* 书签拖拽排序 */
.card.dragging { opacity: .4; transform: scale(.94); }
.card.drag-over { outline: 2px dashed var(--accent); outline-offset: 2px; }
.drag-handle {
  position: absolute; top: 7px; left: 8px;
  font-size: 13px; color: var(--text-soft);
  cursor: grab; opacity: .5; line-height: 1;
  user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.card:hover .drag-handle { opacity: 1; }
.sort-tip { font-size: 12px; color: var(--text-soft); margin: 0 0 12px; }

/* 主题切换的柔和过渡 */
.card, .widget, .announce-bar, .auth-card {
  transition: background .4s ease, box-shadow .4s ease, border-color .4s ease, transform .22s ease;
}

/* 卡片错落入场（stagger） */
.grid .card { animation: cardPop .42s cubic-bezier(.34,1.4,.64,1) both; }
@keyframes cardPop {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   浏览器一键收藏工具
   ============================================================ */
.collect-box {
  background: rgba(255,255,255,.94); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px; margin-bottom: 16px;
  box-shadow: var(--shadow); animation: fadeUp .3s ease both;
}
.collect-box-head { display: flex; align-items: center; justify-content: space-between; }
.collect-box-head strong { font-size: 14px; color: var(--text); }
.collect-close { border: none; background: none; font-size: 22px; color: var(--text-soft); cursor: pointer; line-height: 1; }
.collect-drag-row { margin: 12px 0 8px; }
.bookmarklet-btn {
  display: inline-block; padding: 10px 18px; border-radius: 10px;
  background: linear-gradient(135deg,#5b8cff,#007aff); color: #fff;
  font-size: 13px; font-weight: 600; text-decoration: none;
  box-shadow: 0 6px 16px rgba(0,122,255,.35); cursor: grab;
}
.bookmarklet-btn:active { cursor: grabbing; }
.collect-steps { font-size: 12px; color: var(--text-soft); }

/* ============================================================
   苹果风格备忘录
   ============================================================ */
.memo-app {
  display: grid; grid-template-columns: 300px 1fr;
  min-height: 560px; height: calc(100vh - 220px); max-height: 760px;
  background: #fff; border-radius: 16px; overflow: hidden;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.memo-sidebar {
  display: flex; flex-direction: column;
  background: #f7f7f9; border-right: 1px solid var(--apple-sep);
  overflow: hidden;
}
.memo-sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px;
}
.memo-new-btn {
  width: 30px; height: 30px; border: none; border-radius: 8px;
  background: var(--apple-blue); color: #fff; font-size: 20px;
  cursor: pointer; line-height: 1; box-shadow: 0 3px 8px rgba(0,122,255,.3);
}
.memo-search-wrap {
  display: flex; align-items: center; gap: 6px;
  margin: 0 14px 10px; padding: 7px 10px;
  background: rgba(120,120,128,.1); border-radius: 9px;
}
.memo-search-wrap svg { width: 15px; height: 15px; color: var(--apple-secondary); flex: 0 0 15px; }
.memo-search-wrap input { border: none; background: transparent; outline: none; font-size: 13px; width: 100%; color: var(--text); }
.memo-folders { padding: 0 10px 6px; max-height: 120px; overflow-y: auto; }
.memo-folder {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: none; background: transparent; text-align: left;
  padding: 7px 10px; border-radius: 8px; font-size: 13px;
  color: var(--text); cursor: pointer;
}
.memo-folder:hover { background: rgba(120,120,128,.08); }
.memo-folder.active { background: rgba(0,122,255,.14); color: var(--apple-blue); font-weight: 600; }
.memo-folder-add {
  display: flex; gap: 6px; padding: 4px 14px 10px;
  border-bottom: 1px solid var(--apple-sep);
}
.memo-folder-add input { flex: 1; min-width: 0; padding: 6px 9px; font-size: 12px; border: 1px solid var(--line); border-radius: 8px; outline: none; }
.memo-folder-add button { border: none; background: rgba(120,120,128,.12); color: var(--text); border-radius: 8px; width: 28px; cursor: pointer; font-size: 16px; }
.memo-list { flex: 1; overflow-y: auto; padding: 6px 10px; }
.memo-item {
  position: relative; display: flex; padding: 0; margin-bottom: 8px;
  border-radius: 10px; overflow: hidden; cursor: pointer;
  border: 1px solid rgba(60,60,67,.08);
  transition: transform .16s ease, box-shadow .16s ease;
}
.memo-item:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(15,23,42,.1); }
.memo-item.active { outline: 2px solid var(--apple-blue); }
.memo-item-bg { position: absolute; inset: 0; opacity: .55; }
.memo-item-inner { position: relative; padding: 10px 12px; width: 100%; }
.memo-item-title { font-size: 13.5px; font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.memo-item-date { font-size: 10.5px; color: var(--apple-secondary); margin: 2px 0 4px; }
.memo-item-prev { font-size: 12px; color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.memo-editor { display: flex; flex-direction: column; background: #fff; position: relative; overflow: hidden; }
.memo-editor-empty {
  margin: auto; color: var(--apple-secondary); font-size: 14px;
  display: flex; align-items: center; justify-content: center; height: 100%;
}
.memo-editor-body { display: flex; flex-direction: column; flex: 1; padding: 16px 22px; height: 100%; }
.memo-toolbar { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--apple-sep); }
.memo-tool { border: none; background: transparent; font-size: 17px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.memo-tool:hover { background: rgba(120,120,128,.1); }
.memo-tool.active { background: rgba(255,149,0,.16); }
.memo-colors { display: flex; gap: 6px; }
.memo-color {
  width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(60,60,67,.15);
  cursor: pointer; padding: 0;
}
.memo-color.selected { outline: 2px solid var(--apple-blue); outline-offset: 1px; }
.memo-title-input {
  border: none; background: transparent; outline: none;
  font-size: 22px; font-weight: 700; color: var(--text);
  padding: 14px 0 4px; width: 100%;
}
.memo-date { font-size: 11px; color: var(--apple-secondary); padding-bottom: 8px; }
.memo-content-input {
  flex: 1; border: none; background: transparent; outline: none; resize: none;
  font-size: 14px; line-height: 1.8; color: var(--text);
  font-family: inherit; width: 100%; padding: 4px 0;
}

@media (max-width: 860px) {
  .memo-app { grid-template-columns: 1fr; height: auto; max-height: none; min-height: 70vh; }
  .memo-sidebar { max-height: 260px; border-right: none; border-bottom: 1px solid var(--apple-sep); }
  .memo-editor { min-height: 360px; }
}

/* ===== 密码保险箱 ===== */
.vault-list { display: flex; flex-direction: column; gap: 10px; }
.vault-item {
  display: flex; gap: 14px; align-items: flex-start;
  background: rgba(255,255,255,.92); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow);
  animation: fadeUp .35s ease both;
}
.vault-logo {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 12px;
  background: linear-gradient(135deg,#5b8cff,#007aff); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,122,255,.3);
}
.vault-info { flex: 1; min-width: 0; }
.vault-site { font-size: 15px; font-weight: 700; color: var(--text); }
.vault-host { font-size: 11px; font-weight: 400; color: var(--apple-secondary); }
.vault-account { font-size: 12.5px; color: var(--text-soft); margin-top: 2px; }
.vault-pw-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.vault-pw {
  font-size: 12.5px; color: var(--text-soft); background: rgba(120,120,128,.1);
  padding: 4px 10px; border-radius: 7px; letter-spacing: 1px;
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vault-pw.revealed { color: var(--apple-blue); background: rgba(0,122,255,.1); letter-spacing: 0; }
.vault-act {
  border: none; background: transparent; cursor: pointer; font-size: 14px;
  padding: 4px 6px; border-radius: 7px; opacity: .7;
}
.vault-act:hover { background: rgba(120,120,128,.12); opacity: 1; }
.vault-note { font-size: 11.5px; color: var(--apple-secondary); margin-top: 6px; font-style: italic; }
.card-manage .mini.open { color: var(--apple-blue); border-color: rgba(0,122,255,.4); }
.card-manage .mini.open:hover { background: rgba(0,122,255,.1); }

/* ===== iOS 风格日历 ===== */
.cal-ios { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif; }
.cal-ios-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; padding: 0 4px;
}
.cal-month-name { font-size: 15px; font-weight: 700; color: var(--apple-label); letter-spacing: -.2px; }
.cal-nav {
  width: 28px; height: 28px; border: none; border-radius: 8px;
  background: rgba(120,120,128,.1); color: var(--apple-label);
  font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.cal-nav:hover { background: rgba(120,120,128,.2); }
.cal-ios-weekdays, .cal-ios-grid { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; }
.cal-weekday { font-size: 11px; color: var(--apple-secondary); padding: 4px 0; font-weight: 500; }
.cal-weekday.weekend { color: #ff3b30; }
.cal-ios-grid { gap: 2px 0; margin-top: 2px; }
.cal-day {
  font-size: 12px; color: var(--apple-label);
  padding: 6px 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  aspect-ratio: 1; max-height: 30px; margin: 0 auto; width: 30px;
}
.cal-day.muted { color: #c7c7cc; }
.cal-day.weekend:not(.muted) { color: #ff3b30; }
.cal-day.today {
  background: #ff3b30; color: #fff !important; font-weight: 700;
  box-shadow: 0 3px 8px rgba(255,59,48,.4);
}
