/* ===== 平板 ===== */
@media (max-width: 720px) {
  .clock { font-size: 3.75rem; }
  .clock-suffix { font-size: 1.2rem; margin-left: 0.4rem; }
}

/* ===== 手机竖屏 ===== */
@media (max-width: 560px) {
  body {
    font-size: 14px;
    padding: 1rem;
    padding-top: max(1rem, env(safe-area-inset-top));
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    justify-content: flex-start;
  }
  body::before { background-size: 30px 30px; }
  .home { gap: 1.15rem; padding: 0; margin-top: 0.4rem; }

  .clock { font-size: 3rem; letter-spacing: -0.02em; }
  .clock::before { width: 6px; height: 6px; margin-right: 0.8rem; }
  .clock-suffix { font-size: 1.1rem; margin-left: 0.35rem; }

  .greeting { font-size: 0.85rem; }

  .search-area { flex-direction: column; gap: 0.45rem; }
  .search-btn { width: 100%; min-height: 46px; }
  .search-input { min-height: 46px; font-size: 16px; padding-left: 2rem; }
  .search-wrapper::before { left: 0.9rem; }

  .widgets-area { grid-template-columns: 1fr; }
  .widget-wide { grid-column: auto; }

  .links-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.4rem;
  }
  .link-item {
    padding: 0.8rem 0.3rem;
    min-height: 78px;
    font-size: 0.72rem;
    gap: 0.35rem;
  }
  .link-icon { font-size: 1.3rem; }

  .engine-btn {
    padding: 0.35rem 0.55rem;
    font-size: 0.72rem;
    min-height: 28px;
  }
  .icon-btn { width: 34px; height: 34px; font-size: 0.9rem; }
  .top-bar { margin-bottom: -0.25rem; }

  /* 每日格言 */
  .quote { font-size: 0.78rem; padding: 0.5rem 0.75rem; }
  .quote-mark { font-size: 1rem; }
  .quote-author { font-size: 0.68rem; }

  /* 搜索历史 */
  .history-chip {
    font-size: 0.72rem;
    padding: 0.25rem 0.6rem;
  }

  /* 复制按钮 */
  .copy-btn {
    opacity: 1;
    pointer-events: auto;
    width: 28px;
    height: 28px;
  }
}

/* ===== 小屏 ===== */
@media (max-width: 400px) {
  .clock { font-size: 2.6rem; }
  .clock-suffix { font-size: 0.95rem; margin-left: 0.3rem; }

  .links-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.35rem;
  }
  .link-item {
    padding: 0.7rem 0.25rem;
    min-height: 72px;
    font-size: 0.68rem;
  }
  .link-icon { font-size: 1.2rem; }
  .engine-btn { padding: 0.3rem 0.5rem; font-size: 0.7rem; }
}

/* ===== 横屏手机 ===== */
@media (max-height: 520px) and (orientation: landscape) {
  body {
    justify-content: flex-start;
    padding: 0.8rem;
  }
  body::before { background-size: 24px 24px; }
  .home { gap: 0.8rem; max-width: 900px; }

  .clock { font-size: 2.2rem; }
  .clock::before { width: 5px; height: 5px; margin-right: 0.7rem; margin-bottom: 0.4rem; }
  .clock-suffix { font-size: 1rem; margin-left: 0.3rem; }

  .greeting { font-size: 0.78rem; margin-top: 0.25rem; }
  .time-area { margin-top: 0; margin-bottom: 0; }
  .weather-inline { padding: 0.25rem 0.6rem; font-size: 0.72rem; margin-top: 0.4rem; }

  .widgets-area { grid-template-columns: repeat(2, 1fr); }
  .links-grid { grid-template-columns: repeat(6, 1fr); gap: 0.3rem; }
  .link-item {
    padding: 0.55rem 0.2rem;
    min-height: 62px;
    font-size: 0.62rem;
    gap: 0.2rem;
  }
  .link-icon { font-size: 1.05rem; }

  .search-input, .search-btn { min-height: 42px; padding: 0.65rem 1rem 0.65rem 2rem; }
  .search-wrapper::before { left: 0.85rem; }
  .engine-btn { padding: 0.3rem 0.6rem; font-size: 0.72rem; min-height: 28px; }

  .quote { font-size: 0.72rem; padding: 0.4rem 0.6rem; }
  .quote-mark { font-size: 0.9rem; }
}

/* ============================================================
 *  触摸设备专用
 *  - 隐藏书签卡片的删除按钮（避免误触）
 *  - 隐藏待办的删除按钮
 *  - 其他触摸优化
 * ============================================================ */
@media (pointer: coarse) {
  /* 隐藏书签的删除按钮 */
  .link-item .link-remove {
    display: none !important;
  }

  /* 隐藏待办的删除按钮 */
  .todo-item .todo-del {
    display: none !important;
  }

  /* 其他触摸优化 */
  .icon-btn {
    min-width: 40px;
    min-height: 40px;
  }
  .engine-btn {
    min-height: 40px;
  }
  .settings-close {
    min-width: 40px;
    min-height: 40px;
  }
}

/* ============================================================
 *  窄屏（手机）额外隐藏
 *  双保险：手机宽度下也隐藏（防止某些浏览器不识别 pointer: coarse）
 * ============================================================ */
@media (max-width: 640px) {
  .link-item .link-remove,
  .todo-item .todo-del {
    display: none !important;
  }
}

/* ===== 减少动画 ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}