/* mobile.css - スマホ幅 (760px 以下) のレイアウト (v63)
   開閉は js/51_mobile.js。PC 幅には影響しない。 */

.mob-only, .mob-backdrop { display: none; }

@media (max-width: 760px) {
  /* ── 全体: 画面の高さはアドレスバーの出入りに追従 (dvh) ── */
  #app { height: 100vh; height: 100dvh; position: relative; }
  body { font-size: 14px; -webkit-text-size-adjust: 100%; }
  /* iOS は 16px 未満の入力欄でフォーカス時に勝手に拡大するので 16px に */
  input, select, textarea { font-size: 16px; }
  .resize-handle { display: none !important; }

  /* ── 左サイドバー: 左から出るドロワー ── */
  #sb {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: min(78vw, 240px) !important;
    z-index: 9500;
    transform: translateX(-102%);
    transition: transform .22s ease;
    box-shadow: none;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
  }
  #app.sb-open #sb { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.25); }

  /* ── 右パネル: 右から出るドロワー ── */
  #app .rp {
    position: fixed; top: 0; bottom: 0; right: 0;
    width: min(92vw, 380px) !important;
    z-index: 9500;
    display: flex;
    transform: none;
    transition: transform .22s ease;
    box-shadow: -4px 0 24px rgba(0,0,0,.25);
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    padding-right: calc(8px + env(safe-area-inset-right));
  }
  #app.rp-collapsed .rp { display: flex; width: min(92vw, 380px) !important; transform: translateX(104%); box-shadow: none; }
  /* 右パネルの列数指定はスマホでは 1 列 */
  .rp-side-list[data-cols] { grid-template-columns: 1fr !important; }

  /* ── 背景 ── */
  .mob-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 9400;
    opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  #app.sb-open .mob-backdrop,
  #app:not(.rp-collapsed) .mob-backdrop { opacity: 1; pointer-events: auto; }

  /* ── メイン ── */
  .main { width: 100%; }
  .topbar, html[data-ui="minimal"] .topbar {
    padding: calc(6px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 6px calc(10px + env(safe-area-inset-left));
  }
  .topbar-left { gap: 2px; min-width: 0; flex: 1; }
  .topbar .nav-btn, .sb-tog {
    min-width: 40px; min-height: 40px;
    padding: 0 8px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .mob-only { display: inline-flex; }
  .sb-tog { font-size: 20px; line-height: 1; margin-right: 2px; }
  .hdr-date { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-left: 4px; }
  .hdr-summary { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .hdr-summary::-webkit-scrollbar { display: none; }
  .hdr-chip { max-width: 60vw; }
  .view-root {
    padding: 10px calc(10px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) calc(10px + env(safe-area-inset-left));
  }


  /* ── 今日: 月カレンダーを詰める ── */
  .dcal-cell { min-height: 46px; padding: 3px; border-radius: 6px; }
  .dcal-day { font-size: 12px; }
  .dcal-items > div { font-size: 9px; }
  .dcal-todo { display: none; }
  .dcal-title { min-width: 0; font-size: 14px; }

  /* ── テキスト (メモ一覧): ツールバーを 2 段に ── */
  .memo-toolbar { flex-wrap: wrap; gap: 8px; padding: 8px 4px; }
  .memo-toolbar-l { flex: 1 1 100%; }
  .memo-toolbar-r { flex: 1 1 100%; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
  .memo-search { min-width: 0; max-width: none; }
  .memo-daily-toggle { white-space: nowrap; flex-shrink: 0; }
  .memo-count { margin-right: auto; }
  .memo-mode-btn, .memo-new-btn { min-height: 36px; min-width: 36px; }

  /* ── 設定: ラベルが潰れないよう、入力は必要なら下の行へ ── */
  .settings-row { flex-wrap: wrap; row-gap: 6px; padding: 8px 0; }
  .settings-row > label, .settings-row > .settings-label { flex: 1 1 200px; min-width: min(200px, 100%); }
  .settings-row select, .settings-row input[type="text"], .settings-row input[type="url"],
  .settings-row input[type="number"], .settings-row input[type="search"] { max-width: 100%; }
  .settings-row .rng { flex-wrap: wrap; }
  .settings-row .rng input[type="range"] { width: 140px; }
  .settings-row input[type="checkbox"], .settings-row input[type="radio"] { width: 20px; height: 20px; }

  /* ── 記録: 表示切替タブは横スクロール ── */
  .rv-viewers { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .rv-viewer { white-space: nowrap; flex-shrink: 0; }

  /* ── 横に長い表・ボタン列は横スクロール ── */
  .view-root table { display: block; max-width: 100%; overflow-x: auto; }
  .view-root pre { max-width: 100%; overflow-x: auto; }
  .view-root img, .view-root video { max-width: 100%; height: auto; }

  /* ── モーダル・確認ダイアログ ── */
  .modal-card {
    width: calc(100% - 16px); max-width: none;
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
  .modal-body { padding: 12px; }
  .modal-body input[type="text"], .modal-body input:not([type]), .modal-body textarea { width: 100%; max-width: 100%; }

  /* ── キャラクターの吹き出し ── */
  .msc-bubble { font-size: 12px; max-width: min(240px, 62vw); }

  /* ── トースト ── */
  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); max-width: calc(100% - 24px); }
}

/* ── メニューの並び替え (タッチ): 長押しで持ち上がる (js/04_router.js) ── */
.sbnav .sni { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.sbnav .sni.is-lifted {
  position: relative; z-index: 2;
  transform: scale(1.04);
  background: var(--bg-elev); color: var(--fg);
  outline: 2px solid var(--accent); outline-offset: -2px;
  box-shadow: 0 8px 22px rgba(0,0,0,.22);
  animation: sni-lift .22s ease-out;
}
@keyframes sni-lift {
  0%   { transform: scale(1); box-shadow: none; }
  60%  { transform: scale(1.07); }
  100% { transform: scale(1.04); }
}
@media (prefers-reduced-motion: reduce) { .sbnav .sni.is-lifted { animation: none; } }

@media (max-width: 760px) {
  .settings-section.st-fold.is-open > :not(h3) { padding-left: 4px; }
  .settings-section.st-fold > h3 { padding: 13px 4px; }
}
