/* 灵通资源 - 手机端专属样式（小程序风格） */
/* 仅在屏幕宽度 <= 768px 时生效，覆盖响应式设计 */

/* ===== 桌面端隐藏底部TabBar ===== */
.mobile-tabbar {
  display: none;
}

@media (max-width: 768px) {

  /* ===== 全局重置 ===== */
  :root {
    --mobile-primary: var(--primary);
    --mobile-bg: var(--bg);
    --mobile-card: var(--bg-white);
    --mobile-text: var(--text);
    --mobile-text-sub: var(--text-muted);
    --mobile-border: var(--border-light);
    --mobile-radius: var(--radius-lg);
    --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
  }

  html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
  }

  body {
    background: var(--mobile-bg);
    padding-top: 52px;
    padding-bottom: calc(56px + var(--mobile-safe-bottom));
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .container {
    padding: 0 12px;
    max-width: 100%;
  }

  /* ===== 顶部导航栏 - 小程序风格 52px ===== */
  .nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--bg-white);
    border-bottom: none;
    box-shadow: 0 0.5px 0 var(--border-light);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .nav-inner {
    height: 52px;
    padding: 0 16px;
    max-width: 100%;
  }

  .nav-brand {
    font-size: 17px;
    font-weight: 600;
    gap: 8px;
  }

  .nav-brand img {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
  }

  .nav-brand span {
    display: none;
  }

  /* 隐藏桌面端导航链接和汉堡菜单 */
  .nav-links,
  .nav-toggle,
  .nav-overlay,
  .nav-mobile {
    display: none !important;
  }

  /* ===== 首页 Hero 区域 - 紧凑化 ===== */
  .hero-section {
    padding: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    margin: -52px 0 0;
    padding-top: 52px;
  }

  .hero-section::before {
    display: none;
  }

  .hero-title {
    font-size: 22px;
    letter-spacing: 0;
    margin-bottom: 4px;
  }

  .hero-slogan {
    font-size: 13px;
    margin-bottom: 16px;
    opacity: 0.85;
  }

  .hero-stats {
    gap: 24px;
    margin-bottom: 16px;
  }

  .hero-stats .stat-num {
    font-size: 22px;
  }

  .hero-stats .stat-label {
    font-size: 11px;
  }

  /* 搜索框 - 圆角20px */
  .search-box {
    max-width: 100%;
  }

  .search-box input {
    padding: 11px 44px 11px 40px;
    font-size: 16px; /* 防止iOS缩放 */
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    box-shadow: none;
    border: none;
  }

  .search-box input:focus {
    background: var(--bg-white);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.1);
  }

  .search-icon {
    left: 14px;
  }

  .search-icon svg {
    width: 18px;
    height: 18px;
  }

  .search-shortcut {
    display: none;
  }

  /* ===== 分类标签栏 - 胶囊横向滚动 ===== */
  .category-section {
    position: sticky;
    top: 52px;
    z-index: 50;
    background: var(--bg-white);
    border-bottom: none;
    box-shadow: 0 1px 0 var(--border-light);
  }

  .category-bar {
    padding: 10px 0;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .category-bar::-webkit-scrollbar {
    display: none;
  }

  .category-tab {
    padding: 6px 16px;
    font-size: 13px;
    border-radius: 20px;
    background: var(--mobile-bg);
    color: var(--mobile-text-sub);
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s ease;
  }

  .category-tab:hover {
    background: var(--mobile-bg);
    color: var(--mobile-text-sub);
  }

  .category-tab.active {
    background: var(--mobile-primary);
    color: var(--bg-white);
    box-shadow: 0 2px 8px rgba(0, 102, 255, 0.25);
  }

  /* ===== 工具网格 - 4列九宫格 ===== */
  .tools-section {
    padding: 12px 0 20px;
  }

  .tools-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px 0;
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
  }

  /* 分类标题 - 小程序分组标题 */
  .tool-cat-title {
    display: block !important;
    grid-column: 1 / -1;
    font-size: 15px;
    font-weight: 600;
    color: var(--mobile-text);
    padding: 20px 0 8px;
    margin-bottom: 0;
    border-bottom: none;
  }

  .tool-cat-title:first-child {
    padding-top: 4px;
  }

  /* 工具卡片 - 大图标+小文字 */
  .tool-card {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 4px 8px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    text-align: center;
    transition: background 0.15s;
  }

  .tool-card::before {
    display: none;
  }

  .tool-card:hover {
    transform: none;
    box-shadow: none;
    background: var(--mobile-bg);
  }

  .tool-card:active {
    background: rgba(0, 0, 0, 0.04);
    transform: scale(0.96);
  }

  /* 图标 - 40px大图标 */
  .tool-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .tool-icon svg {
    width: 22px;
    height: 22px;
  }

  /* 工具名称 - 12px小文字 */
  .tool-info {
    text-align: center;
    line-height: 1.2;
  }

  .tool-info h3 {
    font-size: 12px;
    font-weight: 500;
    color: var(--mobile-text);
    margin-bottom: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 72px;
  }

  .tool-info p {
    display: none;
  }

  /* ===== 底部统计 ===== */
  .tools-stats {
    padding: 16px 12px 0;
    font-size: 12px;
    color: var(--mobile-text-sub);
  }

  /* ===== 空状态 ===== */
  .empty-state {
    padding: 48px 20px;
  }

  .empty-state-icon svg {
    width: 40px;
    height: 40px;
  }

  .empty-state p {
    font-size: 14px;
  }

  /* ===== 底部导航栏 - 小程序TabBar 56px + safe-area ===== */
  .mobile-tabbar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(56px + var(--mobile-safe-bottom));
    padding-bottom: var(--mobile-safe-bottom);
    background: var(--bg-white);
    border-top: none;
    box-shadow: 0 -0.5px 0 var(--border-light);
    z-index: 200;
  }

  .mobile-tabbar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--mobile-text-sub);
    font-size: 10px;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
    position: relative;
  }

  .mobile-tabbar-item:active {
    opacity: 0.7;
  }

  .mobile-tabbar-item.active {
    color: var(--mobile-primary);
  }

  .mobile-tabbar-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: var(--mobile-primary);
    border-radius: 0 0 2px 2px;
  }

  .mobile-tabbar-item svg {
    width: 22px;
    height: 22px;
  }

  .mobile-tabbar-item span {
    line-height: 1;
  }

  /* ===== 工具页面 - 小程序风格 ===== */
  .tool-page {
    padding: calc(var(--nav-height-mobile, 52px) + 12px) 0 20px;
  }

  .tool-header {
    margin-bottom: 12px;
  }

  .tool-breadcrumb {
    font-size: 12px;
    margin-bottom: 8px;
  }

  .tool-header h1 {
    font-size: 18px;
    gap: 8px;
  }

  .tool-header h1 .tool-icon {
    width: 28px;
    height: 28px;
  }

  .tool-header h1 .tool-icon svg {
    width: 16px;
    height: 16px;
  }

  .tool-header p {
    font-size: 13px;
  }

  /* 工具面板 */
  .tool-panel {
    padding: 14px;
    border-radius: var(--radius-md);
  }

  .tool-panels {
    gap: 10px;
  }

  .tool-panels-single {
    grid-template-columns: 1fr;
  }

  .panel-label {
    font-size: 12px;
    margin-bottom: 8px;
  }

  /* 输入框 - 防止iOS缩放 font-size:16px */
  .input,
  .textarea,
  select {
    padding: 10px 12px;
    font-size: 16px;
    border-radius: var(--radius-md);
  }

  .textarea {
    min-height: 120px;
  }

  /* 操作按钮区 */
  .tool-actions {
    gap: 8px;
    margin: 12px 0;
    padding: 12px 0;
  }

  .btn {
    padding: 10px 16px;
    font-size: 14px;
    border-radius: var(--radius-md);
  }

  .btn-sm {
    padding: 8px 12px;
    font-size: 13px;
  }

  /* 结果区域 */
  .result-area {
    padding: 12px;
    font-size: 13px;
    min-height: 100px;
    border-radius: var(--radius-md);
  }

  .result-area .copy-btn {
    padding: 6px 10px;
    font-size: 11px;
    top: 8px;
    right: 8px;
  }

  /* 顶部操作栏 */
  .tool-topbar {
    margin-bottom: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .tool-topbar-left,
  .tool-topbar-right {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  /* 标签页 */
  .tabs {
    gap: 0;
    margin-bottom: 12px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    padding: 8px 14px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* 哈希结果 */
  .hash-item {
    padding: 10px 12px;
    gap: 8px;
  }

  .hash-algo {
    min-width: 56px;
    font-size: 11px;
  }

  .hash-value {
    font-size: 12px;
  }

  /* 单选组 */
  .radio-group {
    gap: 12px;
  }

  .radio-item {
    font-size: 13px;
  }

  /* ===== 页脚 - 简化 ===== */
  .footer {
    padding: 20px 0 16px;
    background: var(--bg-white);
  }

  .footer-inner {
    display: none;
  }

  .footer-bottom {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 16px 0;
    gap: 6px;
  }

  .footer-bottom-left {
    font-size: 11px;
  }

  .footer-bottom-right {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
  }

  .footer-bottom-right a {
    font-size: 11px;
  }

  /* ===== 个人中心页面 ===== */
  .wb-page {
    padding-top: calc(var(--nav-height-mobile, 52px) + 16px);
  }

  .wb-header {
    flex-direction: column;
    text-align: center;
    gap: 12px;
    padding: 16px;
  }

  .wb-header-avatar {
    width: 48px !important;
    height: 48px !important;
  }

  .wb-header-info {
    align-items: center;
  }

  .wb-cards-grid {
    grid-template-columns: 1fr;
  }

  .wb-site-domain-form input {
    min-width: 0 !important;
  }

  .wb-key-name-input {
    width: 80px !important;
  }

  /* 覆盖profile.php内联style中的固定宽度 */
  .wb-site-domain-form {
    flex-direction: column;
    align-items: stretch;
  }

  .wb-site-domain-form input {
    min-width: 0 !important;
    width: 100% !important;
  }

  /* ===== 登录/注册页面 ===== */
  .auth-page {
    padding-top: calc(var(--nav-height-mobile, 52px) + 12px);
    align-items: flex-start;
  }

  .auth-layout {
    flex-direction: column;
    max-width: 100%;
    margin: 12px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
  }

  .auth-brand {
    min-height: auto;
    padding: 24px 20px;
  }

  .auth-brand h2 {
    font-size: 20px;
  }

  .auth-brand-features {
    display: none;
  }

  .auth-form-side {
    padding: 20px;
  }

  .auth-card {
    padding: 20px;
  }

  .code-row {
    flex-direction: column;
  }

  .code-row .btn {
    min-width: auto;
  }

  /* ===== API开放平台 ===== */
  .api-hero {
    padding-top: 52px;
  }

  .api-hero h1 {
    font-size: 20px;
  }

  .api-hero p {
    font-size: 13px;
  }

  /* ===== Toast 提示 ===== */
  .toast {
    top: 60px;
    font-size: 13px;
    padding: 10px 20px;
    border-radius: 20px;
    max-width: 80vw;
  }

  /* ===== 通用卡片样式覆盖 ===== */
  .wb-card {
    border-radius: var(--radius-md);
  }

  .wb-card-header {
    padding: 12px 14px;
  }

  .wb-card-body {
    padding: 12px 14px 14px;
  }

  /* ===== 隐藏滚动条 ===== */
  ::-webkit-scrollbar {
    display: none;
  }

  * {
    scrollbar-width: none;
  }

  /* ===== 防止长按选中 ===== */
  .tool-card,
  .mobile-tabbar-item,
  .btn {
    -webkit-user-select: none;
    user-select: none;
  }

  /* ===== 工具页面返回按钮 ===== */
  .tool-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 14px;
    color: var(--mobile-text);
    background: var(--mobile-bg);
    border-radius: var(--radius-md);
    text-decoration: none;
    margin-bottom: 8px;
    transition: background 0.15s;
  }

  .tool-back-btn:active {
    background: var(--border-light);
  }

  .tool-back-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* ===== 超小屏幕适配 (<=360px) - 3列 ===== */
@media (max-width: 360px) {
  .tools-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .tool-icon {
    width: 36px;
    height: 36px;
  }

  .tool-icon svg {
    width: 20px;
    height: 20px;
  }

  .tool-info h3 {
    font-size: 11px;
    max-width: 60px;
  }

  .hero-title {
    font-size: 18px;
  }

  .hero-stats .stat-num {
    font-size: 18px;
  }
}
