/* ============================================================
 *  Layout · 混合字体
 *  界面用 UI 字体 · 时钟/搜索框/代码感元素用等宽
 * ============================================================ */
.home {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 0.5rem;
  animation: fadeIn 0.4s ease;
}

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

/* ===== 顶部栏 ===== */
.top-bar {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-bottom: -0.5rem;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 1rem;
  transition: all 0.12s ease;
}
.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-bright);
  background-color: var(--bg-hover);
}
.icon-btn:active { transform: scale(0.94); }

/* ===== 时钟 ===== */
.time-area {
  text-align: center;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
}

.clock {
  /* 保留等宽：时钟数字对齐、走时整齐 */
  font-family: var(--font-mono);
  font-size: 4.5rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent-glow);
  transition: text-shadow 0.3s;
}

.clock::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--accent);
  border-radius: 50%;
  margin-right: 1.2rem;
  vertical-align: middle;
  box-shadow: 0 0 12px var(--accent-glow);
  animation: pulse 2s ease-in-out infinite;
  margin-bottom: 0.7rem;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* 秒数：字号小一号，弱化 */
.clock-seconds {
  font-size: 0.55em;
  font-weight: 400;
  opacity: 0.55;
  letter-spacing: 0;
  margin-left: 0.05em;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* AM/PM 后缀：相对时钟主字号 */
.clock-suffix {
  font-size: 0.32em;
  font-weight: 500;
  margin-left: 0.35em;
  color: var(--accent);
  opacity: 0.6;
  letter-spacing: 0.05em;
  vertical-align: super;
  font-family: var(--font-mono);
}

.greeting {
  /* UI 字体：中文更易读 */
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-top: 0.6rem;
  letter-spacing: 0.1px;
}
.greeting::before {
  content: '# ';
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 600;
}

.weather-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  /* UI 字体 */
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-top: 0.7rem;
  padding: 0.35rem 0.75rem;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.weather-inline::before {
  content: '// ';
  color: var(--text-muted);
  font-family: var(--font-mono);
  opacity: 0.7;
}

/* ===== 搜索引擎切换（收窄版）===== */
.engine-selector-wrapper {
  position: relative;
  margin: 0 -0.5rem;
}
.engine-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 0.25rem 0.5rem 0.5rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.engine-selector::-webkit-scrollbar { display: none; }

.engine-btn {
  /* UI 字体：引擎名易读 */
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background-color: transparent;
  color: var(--text-muted);
  transition: all 0.12s ease;
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.01em;
}

.engine-btn::before,
.engine-btn::after {
  content: none;
}

.engine-btn:hover {
  color: var(--text-secondary);
  background-color: var(--bg-subtle);
}

.engine-btn.active {
  background-color: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
  box-shadow: 0 0 0 1px var(--accent-soft), 0 0 12px var(--accent-soft);
}

/* ===== 搜索 ===== */
.search-area {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.search-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}
.search-wrapper::before {
  content: '>';
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--accent);
  font-weight: 700;
  font-size: 1rem;
  pointer-events: none;
  z-index: 1;
  font-family: var(--font-mono);
}

.search-input {
  /* 等宽：打字手感好 */
  font-family: var(--font-mono);
  width: 100%;
  padding: 0.85rem 2.6rem 0.85rem 2.2rem;
  font-size: 0.92rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--bg-elevated);
  color: var(--text-bright);
  transition: all 0.15s ease;
  min-height: 48px;
}
.search-input:hover { border-color: var(--border-strong); }
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.search-input::placeholder {
  color: var(--text-muted);
  font-family: var(--font-ui);
}

.search-btn {
  /* UI 字体：按钮更清晰 */
  font-family: var(--font-ui);
  padding: 0.85rem 1.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius);
  background-color: var(--accent);
  color: #0d1117;
  border: 1px solid var(--accent);
  min-height: 48px;
  flex-shrink: 0;
  transition: all 0.12s ease;
  letter-spacing: 0.03em;
}
body.light .search-btn { color: #fffbf0; }
.search-btn:hover {
  background-color: var(--accent-dim);
  border-color: var(--accent-dim);
  box-shadow: 0 0 16px var(--accent-glow);
}
.search-btn:active { transform: scale(0.98); }

/* ===== 快捷导航 ===== */
.links-section { margin-top: 0.25rem; }
.links-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding: 0 0.25rem;
  gap: 0.5rem;
}
.links-label {
  font-family: var(--font-ui);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
}
.links-label::before,
.links-label::after {
  content: '──';
  color: var(--border-strong);
  font-family: var(--font-mono);
  opacity: 0.6;
  line-height: 1;
}

.add-bookmark-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
  font-family: var(--font-mono);
  line-height: 1;
}
.add-bookmark-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 8px var(--accent-soft);
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.link-item {
  /* UI 字体：书签名称易读 */
  font-family: var(--font-ui);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.9rem 0.4rem;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-weight: 500;
  font-size: 0.8rem;
  text-align: center;
  transition: all 0.15s ease;
  gap: 0.4rem;
  line-height: 1.3;
  min-height: 84px;
  position: relative;
  overflow: hidden;
}
.link-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  transition: opacity 0.2s;
}
.link-item:hover {
  border-color: var(--accent);
  background-color: var(--bg-hover);
  color: var(--text-bright);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--accent-soft);
}
.link-item:hover::before {
  opacity: 1;
}
.link-item:active { transform: translateY(0); }

.link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  font-size: 1.4rem;
  line-height: 1;
  filter: saturate(0.9);
  flex-shrink: 0;
}

.link-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-sm);
  background-color: var(--red);
  color: #0d1117;
  font-size: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
  border: none;
  font-weight: 700;
  font-family: var(--font-mono);
}
.link-item:hover .link-remove { opacity: 1; }
.link-remove:active { opacity: 1; }

.link-item.dragging { opacity: 0.4; }
.link-item.drag-over {
  border-color: var(--accent);
  border-style: dashed;
  background-color: var(--accent-soft);
}

/* ===== 分隔 ===== */
.divider {
  width: 100%;
  height: 1px;
  background-color: var(--border);
  margin: 0.5rem 0;
  position: relative;
}
.divider::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
}

.footer-note {
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  color: var(--text-muted);
  padding-bottom: 0.25rem;
  letter-spacing: 0.02em;
}
.footer-note::before {
  content: '/* ';
  color: var(--text-muted);
  opacity: 0.5;
  font-family: var(--font-mono);
}
.footer-note::after {
  content: ' */';
  color: var(--text-muted);
  opacity: 0.5;
  font-family: var(--font-mono);
}

/* ===== 小组件网格 ===== */
.widgets-area {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.6rem;
}

.widget {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-width: 0;
  transition: border-color 0.15s;
  position: relative;
}
.widget:hover { border-color: var(--border-strong); }
.widget-wide { grid-column: 1 / -1; }

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.widget-title {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted);
}
.widget-title::before {
  content: '## ';
  color: var(--accent);
  opacity: 0.7;
  font-family: var(--font-mono);
}
.widget-hint {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  color: var(--text-muted);
}
.widget-action {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: all 0.15s;
}
.widget-action:hover {
  background-color: var(--bg-hover);
  color: var(--accent);
}

/* ===== 模态框 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(1, 4, 9, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 1rem;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
body.light .modal-overlay { background-color: rgba(60, 55, 40, 0.4); }
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal-panel {
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  box-shadow: var(--shadow);
  transform: translateY(6px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.open .modal-panel {
  transform: translateY(0) scale(1);
}
.modal-panel h3 {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
  color: var(--text-bright);
  letter-spacing: 0.02em;
}
.modal-panel h3::before {
  content: '$ ';
  color: var(--accent);
  font-family: var(--font-mono);
}
.modal-panel input {
  font-family: var(--font-mono);
  padding: 0.65rem 0.9rem;
  font-size: 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background-color: var(--bg);
  color: var(--text-bright);
  transition: all 0.15s;
  min-height: 40px;
}
.modal-panel input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.25rem;
}

/* ===== 通用按钮 ===== */
.primary-btn, .secondary-btn {
  font-family: var(--font-ui);
  padding: 0.55rem 1rem;
  font-size: 0.8rem;
  font-weight: 500;
  border-radius: var(--radius);
  transition: all 0.15s ease;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
}

.primary-btn {
  background-color: var(--accent);
  color: #0d1117;
  border: 1px solid var(--accent);
  font-weight: 600;
}
body.light .primary-btn { color: #fffbf0; }
.primary-btn:hover {
  background-color: var(--accent-dim);
  border-color: var(--accent-dim);
  box-shadow: 0 0 12px var(--accent-glow);
}
.primary-btn:active { transform: scale(0.98); }

.secondary-btn {
  background-color: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.secondary-btn:hover {
  background-color: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text-bright);
}
.secondary-btn:active { transform: scale(0.98); }
.secondary-btn.danger {
  color: var(--red);
  border-color: var(--border);
}
.secondary-btn.danger:hover {
  background-color: var(--red-soft);
  border-color: var(--red);
}
.secondary-btn.full { width: 100%; }

/* ===== 命令面板 ===== */
.command-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(1, 4, 9, 0.75);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding-left: 1rem;
  padding-right: 1rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
body.light .command-overlay { background-color: rgba(60, 55, 40, 0.45); }
.command-overlay.open { opacity: 1; pointer-events: auto; }

.command-panel {
  width: 100%;
  max-width: 560px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: translateY(-6px) scale(0.98);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}
.command-overlay.open .command-panel {
  transform: translateY(0) scale(1);
}
.command-panel::before {
  content: '>';
  position: absolute;
  top: 0.95rem;
  left: 1rem;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.95rem;
  pointer-events: none;
  z-index: 1;
  font-family: var(--font-mono);
}

.command-input {
  font-family: var(--font-mono);
  width: 100%;
  padding: 0.95rem 1.1rem 0.95rem 2.2rem;
  font-size: 0.9rem;
  border: none;
  background: transparent;
  color: var(--text-bright);
  border-bottom: 1px solid var(--border);
}
.command-input::placeholder {
  color: var(--text-muted);
  font-family: var(--font-ui);
}

.command-list {
  list-style: none;
  max-height: 50vh;
  overflow-y: auto;
  padding: 0.35rem;
}

.command-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s;
  font-size: 0.85rem;
  font-family: var(--font-ui);
}
.command-item:hover,
.command-item.active {
  background-color: var(--accent-soft);
}
.command-item.active .cmd-title {
  color: var(--accent);
}
.command-item .cmd-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background-color: var(--bg-subtle);
  font-size: 0.8rem;
  flex-shrink: 0;
}
.command-item.active .cmd-icon {
  background-color: var(--accent);
  color: #0d1117;
}
.command-item .cmd-body { flex: 1; min-width: 0; }
.command-item .cmd-title {
  font-weight: 500;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
}
.command-item .cmd-sub {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.1rem;
}
.command-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--font-ui);
}
.command-empty::before {
  content: '// ';
  opacity: 0.5;
  font-family: var(--font-mono);
}