/* =============================================
   名刺めくり - モバイル専用スタイル
   モバイルファーストのUX最適化
   ============================================= */

/* =============================================
   CSS カスタムプロパティ
   ============================================= */
:root {
  /* タップターゲットサイズ (最低44px推奨) */
  --tap-target-min: 44px;
  --tap-target-comfortable: 48px;
  
  /* モバイル用スペーシング */
  --mobile-spacing-xs: 4px;
  --mobile-spacing-sm: 8px;
  --mobile-spacing-md: 12px;
  --mobile-spacing-lg: 16px;
  --mobile-spacing-xl: 24px;
  
  /* モバイル用カラー */
  --mobile-primary: #667eea;
  --mobile-primary-dark: #5a6fd8;
  --mobile-accent: #764ba2;
  --mobile-success: #10b981;
  --mobile-danger: #ef4444;
  --mobile-warning: #f59e0b;
  
  /* シャドウ */
  --mobile-shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
  --mobile-shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --mobile-shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
  --mobile-shadow-xl: 0 20px 40px rgba(0,0,0,0.2);
  
  /* Safe Area (ノッチ対応) */
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --safe-area-left: env(safe-area-inset-left, 0px);
  --safe-area-right: env(safe-area-inset-right, 0px);
  
  /* ボトムバー高さ（コンパクト） */
  --bottom-bar-height: 44px;
  /* FABボタン突出分（よりコンパクトに） */
  --fab-overflow: 20px;
  
  /* ブラウザツールバー対応の追加マージン */
  --browser-toolbar-offset: 12px;
}

/* =============================================
   モバイル基本スタイル (768px以下)
   ============================================= */
@media (max-width: 768px) {
  /* タッチデバイス最適化 */
  * {
    -webkit-tap-highlight-color: transparent;
  }
  
  /* スムーズスクロール */
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    /* ベースフォントサイズをモバイル用に調整 */
    font-size: 15px;
  }
  
  body {
    /* ボトムバー用のパディング（ブラウザツールバー分も考慮） */
    padding-bottom: calc(var(--bottom-bar-height) + var(--fab-overflow) + var(--safe-area-bottom) + var(--browser-toolbar-offset));
    overscroll-behavior: contain;
    /* モバイル用ベース行間 */
    line-height: 1.6;
    /* フォントの読みやすさ向上 */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
  }
  
  /* ボトムバー表示時のメインコンテンツ調整 */
  body.has-bottom-bar {
    padding-bottom: calc(var(--bottom-bar-height) + var(--fab-overflow) + var(--safe-area-bottom) + var(--browser-toolbar-offset));
  }
  
  /* =============================================
     ナビゲーションヘッダー最適化
     ============================================= */
  .main-navigation {
    margin-bottom: var(--mobile-spacing-sm);
  }
  
  .nav-container {
    padding: var(--mobile-spacing-sm) var(--mobile-spacing-md);
  }
  
  .nav-logo {
    font-size: 1.2em;
  }
  
  /* モバイル：右上サイドバー（nav-links）とハンバーガー（hamburger-menu）を非表示 */
  .hamburger-menu {
    display: none !important;
  }
  .nav-links {
    display: none !important;
  }
  /* 念のため、メニューオープン時のオーバーレイも抑止 */
  body.menu-open::before {
    content: none !important;
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }
  body.menu-open {
    overflow: auto !important;
  }
  
  /* =============================================
     モバイル用タイポグラフィ
     ============================================= */
  
  /* コンテナの調整 */
  .container {
    padding: var(--mobile-spacing-sm) var(--mobile-spacing-sm);
  }
  
  /* サービスタイトル - コンパクト */
  .service-title {
    font-size: 1.4rem;
    line-height: 1.2;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
    text-align: center;
  }
  
  /* サービス説明 - 短く */
  .service-description {
    font-size: 0.75rem;
    line-height: 1.5;
    color: #64748b;
    padding: 0 var(--mobile-spacing-sm);
    margin-bottom: var(--mobile-spacing-sm);
    text-align: center;
  }
  
  .service-description br {
    display: none;
  }
  
  /* 汎用見出し */
  h1 {
    font-size: 1.4rem;
    line-height: 1.2;
  }
  
  h2 {
    font-size: 1.2rem;
    line-height: 1.3;
  }
  
  h3 {
    font-size: 1rem;
    line-height: 1.35;
  }
  
  h4, h5, h6 {
    font-size: 0.9rem;
    line-height: 1.35;
  }
  
  /* 段落テキスト */
  p {
    font-size: 0.85rem;
    line-height: 1.6;
    margin-bottom: 0.75rem;
  }
  
  /* 小テキスト */
  small, .small {
    font-size: 0.75rem;
    line-height: 1.4;
  }
  
  /* ラベルテキスト */
  label {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.35;
  }
  
  /* =============================================
     モバイル用ボトムナビゲーション（タブバー + FAB）
     ============================================= */
  .mobile-bottom-bar {
    position: fixed;
    bottom: var(--browser-toolbar-offset);
    left: var(--mobile-spacing-sm);
    right: var(--mobile-spacing-sm);
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 
      0 -1px 10px rgba(0, 0, 0, 0.06),
      0 0 0 1px rgba(0, 0, 0, 0.02);
    z-index: 9000;
    min-height: var(--bottom-bar-height);
    padding: 4px 6px calc(4px + var(--safe-area-bottom));
    display: none;
    flex-direction: column;
    border-radius: 14px;
    overflow: visible;
    will-change: transform;
    -webkit-backface-visibility: hidden;
    /* paintコンテインメントを外してFABがはみ出せるようにする */
    contain: layout;
  }
  
  body.is-mobile .mobile-bottom-bar {
    display: flex;
  }
  
  /* ナビゲーションタブ部分 */
  .bottom-nav-tabs {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    padding: 4px 6px 4px;
    position: relative;
  }
  
  .nav-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: #9ca3af;
    font-size: 0.72rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
    border-radius: 10px;
    position: relative;
    white-space: nowrap;
    flex: 1 1 0; /* タブ幅を均等配分して視認性を向上 */
    line-height: 1;
  }
  
  .nav-tab i {
    font-size: 0.85rem;
    transition: all 0.2s ease;
  }
  
  .nav-tab:active {
    transform: scale(0.98);
  }
  
  .nav-tab.active {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    font-weight: 600;
    box-shadow: 0 1px 4px rgba(99, 102, 241, 0.22);
  }
  
  .nav-tab.active i {
    color: white;
  }
  
  /* 中央のFAB（カメラボタン） */
  .fab-camera {
    position: absolute;
    top: calc(-1 * var(--fab-overflow));
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(145deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 
      0 3px 12px rgba(99, 102, 241, 0.28),
      0 2px 4px rgba(99, 102, 241, 0.16);
    transition: all 0.25s ease;
    z-index: 10;
  }
  
  .fab-camera:active {
    transform: translateX(-50%) scale(0.92);
    box-shadow: 
      0 2px 10px rgba(99, 102, 241, 0.3),
      0 1px 3px rgba(99, 102, 241, 0.15);
  }
  
  .fab-camera i {
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
  }
  
  /* アクションボタンエリア（非表示） */
  .bottom-actions {
    display: none;
  }
  
  /* レガシー互換 */
  .mobile-bottom-bar .action-item {
    display: none;
  }
  
  /* =============================================
     アップロードエリアのモバイル最適化
     ============================================= */
  .upload-container {
    padding: var(--mobile-spacing-sm);
    margin: 0 var(--mobile-spacing-sm);
    border-radius: 12px;
    background: white;
    box-shadow: var(--mobile-shadow-sm);
    border: 1px solid #e5e7eb;
  }
  
  .upload-area {
    min-height: 80px;
    padding: var(--mobile-spacing-sm);
    border-radius: 10px;
    border-width: 2px;
    border-color: #e5e7eb;
    background: #f9fafb;
  }
  
  .upload-message {
    font-size: 0.8rem;
    margin: 0.5em 0;
    line-height: 1.4;
    color: #64748b;
    text-align: center;
  }
  
  .upload-message small {
    font-size: 0.65rem;
    opacity: 0.8;
    display: block;
    margin-top: 4px;
    color: #94a3b8;
  }
  
  /* カメラボタンの強調表示 */
  .camera-button {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--mobile-primary) 0%, var(--mobile-accent) 100%);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    letter-spacing: 0.01em;
    margin-top: var(--mobile-spacing-xs);
  }
  
  .camera-button:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(102, 126, 234, 0.2);
  }
  
  /* =============================================
     プレビューアクションボタン - 横並びコンパクト
     ============================================= */
  .preview-actions {
    display: flex;
    flex-direction: row;
    gap: 6px;
    margin: var(--mobile-spacing-sm);
    padding: 0;
  }
  
  .preview-actions.always-show {
    display: flex !important;
  }
  
  .preview-button,
  .settings-button {
    flex: 1;
    min-height: 40px;
    justify-content: center;
    margin: 0 !important;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 10px;
    letter-spacing: 0;
    padding: 8px 10px;
    gap: 5px;
  }
  
  .preview-button i,
  .settings-button i {
    font-size: 0.85rem;
  }
  
  .preview-count {
    font-size: 0.6rem;
    padding: 2px 5px;
    margin-left: 3px;
    border-radius: 6px;
  }
  
  /* ボタン内テキストを短縮 */
  .preview-button .btn-text,
  .settings-button .btn-text {
    display: none;
  }
  
  .preview-button::after {
    content: "一括回転";
    font-size: 0.7rem;
  }
  
  .settings-button::after {
    content: "メール設定";
    font-size: 0.7rem;
  }
  
  /* =============================================
     サマリーダッシュボード - コンパクト3列グリッド
     ============================================= */
  .summary-dashboard,
  #initial-summary {
    margin: var(--mobile-spacing-sm) !important;
    padding: var(--mobile-spacing-sm);
    border-radius: 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
  }
  
  .dashboard-header {
    margin-bottom: var(--mobile-spacing-sm);
    text-align: center;
  }
  
  .dashboard-title {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: #64748b;
    text-transform: uppercase;
  }
  
  .dashboard-title i {
    font-size: 0.7rem;
    margin-right: 5px;
  }
  
  .dashboard-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  
  .metric-card {
    padding: var(--mobile-spacing-sm) var(--mobile-spacing-xs);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 10px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
    min-height: auto;
  }
  
  .metric-card.primary {
    background: linear-gradient(135deg, var(--mobile-primary) 0%, var(--mobile-accent) 100%);
    border: none;
  }
  
  .metric-card.primary .metric-number,
  .metric-card.primary .metric-label,
  .metric-card.primary .metric-subtitle {
    color: white;
  }
  
  .metric-card.primary .metric-icon {
    background: rgba(255,255,255,0.2);
    color: white;
  }
  
  .metric-card:hover {
    transform: none;
  }
  
  .metric-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .metric-number {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
  }
  
  .metric-card.secondary .metric-number {
    font-size: 1.4rem;
    color: #374151;
  }
  
  .metric-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: #64748b;
    text-align: center;
    line-height: 1.2;
    word-break: keep-all;
    overflow-wrap: break-word;
  }
  
  .metric-card.primary .metric-label {
    color: rgba(255,255,255,0.9);
  }
  
  .metric-subtitle {
    display: none;
  }
  
  .metric-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }
  
  /* =============================================
     名刺リスト - モバイルカード表示（改善版）
     ============================================= */
  .results-container {
    flex-direction: column;
    margin: var(--mobile-spacing-sm);
    gap: var(--mobile-spacing-sm);
  }
  
  .data-grid {
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: var(--mobile-shadow-sm);
  }
  
  .grid-header {
    padding: var(--mobile-spacing-sm) var(--mobile-spacing-md);
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }
  
  .grid-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    color: white;
    margin-bottom: 2px;
  }
  
  .grid-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    width: 100%;
  }
  
  .search-box {
    flex: 1 1 100%;
    min-width: 0;
    height: 36px;
    border-radius: 18px;
    padding: 0 14px;
    font-size: 0.85rem;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    margin-bottom: 4px;
  }
  
  .search-box::placeholder {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
  }
  
  .control-button {
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 17px;
    font-size: 0.7rem;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    display: flex;
    align-items: center;
    gap: 4px;
  }
  
  .control-button i {
    font-size: 0.8rem;
  }
  
  /* ボタンのテキストを表示 */
  .control-button span {
    display: inline;
  }
  
  /* モバイルカードスタイル */
  .data-table-container {
    padding: 0;
    background: #f8fafc;
  }
  
  /* テーブルをカード形式で表示 */
  .data-grid .data-table {
    display: block;
  }
  
  .data-grid .data-table thead {
    display: none;
  }
  
  .data-grid .data-table tbody {
    display: flex;
    flex-direction: column;
    gap: var(--mobile-spacing-sm);
    padding: var(--mobile-spacing-sm);
  }
  
  .data-grid .data-table tr {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    background: white;
    border-radius: 12px;
    padding: var(--mobile-spacing-md);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    border: 1px solid #e5e7eb;
    transition: all 0.15s ease;
  }
  
  .data-grid .data-table tr:active {
    transform: scale(0.99);
    background: #f9fafb;
  }
  
  .data-grid .data-table td {
    display: flex;
    align-items: center;
    padding: 4px 0;
    border: none;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #374151;
  }
  
  .data-grid .data-table td::before {
    content: attr(data-label);
    font-weight: 500;
    color: #9ca3af;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    min-width: 50px;
    flex-shrink: 0;
    margin-right: 8px;
  }
  
  /* 名前（最初のセル）- ヒーローセクション */
  .data-grid .data-table td:first-child {
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid #f3f4f6;
    display: block;
  }
  
  .data-grid .data-table td:first-child::before {
    display: none;
  }
  
  .data-grid .data-table td:first-child .data-cell {
    line-height: 1.2;
  }
  
  /* 会社名 - サブタイトル */
  .data-grid .data-table td:nth-child(2) {
    font-size: 0.8rem;
    color: #6b7280;
    font-weight: 500;
    padding-top: 0;
  }
  
  .data-grid .data-table td:nth-child(2)::before {
    display: none;
  }
  
  /* 役職 */
  .data-grid .data-table td:nth-child(3) {
    font-size: 0.75rem;
    color: #9ca3af;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px dashed #e5e7eb;
  }
  
  .data-grid .data-table td:nth-child(3)::before {
    display: none;
  }
  
  /* メール・電話 - コンパクト表示 */
  .data-grid .data-table td:nth-child(4),
  .data-grid .data-table td:nth-child(5) {
    font-size: 0.75rem;
    color: #374151;
    padding: 2px 0;
  }
  
  .data-grid .data-table td:nth-child(4)::before,
  .data-grid .data-table td:nth-child(5)::before {
    min-width: 40px;
    font-size: 0.6rem;
  }
  
  /* アクションセル - フローティングボタン */
  .data-grid .data-table td:last-child {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 6px;
    padding-top: 8px;
    margin-top: 6px;
    border-top: 1px solid #f3f4f6;
  }
  
  .data-grid .data-table td:last-child::before {
    display: none;
  }
  
  .email-btn {
    min-width: 40px;
    min-height: 40px;
    border-radius: 10px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  /* 空の状態メッセージ */
  .data-grid .data-table td[colspan] {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 16px !important;
    background: #f9fafb;
    border-radius: 12px;
    margin: 8px;
  }
  
  .data-grid .data-table td[colspan] i {
    font-size: 32px !important;
    color: #d1d5db !important;
    margin-bottom: 12px !important;
  }
  
  .data-grid .data-table td[colspan] div:first-of-type {
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    color: #6b7280 !important;
    margin-bottom: 4px !important;
  }
  
  .data-grid .data-table td[colspan] div:last-of-type {
    font-size: 0.75rem !important;
    color: #9ca3af !important;
  }
  
  /* =============================================
     詳細プレビューパネル - フルスクリーンシート
     ============================================= */
  .preview-panel,
  #pdf-preview-panel,
  #initial-results .preview-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 9500 !important;
    border-radius: 0 !important;
    max-width: none !important;
    flex: none !important;
    margin: 0 !important;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex !important;
    flex-direction: column !important;
    background: #fff !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  .preview-panel.active,
  #pdf-preview-panel.active,
  #initial-results .preview-panel.active {
    transform: translateY(0) !important;
  }
  
  .preview-header {
    padding: var(--mobile-spacing-lg);
    padding-top: calc(var(--mobile-spacing-lg) + var(--safe-area-top));
    position: relative;
    flex-shrink: 0;
  }
  
  /* スワイプインジケーター */
  .preview-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.4);
    border-radius: 2px;
  }
  
  /* 閉じるボタン */
  .preview-header .close-preview-btn {
    position: absolute;
    right: var(--mobile-spacing-md);
    top: calc(var(--mobile-spacing-md) + var(--safe-area-top));
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  
  .preview-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--mobile-spacing-md);
    padding-bottom: calc(var(--mobile-spacing-xl) + var(--safe-area-bottom));
  }
  
  .preview-title {
    font-size: 1.1rem;
    font-weight: 700;
  }
  
  .preview-empty i {
    font-size: 2.5rem;
    margin-bottom: 12px;
  }
  
  .preview-empty p {
    font-size: 0.9rem;
    color: #6b7280;
  }
  
  .card-image {
    min-height: 200px;
    max-height: 40vh;
    border-radius: 12px;
  }
  
  .card-image img {
    max-height: 35vh;
  }
  
  .card-image .loading,
  .card-image .error {
    font-size: 0.85rem;
  }
  
  .card-details {
    border-radius: 12px;
    padding: var(--mobile-spacing-md);
  }
  
  .detail-group {
    margin-bottom: var(--mobile-spacing-md);
  }
  
  .detail-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #9ca3af;
    margin-bottom: 6px;
    font-weight: 600;
  }
  
  .detail-value {
    font-size: 0.95rem;
    padding: 12px 14px;
    min-height: var(--tap-target-min);
    display: flex;
    align-items: center;
    border-radius: 10px;
    line-height: 1.5;
    color: #374151;
  }
  
  .detail-value.editable:hover {
    background: #f8f9fa;
  }
  
  .detail-actions {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    padding: var(--mobile-spacing-md);
    padding-bottom: calc(var(--mobile-spacing-md) + var(--safe-area-bottom));
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: var(--mobile-spacing-sm);
    flex-direction: row;
    margin: 0;
  }
  
  .detail-actions .action-button {
    min-height: var(--tap-target-comfortable);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
  }
  
  /* =============================================
     回転コントロール
     ============================================= */
  .rotation-control {
    padding: var(--mobile-spacing-md);
    border-radius: 12px;
  }
  
  .rotation-header {
    margin-bottom: 10px;
  }
  
  .rotation-title {
    font-size: 0.85rem;
    font-weight: 600;
  }
  
  .rotation-value {
    font-size: 0.8rem;
    padding: 4px 10px;
  }
  
  .rotation-buttons {
    gap: var(--mobile-spacing-sm);
    margin-bottom: var(--mobile-spacing-md);
  }
  
  .rotation-btn {
    min-width: 50px;
    min-height: var(--tap-target-min);
    border-radius: 10px;
    font-size: 0.75rem;
    padding: 8px 6px;
  }
  
  .rotation-btn i {
    font-size: 0.9rem;
  }
  
  .rotation-btn.large-btn {
    min-width: 70px;
    font-size: 0.8rem;
  }
  
  .rotation-slider {
    height: 8px;
    border-radius: 4px;
  }
  
  .rotation-slider::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }
  
  /* 回転ツールバー */
  .rotation-toolbar {
    padding: 10px;
    border-radius: 10px;
  }
  
  .rotation-toolbar .rotation-btn {
    font-size: 0.8rem;
    padding: 8px 12px;
  }
  
  .rotation-toolbar .rotation-note {
    font-size: 0.7rem;
    display: none; /* モバイルでは非表示 */
  }
  
  .rotation-toolbar .rotation-value {
    font-size: 0.75rem;
  }
  
  /* =============================================
     プレビューモーダル
     ============================================= */
  .preview-modal {
    align-items: flex-end;
    padding: 0;
  }
  
  .preview-modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 95vh;
    border-radius: 20px 20px 0 0;
    position: relative;
    transform: translateY(0);
    top: auto;
    left: auto;
  }
  
  .preview-modal-header {
    padding: var(--mobile-spacing-md) var(--mobile-spacing-lg);
    padding-top: calc(var(--mobile-spacing-md) + 12px);
    border-radius: 20px 20px 0 0;
    flex-direction: column;
    align-items: center;
    position: relative;
  }
  
  /* ドラッグハンドル */
  .preview-modal-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.4);
    border-radius: 2px;
  }
  
  .preview-modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: var(--mobile-spacing-sm);
  }
  
  .preview-modal-controls {
    width: 100%;
    flex-direction: column;
    gap: var(--mobile-spacing-md);
  }
  
  .selection-actions {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .modern-btn {
    min-height: var(--tap-target-min);
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 10px;
  }
  
  .modern-btn i {
    font-size: 0.9rem;
  }
  
  .selection-count {
    font-size: 0.8rem;
  }
  
  .modern-btn-close {
    position: absolute;
    top: 12px;
    right: var(--mobile-spacing-md);
  }
  
  .preview-modal-body {
    padding: var(--mobile-spacing-md);
    padding-bottom: calc(var(--mobile-spacing-xl) + var(--safe-area-bottom));
  }
  
  .stats {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: var(--mobile-spacing-md);
    text-align: center;
  }
  
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--mobile-spacing-md);
  }
  
  .card-item {
    height: auto;
    aspect-ratio: 16/10;
    border-radius: 10px;
  }
  
  .card-item .selection-checkbox {
    width: 24px;
    height: 24px;
    top: 6px;
    left: 6px;
  }
  
  /* 一括回転コントロール */
  .bulk-rotation-control {
    padding: var(--mobile-spacing-md);
    border-radius: 12px;
    margin-bottom: var(--mobile-spacing-md);
  }
  
  .bulk-rotation-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
  }
  
  .bulk-rotation-control .rotation-buttons {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .rotation-btn span {
    font-size: 0.7rem;
  }
  
  .fine-control-label {
    font-size: 0.75rem;
  }
  
  /* =============================================
     詳細モーダル
     ============================================= */
  .detail-modal {
    align-items: flex-end;
    padding: 0;
  }
  
  .detail-modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    margin: 0;
    border-radius: 20px 20px 0 0;
  }
  
  .detail-modal-header {
    padding: var(--mobile-spacing-md);
    border-radius: 20px 20px 0 0;
    position: relative;
  }
  
  /* ドラッグハンドル */
  .detail-modal-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.4);
    border-radius: 2px;
  }
  
  .modal-title {
    font-size: 0.95rem;
    font-weight: 600;
    padding-top: 8px;
  }
  
  .modal-nav {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  
  .nav-btn {
    min-width: var(--tap-target-min);
    min-height: var(--tap-target-min);
    border-radius: 10px;
    font-size: 1rem;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    cursor: pointer;
  }
  
  .nav-btn:disabled {
    opacity: 0.4;
  }
  
  #modal-close {
    font-size: 1.5rem;
    margin-left: 8px;
    cursor: pointer;
  }
  
  .detail-modal-body {
    padding: var(--mobile-spacing-md);
    padding-bottom: calc(var(--mobile-spacing-xl) + var(--safe-area-bottom));
  }
  
  .modal-image {
    max-height: 50vh;
    border-radius: 12px;
  }
  
  .modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--mobile-spacing-sm);
    justify-content: center;
    margin-top: var(--mobile-spacing-md);
    padding: var(--mobile-spacing-md);
    background: #f8f9fa;
    border-radius: 12px;
  }
  
  .action-btn,
  #rotate-left,
  #rotate-right,
  #reset-rotation {
    min-height: var(--tap-target-min);
    padding: 10px 16px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    flex: 1;
    min-width: 90px;
    border: 1px solid #dee2e6;
    background: white;
    color: #495057;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  
  .action-btn i,
  #rotate-left i,
  #rotate-right i,
  #reset-rotation i {
    font-size: 0.9rem;
  }
  
  /* =============================================
     設定モーダル
     ============================================= */
  .settings-modal-content {
    width: 100%;
    max-width: 100%;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }
  
  .settings-modal-header {
    padding: var(--mobile-spacing-md) var(--mobile-spacing-lg);
    padding-top: calc(var(--mobile-spacing-md) + var(--safe-area-top));
    border-radius: 0;
  }
  
  .settings-modal-title {
    font-size: 1.15rem;
    font-weight: 700;
  }
  
  .modal-close {
    min-width: var(--tap-target-min);
    min-height: var(--tap-target-min);
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
  }
  
  .settings-modal-body {
    padding: var(--mobile-spacing-lg);
    padding-bottom: calc(var(--mobile-spacing-xl) + var(--safe-area-bottom));
  }
  
  .form-group {
    margin-bottom: var(--mobile-spacing-lg);
  }
  
  .form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
    display: block;
  }
  
  .form-group label span {
    font-size: 0.75rem;
    color: #9ca3af;
    font-weight: 400;
  }
  
  .form-group input,
  .form-group textarea {
    min-height: var(--tap-target-comfortable);
    padding: 14px 16px;
    font-size: 16px; /* iOS zoom防止 */
    border-radius: 10px;
    line-height: 1.5;
    color: #1f2937;
  }
  
  .form-group input::placeholder,
  .form-group textarea::placeholder {
    font-size: 0.9rem;
    color: #9ca3af;
  }
  
  .form-group textarea {
    min-height: 80px;
    resize: vertical;
  }
  
  .form-group small {
    font-size: 0.75rem;
    color: #6b7280;
    line-height: 1.5;
    margin-top: 6px;
  }
  
  .email-client-selector {
    flex-direction: column;
    gap: var(--mobile-spacing-md);
  }
  
  .email-client-card {
    padding: var(--mobile-spacing-md);
    border-radius: 12px;
    min-height: var(--tap-target-comfortable);
  }
  
  .email-client-name {
    font-size: 0.9rem;
    font-weight: 600;
  }
  
  .email-client-desc {
    font-size: 0.75rem;
    color: #6b7280;
  }
  
  .form-actions {
    flex-direction: column-reverse;
    gap: var(--mobile-spacing-md);
    padding-top: var(--mobile-spacing-lg);
    margin-top: var(--mobile-spacing-lg);
  }
  
  .btn-primary,
  .btn-secondary {
    width: 100%;
    min-height: var(--tap-target-comfortable);
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    justify-content: center;
    letter-spacing: 0.01em;
  }
  
  .btn-primary i,
  .btn-secondary i {
    font-size: 0.9rem;
  }
  
  /* =============================================
     CSVビューワー
     ============================================= */
  .csv-viewer-modal {
    padding: 0;
    align-items: flex-end;
  }
  
  .csv-viewer-content {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 20px 20px 0 0;
  }
  
  .csv-viewer-header {
    padding: var(--mobile-spacing-md);
    padding-top: calc(var(--mobile-spacing-md) + var(--safe-area-top));
    flex-wrap: wrap;
    gap: var(--mobile-spacing-sm);
  }
  
  .csv-viewer-title {
    font-size: 1rem;
    font-weight: 700;
    width: 100%;
    text-align: center;
    margin-bottom: var(--mobile-spacing-sm);
  }
  
  .csv-viewer-title i {
    font-size: 0.9rem;
  }
  
  .csv-viewer-controls {
    width: 100%;
    justify-content: space-between;
  }
  
  .csv-search-input {
    flex: 1;
    min-height: var(--tap-target-min);
    border-radius: 10px;
    font-size: 16px; /* iOS zoom防止 */
  }
  
  .csv-search-input::placeholder {
    font-size: 0.85rem;
  }
  
  .csv-export-btn,
  .csv-viewer-close {
    min-width: var(--tap-target-min);
    min-height: var(--tap-target-min);
    border-radius: 10px;
    font-size: 0.9rem;
  }
  
  .csv-viewer-body {
    padding-bottom: var(--safe-area-bottom);
  }
  
  .csv-viewer-table th {
    padding: 10px 8px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  
  .csv-viewer-table td {
    padding: 10px 8px;
    font-size: 0.8rem;
    line-height: 1.4;
  }
  
  .csv-viewer-footer {
    padding: 10px 16px;
  }
  
  .csv-viewer-info {
    font-size: 0.8rem;
  }
  
  /* =============================================
     カメラモーダル
     ============================================= */
  .camera-modal {
    padding: 0;
    padding-top: var(--safe-area-top);
    padding-bottom: var(--safe-area-bottom);
  }
  
  .camera-modal-inner {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: var(--mobile-spacing-md);
    padding-top: calc(var(--mobile-spacing-md) + var(--safe-area-top));
    padding-bottom: calc(var(--mobile-spacing-md) + var(--safe-area-bottom));
  }
  
  .camera-video-wrapper {
    border-radius: 12px;
  }
  
  .camera-guide-label {
    font-size: 0.75rem;
    padding: 6px 12px;
    font-weight: 500;
  }
  
  .camera-guide-label i {
    font-size: 0.8rem;
  }
  
  .camera-controls {
    padding: 0;
    gap: var(--mobile-spacing-sm);
  }
  
  .camera-status {
    font-size: 0.8rem;
  }
  
  .camera-btn {
    min-width: 100px;
    min-height: var(--tap-target-comfortable);
    padding: 12px 18px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 25px;
    letter-spacing: 0.02em;
  }
  
  .camera-btn i {
    font-size: 0.9rem;
  }
  
  .camera-buttons {
    gap: var(--mobile-spacing-sm);
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .recording-timer-inline {
    max-width: 100%;
    padding: 10px 16px;
  }
  
  .timer-text {
    font-size: 0.75rem;
  }
  
  .timer-count {
    font-size: 0.9rem;
  }
  
  /* =============================================
     タップフィードバック
     ============================================= */
  .tap-feedback {
    position: relative;
    overflow: hidden;
  }
  
  .tap-feedback::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(0,0,0,0.1) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.3s ease;
    pointer-events: none;
  }
  
  .tap-feedback:active::after {
    transform: translate(-50%, -50%) scale(2);
  }
  
  /* =============================================
     スワイプジェスチャーインジケーター
     ============================================= */
  .swipe-indicator {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    animation: swipeHint 2s ease-in-out infinite;
  }
  
  @keyframes swipeHint {
    0%, 100% { opacity: 0.5; transform: translateX(-50%) translateY(0); }
    50% { opacity: 1; transform: translateX(-50%) translateY(-5px); }
  }
  
  /* =============================================
     エンプティステート
     ============================================= */
  .empty-state {
    padding: var(--mobile-spacing-xl);
    text-align: center;
  }
  
  .empty-state h3 {
    font-size: 1.1em;
    margin-bottom: var(--mobile-spacing-sm);
  }
  
  .empty-state p {
    font-size: 14px;
    color: #6b7280;
  }
  
  /* =============================================
     プルトゥリフレッシュヒント
     ============================================= */
  .pull-to-refresh-hint {
    position: fixed;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--mobile-primary);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: top 0.3s ease;
    z-index: 9999;
  }
  
  .pull-to-refresh-hint.visible {
    top: calc(10px + var(--safe-area-top));
  }
  
  /* =============================================
     ローディングステート
     ============================================= */
  .mobile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--mobile-spacing-xl);
    gap: var(--mobile-spacing-md);
  }
  
  .mobile-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--mobile-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
  
  @keyframes spin {
    to { transform: rotate(360deg); }
  }
  
  .mobile-loading .loading-text {
    font-size: 14px;
    color: #6b7280;
  }
  
  /* =============================================
     横向き対応
     ============================================= */
  @media (orientation: landscape) and (max-height: 500px) {
    .mobile-bottom-bar {
      padding: 0;
      bottom: 6px;
      border-radius: 16px;
      flex-direction: row;
      align-items: center;
    }
    
    .bottom-nav-tabs {
      padding: 6px 10px;
      gap: 3px;
    }
    
    .nav-tab {
      padding: 6px 12px;
      font-size: 0.68rem;
    }
    
    .nav-tab i {
      font-size: 0.85rem;
    }
    
    .fab-camera {
      position: relative;
      top: 0;
      left: 0;
      transform: none;
      width: 38px;
      height: 38px;
      font-size: 16px;
      margin: 0 10px;
    }
    
    .fab-camera:active {
      transform: scale(0.92);
    }
    
    .preview-modal-content,
    .detail-modal-content,
    .settings-modal-content {
      max-height: 100vh;
      border-radius: 0;
    }
  }
}

/* =============================================
   タブレット対応 (769px - 1024px)
   ============================================= */
@media (min-width: 769px) and (max-width: 1024px) {
  .mobile-bottom-bar {
    display: none !important;
  }
  
  .results-container {
    flex-direction: row;
    margin: var(--mobile-spacing-lg);
  }
  
  .preview-panel {
    position: relative;
    transform: none;
    flex: 0 0 400px;
    border-radius: 12px;
  }
  
  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* =============================================
   デスクトップ - ボトムバー非表示
   ============================================= */
@media (min-width: 769px) {
  .mobile-bottom-bar {
    display: none !important;
  }
  
  body {
    padding-bottom: 0;
  }
}

/* =============================================
   PDFめくり専用モバイルスタイル
   ============================================= */
@media (max-width: 768px) {
  /* PDFサマリーダッシュボード - 名刺めくりと同じ3列グリッド */
  #pdf-summary-root {
    margin-top: var(--mobile-spacing-md);
  }
  
  #pdf-summary-root .summary-dashboard {
    margin: 0 var(--mobile-spacing-sm) var(--mobile-spacing-sm);
    padding: var(--mobile-spacing-sm);
    border-radius: 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
  }
  
  #pdf-summary-root .dashboard-header {
    margin-bottom: var(--mobile-spacing-sm);
    text-align: center;
  }
  
  #pdf-summary-root .dashboard-title {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: #64748b;
    text-transform: uppercase;
  }
  
  #pdf-summary-root .dashboard-title i {
    font-size: 0.7rem;
    margin-right: 5px;
  }
  
  #pdf-summary-root .dashboard-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  
  #pdf-summary-root .metric-card {
    padding: var(--mobile-spacing-sm) var(--mobile-spacing-xs);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-radius: 10px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
    min-height: auto;
  }
  
  #pdf-summary-root .metric-card.primary {
    background: linear-gradient(135deg, var(--mobile-primary) 0%, var(--mobile-accent) 100%);
    border: none;
  }
  
  #pdf-summary-root .metric-card.primary .metric-number,
  #pdf-summary-root .metric-card.primary .metric-label,
  #pdf-summary-root .metric-card.primary .metric-subtitle {
    color: white;
  }
  
  #pdf-summary-root .metric-card.primary .metric-icon {
    background: rgba(255,255,255,0.2);
    color: white;
  }
  
  #pdf-summary-root .metric-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  #pdf-summary-root .metric-number {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
  }
  
  #pdf-summary-root .metric-card.secondary .metric-number {
    font-size: 1.4rem;
    color: #374151;
  }
  
  #pdf-summary-root .metric-label {
    font-size: 0.6rem;
    font-weight: 600;
    color: #64748b;
    text-align: center;
    line-height: 1.2;
    word-break: keep-all;
  }
  
  #pdf-summary-root .metric-card.primary .metric-label {
    color: rgba(255,255,255,0.9);
  }
  
  #pdf-summary-root .metric-subtitle {
    display: none;
  }
  
  #pdf-summary-root .metric-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }
  
  /* PDFめくり結果コンテナ */
  #pdf-results-root {
    margin-top: var(--mobile-spacing-md);
  }
  
  /* ファイルフィルター（セレクトボックス） */
  .file-filter {
    height: 38px;
    padding: 8px 12px;
    font-size: 0.75rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    min-width: 80px;
    max-width: 100px;
  }
  
  .file-filter option {
    background: #667eea;
    color: white;
  }
  
  /* PDFめくり用テーブル - カード表示 */
  #pdf-results-root .data-table {
    display: block;
  }
  
  #pdf-results-root .data-table thead {
    display: none;
  }
  
  #pdf-results-root .data-table tbody {
    display: flex;
    flex-direction: column;
    gap: var(--mobile-spacing-sm);
    padding: var(--mobile-spacing-sm);
  }
  
  #pdf-results-root .data-table tr {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    padding: var(--mobile-spacing-md);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    border: 1px solid #e5e7eb;
  }
  
  #pdf-results-root .data-table tr.empty-row {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background: #f9fafb;
  }
  
  #pdf-results-root .data-table tr:active:not(.empty-row) {
    transform: scale(0.99);
    background: #f9fafb;
  }
  
  #pdf-results-root .data-table td {
    display: flex;
    align-items: center;
    padding: 3px 0;
    border: none;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #374151;
  }
  
  #pdf-results-root .data-table td::before {
    content: attr(data-label);
    font-weight: 500;
    color: #9ca3af;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    min-width: 55px;
    flex-shrink: 0;
  }
  
  /* ファイル名 - ヘッダー */
  #pdf-results-root .data-table td:first-child {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1f2937;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid #f3f4f6;
    display: block;
    word-break: break-all;
  }
  
  #pdf-results-root .data-table td:first-child::before {
    display: none;
  }
  
  /* 店名 */
  #pdf-results-root .data-table td:nth-child(2) {
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
  }
  
  /* 日付 */
  #pdf-results-root .data-table td:nth-child(3) {
    font-size: 0.75rem;
    color: #6b7280;
  }
  
  /* 金額 - 強調 */
  #pdf-results-root .data-table td:nth-child(4) {
    font-size: 1rem;
    font-weight: 700;
    color: var(--mobile-primary);
  }
  
  /* 単位 */
  #pdf-results-root .data-table td:nth-child(5) {
    font-size: 0.7rem;
    color: #9ca3af;
  }
  
  /* カテゴリ */
  #pdf-results-root .data-table td:nth-child(6) {
    font-size: 0.75rem;
    color: #6b7280;
  }
  
  /* メモ */
  #pdf-results-root .data-table td:nth-child(7) {
    font-size: 0.75rem;
    color: #9ca3af;
    font-style: italic;
  }
  
  /* PDFプレビュー - モバイル用フルスクリーン */
  #pdf-preview-panel {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 9500 !important;
    border-radius: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex !important;
    flex-direction: column !important;
    background: #fff !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  #pdf-preview-panel.active {
    transform: translateY(0) !important;
  }
  
  /* PDFプレビューフレーム */
  .pdf-preview-frame {
    padding: 8px;
    margin-bottom: 12px;
  }
  
  .pdf-frame {
    min-height: 300px;
    max-height: 40vh;
  }
  
  /* PDFツールバー */
  .pdf-preview-toolbar {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .pdf-preview-open-btn {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
  
  /* ローディング表示 */
  .loading {
    padding: var(--mobile-spacing-md);
  }
  
  .loading p {
    font-size: 0.85rem;
  }
  
  /* PDFプレビューパネルの閉じるボタン */
  #pdf-preview-panel .preview-header {
    position: relative;
    padding-top: calc(var(--mobile-spacing-lg) + var(--safe-area-top));
  }
  
  #pdf-preview-panel .preview-header .close-preview-btn {
    position: absolute;
    right: var(--mobile-spacing-md);
    top: calc(var(--mobile-spacing-md) + var(--safe-area-top));
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }
  
  /* スワイプインジケーター */
  #pdf-preview-panel .preview-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: rgba(255,255,255,0.4);
    border-radius: 2px;
  }
  
  /* PDFプレビューパネルのコンテンツ */
  #pdf-preview-panel .preview-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--mobile-spacing-md);
    padding-bottom: calc(var(--mobile-spacing-xl) + var(--safe-area-bottom));
  }
  
  /* PDFプレビューフレームのモバイル最適化 */
  #pdf-preview-panel .pdf-preview-frame {
    padding: var(--mobile-spacing-sm);
    margin-bottom: var(--mobile-spacing-md);
    border-radius: 10px;
  }
  
  #pdf-preview-panel .pdf-frame {
    min-height: 250px;
    max-height: 35vh;
    border-radius: 8px;
  }
  
  #pdf-preview-panel .pdf-preview-toolbar {
    margin-bottom: var(--mobile-spacing-sm);
  }
  
  #pdf-preview-panel .pdf-preview-open-btn {
    padding: 10px 14px;
    font-size: 0.8rem;
    width: 100%;
    justify-content: center;
    border-radius: 8px;
  }
  
  /* 詳細フォームのモバイル最適化 */
  #pdf-preview-panel .card-details {
    background: white;
    border-radius: 12px;
    padding: var(--mobile-spacing-md);
  }
  
  #pdf-preview-panel .detail-group {
    margin-bottom: var(--mobile-spacing-md);
  }
  
  #pdf-preview-panel .detail-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9ca3af;
    margin-bottom: 6px;
    font-weight: 600;
  }
  
  #pdf-preview-panel .detail-value {
    font-size: 0.9rem;
    padding: 12px 14px;
    min-height: var(--tap-target-min);
    display: flex;
    align-items: center;
    border-radius: 10px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    line-height: 1.5;
    color: #374151;
  }
  
  #pdf-preview-panel .detail-value.editable {
    background: white;
    border: 1px solid #e5e7eb;
  }
  
  #pdf-preview-panel .detail-value.editable:focus {
    border-color: var(--mobile-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
  }
  
  #pdf-preview-panel .detail-input,
  #pdf-preview-panel .detail-select,
  #pdf-preview-panel .detail-textarea {
    font-size: 16px; /* iOS拡大防止 */
    padding: 12px 14px;
    min-height: var(--tap-target-min);
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    background: white;
  }
  
  #pdf-preview-panel .detail-input:focus,
  #pdf-preview-panel .detail-select:focus,
  #pdf-preview-panel .detail-textarea:focus {
    border-color: var(--mobile-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
  }
  
  #pdf-preview-panel .detail-textarea {
    min-height: 80px;
  }
  
  #pdf-preview-panel .detail-amount-row {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  #pdf-preview-panel .detail-amount-unit {
    font-size: 0.9rem;
    color: #6b7280;
    font-weight: 500;
  }
}

/* =============================================
   領収書めくり専用モバイルスタイル
   ============================================= */
@media (max-width: 768px) {
  /* 領収書めくり結果コンテナ - サマリーと同じ幅 */
  #initial-results {
    margin: var(--mobile-spacing-sm) !important;
    padding: 0;
  }
  
  /* preview-panelをフローから除外 */
  #initial-results .preview-panel {
    position: fixed;
  }
  
  #initial-results .data-grid {
    border-radius: 12px;
    overflow: hidden;
    margin: 0;
  }
  
  #initial-results .grid-header {
    padding: var(--mobile-spacing-sm) var(--mobile-spacing-md);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  }
  
  #initial-results .grid-title {
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    color: white;
  }
  
  #initial-results .grid-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }
  
  #initial-results .search-box {
    flex: 1 1 100%;
    height: 36px;
    border-radius: 18px;
    margin-bottom: 4px;
  }
  
  #initial-results .control-button {
    min-height: 34px;
    padding: 6px 12px;
    border-radius: 17px;
    font-size: 0.7rem;
  }
  
  /* 領収書めくり用テーブル - カード表示 */
  #initial-results .data-table {
    display: block;
  }
  
  #initial-results .data-table thead {
    display: none;
  }
  
  #initial-results .data-table tbody {
    display: flex;
    flex-direction: column;
    gap: var(--mobile-spacing-sm);
    padding: var(--mobile-spacing-sm);
  }
  
  #initial-results .data-table tr {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 12px;
    padding: var(--mobile-spacing-md);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
    border: 1px solid #e5e7eb;
  }
  
  #initial-results .data-table tr:active {
    transform: scale(0.99);
    background: #f9fafb;
  }
  
  #initial-results .data-table td {
    display: flex;
    align-items: center;
    padding: 3px 0;
    border: none;
    font-size: 0.8rem;
    line-height: 1.4;
    color: #374151;
  }
  
  #initial-results .data-table td::before {
    content: attr(data-label);
    font-weight: 500;
    color: #9ca3af;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    min-width: 55px;
    flex-shrink: 0;
  }
  
  /* 店名 - ヘッダー */
  #initial-results .data-table td:first-child {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid #f3f4f6;
    display: block;
  }
  
  #initial-results .data-table td:first-child::before {
    display: none;
  }
  
  /* 日付 */
  #initial-results .data-table td:nth-child(2) {
    font-size: 0.75rem;
    color: #6b7280;
  }
  
  /* 金額 - 強調 */
  #initial-results .data-table td:nth-child(3) {
    font-size: 1rem;
    font-weight: 700;
    color: var(--mobile-primary);
  }
  
  /* 単位 */
  #initial-results .data-table td:nth-child(4) {
    font-size: 0.7rem;
    color: #9ca3af;
  }
  
  /* カテゴリ */
  #initial-results .data-table td:nth-child(5) {
    font-size: 0.75rem;
    color: #6b7280;
  }
  
  /* メモ */
  #initial-results .data-table td:nth-child(6) {
    font-size: 0.75rem;
    color: #9ca3af;
    font-style: italic;
  }
}

