/* ================================================================
   Memoria — フォーカス・ブルーグラデーション
   青は集中・認知課題の成績を高めるとされる色（青色光の覚醒効果・
   Mehta & Zhu 2009 等）。Googleブルー→インディゴ→バイオレットの
   グラデーションを主役に、白背景へ淡い青の光を漂わせる。
   フォントはGoogleマップと同じRoboto系。
   レイアウトと操作感はMaterial準拠（Healthspanのデザインシステムを継承）。
   ================================================================ */
:root {
  --grad: linear-gradient(135deg, #1a73e8 0%, #4f46e5 55%, #7c3aed 100%);
  --grad-soft: linear-gradient(135deg, rgba(26, 115, 232, 0.12), rgba(79, 70, 229, 0.12), rgba(124, 58, 237, 0.12));
  --blue: #1a73e8;
  --indigo: #4f46e5;
  --violet: #7c3aed;
  --bg: #fafbff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-2: #eff2fb;
  --outline: rgba(90, 100, 200, 0.14);
  --outline-strong: rgba(90, 100, 200, 0.30);
  --text: #1f2333;
  --text-2: #4a5068;
  --muted: #868da8;
  --red: #ef5d7a;
  --radius: 20px;
  --font: "Roboto", "Noto Sans JP", "Hiragino Sans", sans-serif;
  --font-display: "Google Sans", "Roboto", "Noto Sans JP", "Hiragino Sans", sans-serif;
  --shadow-1: 0 2px 10px rgba(85, 95, 175, 0.10);
  --shadow-2: 0 12px 40px -8px rgba(85, 95, 175, 0.28);
  --glow: 0 8px 24px -8px rgba(79, 70, 229, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  /* 下部固定の入力ボックス + タブバーに隠れないよう余白を確保する */
  padding-bottom: calc(150px + env(safe-area-inset-bottom));
}

/* 背景のオーロラ: 画面全体に淡い青〜藤色の光をにじませる */
.atmosphere {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(46% 34% at 12% 0%, rgba(147, 197, 253, 0.32), transparent 70%),
    radial-gradient(50% 36% at 92% 6%, rgba(196, 181, 253, 0.34), transparent 70%),
    radial-gradient(42% 30% at 78% 46%, rgba(165, 243, 252, 0.16), transparent 70%),
    radial-gradient(55% 40% at 6% 88%, rgba(129, 140, 248, 0.18), transparent 70%),
    var(--bg);
}

.container { max-width: 560px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 14px 24px; }

/* ブランドロゴ */
.brand { display: flex; align-items: center; justify-content: center; gap: 7px; margin: 0 0 12px; text-decoration: none; }
.brand-icon { width: 22px; height: 22px; border-radius: 6px; display: block; }
.brand-name {
  font-family: var(--font-display);
  font-size: 0.92rem; font-weight: 700; letter-spacing: 0.01em;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

h1, h2, h3 { font-family: var(--font-display); }
h1 { font-size: 1.45rem; font-weight: 500; }
h2 { font-size: 1.05rem; font-weight: 500; }

.kicker {
  font-family: var(--font-display);
  font-size: 0.66rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  margin-bottom: 2px;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; -webkit-tap-highlight-color: transparent; }

input, textarea {
  font: inherit; width: 100%;
  /* 16px固定。理由: iOS Safariは16px未満の入力欄をタップすると画面を自動ズームするため。 */
  font-size: 16px;
  border: 1px solid var(--outline-strong); border-radius: 14px;
  padding: 12px 14px;
  background: var(--surface-solid);
  color: var(--text);
  caret-color: var(--blue);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.16); }

/* 登場アニメーション */
.reveal { animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.reveal:nth-child(2) { animation-delay: 0.05s; }
.reveal:nth-child(3) { animation-delay: 0.1s; }
.reveal:nth-child(4) { animation-delay: 0.15s; }
.reveal:nth-child(5) { animation-delay: 0.2s; }
.reveal:nth-child(6) { animation-delay: 0.25s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .reveal { animation: none; } }

/* ---------------- カード ---------------- */
.card {
  position: relative;
  background: var(--surface);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  padding: 16px 15px 12px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-1);
}

/* ---------------- 入力（コンポーザー・下部固定） ---------------- */
/* チャットアプリと同じく画面下部（タブバーの上）に置く。
   理由: スマホは画面下ほど親指が届きやすく、入力の摩擦が最小になるため。 */
.composer {
  position: fixed; left: 0; right: 0; z-index: 45;
  bottom: calc(68px + env(safe-area-inset-bottom));
  max-width: 560px; margin: 0 auto;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--outline);
}
.composer-row { display: flex; align-items: flex-end; gap: 8px; }
.attach-btn {
  flex: none;
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 999px;
  color: var(--indigo); background: var(--surface-solid);
  border: 1px solid var(--outline);
}
.attach-btn svg { width: 21px; height: 21px; }
.attach-btn:active { background: var(--surface-2); }

/* 送信前の添付プレビュー（×で個別に外せる） */
.attach-previews { display: flex; flex-wrap: wrap; gap: 8px; }
.attach-previews:not(:empty) { padding: 2px 2px 8px; }
.attach-chip { position: relative; }
.attach-chip img {
  width: 64px; height: 64px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--outline);
  display: block;
}
.attach-remove {
  position: absolute; top: -6px; right: -6px;
  display: grid; place-items: center;
  width: 20px; height: 20px; border-radius: 999px;
  background: var(--text); color: #fff;
  font-size: 12px; line-height: 1;
}
.composer textarea {
  resize: none;
  /* 画面の半分まで伸び、それ以上は固定して内部スクロールに切り替わる */
  min-height: 44px; max-height: 50dvh;
  line-height: 1.6;
  border-radius: 22px;
  padding: 10px 16px;
  /* スクロールバー非表示（スクロール自体は可能なまま） */
  scrollbar-width: none;
}
.composer textarea::-webkit-scrollbar { display: none; }
.send-btn {
  flex: none;
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 999px;
  background: var(--grad); color: #fff;
  box-shadow: var(--glow);
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}
.send-btn svg { width: 20px; height: 20px; }
.send-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.45; box-shadow: none; }

/* ---------------- 整理ボタン ---------------- */
.organize-btn {
  position: fixed; z-index: 46;
  top: max(12px, env(safe-area-inset-top)); right: 12px;
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 999px;
  background: var(--surface-solid); color: var(--indigo);
  box-shadow: var(--shadow-1);
  border: 1px solid var(--outline);
}
.organize-btn svg { width: 19px; height: 19px; }
.organize-btn:active { background: var(--surface-2); }
.organize-btn.running { color: var(--muted); pointer-events: none; }
.organize-btn.running svg { animation: spin 1.1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- タイムライン ---------------- */
.day-label {
  font-size: 0.78rem; font-weight: 700; color: var(--muted);
  letter-spacing: 0.06em;
  margin: 18px 4px 8px;
}
.memo-list { list-style: none; }
.memo { padding: 12px 14px 9px; margin-bottom: 10px; }
.memo-body {
  font-size: 0.82rem; line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
  /* 長いメモは2行で省略し、タップで全文と切り替える（app.js） */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.memo-body.expanded { display: block; -webkit-line-clamp: unset; }

/* 添付画像のサムネイル。タップで拡大表示（app.jsのライトボックス） */
.memo-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.memo-images img {
  width: 88px; height: 88px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--outline);
  cursor: zoom-in;
}
.memo-images img:only-child { width: 160px; height: 120px; }

/* 拡大表示（ライトボックス） */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(31, 35, 51, 0.86);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center;
  padding: 20px; cursor: zoom-out;
}
.lightbox.hidden { display: none; }
.lightbox img {
  max-width: 100%; max-height: calc(100dvh - 40px);
  border-radius: 14px;
}
.memo-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.memo-time { font-size: 0.72rem; color: var(--muted); margin-left: auto; }

.chip {
  font-family: var(--font-display);
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.03em;
  color: #fff; border-radius: 999px; padding: 3px 10px;
}

.x { color: var(--muted); padding: 4px 5px; border-radius: 999px; display: grid; place-items: center; }
.x svg { width: 13px; height: 13px; }
.x:active { background: var(--surface-2); color: var(--red); }

.empty-state {
  text-align: center; color: var(--muted);
  font-size: 0.88rem; line-height: 2;
  padding: 44px 12px;
}

/* ---------------- カテゴリグラデーション ---------------- */
/* 帯・チップに割り当てる8テーマ。db.GRADIENTSと1対1で対応する。 */
.grad-green  { background: linear-gradient(135deg, #059669, #84cc16); }
.grad-orange { background: linear-gradient(135deg, #f59e0b, #f97316); }
.grad-blue   { background: linear-gradient(135deg, #38bdf8, #4f8df7); }
.grad-violet { background: linear-gradient(135deg, #8b5cf6, #c084fc); }
.grad-rose   { background: linear-gradient(135deg, #fb7185, #f472b6); }
.grad-cyan   { background: linear-gradient(135deg, #22d3ee, #14b8a6); }
.grad-amber  { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.grad-slate  { background: linear-gradient(135deg, #64748b, #475569); }

.grad-text-green  { background: linear-gradient(135deg, #059669, #84cc16); }
.grad-text-orange { background: linear-gradient(135deg, #f59e0b, #f97316); }
.grad-text-blue   { background: linear-gradient(135deg, #38bdf8, #4f8df7); }
.grad-text-violet { background: linear-gradient(135deg, #8b5cf6, #c084fc); }
.grad-text-rose   { background: linear-gradient(135deg, #fb7185, #f472b6); }
.grad-text-cyan   { background: linear-gradient(135deg, #22d3ee, #14b8a6); }
.grad-text-amber  { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.grad-text-slate  { background: linear-gradient(135deg, #64748b, #475569); }
[class*="grad-text-"] {
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* ---------------- ノートブック（帯） ---------------- */
.pagehead { margin: 6px 2px 16px; }
.backlink {
  display: inline-flex; align-items: center; gap: 2px;
  font-size: 0.78rem; font-weight: 500; color: var(--muted);
  text-decoration: none; margin-bottom: 6px;
}
.backlink svg { width: 15px; height: 15px; }

.shelf { display: flex; flex-direction: column; gap: 12px; }
.band {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border-radius: var(--radius);
  padding: 18px 18px;
  color: #fff; text-decoration: none;
  box-shadow: var(--shadow-2);
  transition: transform 0.15s;
}
.band:active { transform: scale(0.98); }
.band-main { min-width: 0; }
.band-name {
  display: block;
  font-family: var(--font-display);
  font-size: 1.08rem; font-weight: 700;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.10);
}
.band-topic {
  display: block;
  font-size: 0.75rem; opacity: 0.92; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.band-count {
  flex: none;
  font-family: var(--font-display);
  font-size: 0.82rem; font-weight: 700;
  background: rgba(255, 255, 255, 0.24);
  border-radius: 999px; padding: 4px 12px;
}

/* ---------------- ノート詳細（タイトル一覧 + 開閉） ---------------- */
.note-list { display: flex; flex-direction: column; gap: 8px; }
.note { padding: 0; margin-bottom: 0; overflow: hidden; }
.note-title { margin: 0; font-size: 1rem; }
/* タイトル行そのものが開閉ボタン。カード幅いっぱいを押せる領域にする。
   理由: 一覧では「開く」が主操作であり、狙って小さな矢印を押させる必要がないため。 */
.note-toggle {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 14px 16px;
  text-align: left;
}
.note-title-text {
  flex: 1; min-width: 0;
  font-family: var(--font-display); font-weight: 500; line-height: 1.5;
}
.note-img-count {
  flex: none;
  font-size: 0.66rem; font-weight: 700; color: var(--muted);
  background: var(--surface-2); border-radius: 999px; padding: 3px 9px;
}
.note-chevron {
  flex: none; width: 18px; height: 18px; color: var(--muted);
  transition: transform 0.2s;
}
.note.open .note-chevron { transform: rotate(180deg); }
.note-detail { padding: 0 16px 12px; }
.note-body { font-size: 0.9rem; line-height: 1.8; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }
.note-meta { font-size: 0.7rem; color: var(--muted); margin-top: 10px; }

/* ノートの画像。メモのサムネイルと同じ見た目 + 末尾に挿入タイル */
.note-images { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.note-images img {
  width: 88px; height: 88px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--outline);
  cursor: zoom-in;
}
.note-img-add {
  display: grid; place-items: center;
  width: 88px; height: 88px;
  border: 1.5px dashed var(--outline-strong);
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
}
.note-img-add svg { width: 22px; height: 22px; }
.note-img-add:active { background: var(--surface-2); }
.note-img-add .ico-busy { display: none; }
.note-img-add.busy { pointer-events: none; }
.note-img-add.busy .ico-add { display: none; }
.note-img-add.busy .ico-busy { display: block; animation: spin 1.1s linear infinite; }

/* ライトボックス内の削除ボタン（ノート詳細のみ） */
.lightbox-inner {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  max-width: 100%;
}
.lightbox-inner img { max-height: calc(100dvh - 130px); }
.lightbox-delete {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px; padding: 9px 22px;
  font-size: 0.82rem; font-weight: 500;
}
.lightbox-delete:active { background: var(--red); border-color: var(--red); }

/* ---------------- ノートブックへの質問 ---------------- */
.ask { padding: 13px 13px 12px; }
.ask-row { display: flex; align-items: center; gap: 8px; }
.ask-row input {
  flex: 1; min-width: 0;
  background: var(--surface-2);
  border-radius: 999px; padding: 11px 16px;
  font-size: 0.88rem;
}
.ask-btn {
  flex: none; display: grid; place-items: center;
  width: 42px; height: 42px; border-radius: 999px;
  background: var(--grad); color: #fff;
  box-shadow: var(--glow);
  transition: transform 0.15s, opacity 0.2s, box-shadow 0.2s;
}
.ask-btn svg { width: 20px; height: 20px; }
.ask-btn:active { transform: scale(0.92); }
.ask-btn:disabled { opacity: 0.45; box-shadow: none; }
.ask-status {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px; padding: 0 4px;
  font-size: 0.8rem; color: var(--muted);
}
.ask-status.hidden { display: none; }
.ask-spinner { width: 16px; height: 16px; animation: spin 1.1s linear infinite; }
.ask-answer {
  margin-top: 12px; padding: 12px 14px;
  background: var(--grad-soft);
  border-radius: 14px;
  font-size: 0.85rem; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word;
}
.ask-answer.hidden { display: none; }

/* ---------------- ログイン ---------------- */
.login-wrap { max-width: 320px; margin: 16dvh auto 0; text-align: center; }
.login-kicker {
  font-family: var(--font-display);
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.18em;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.login-logo {
  font-size: 2.3rem; font-weight: 700; margin: 4px 0 6px;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.login-sub { font-size: 0.82rem; color: var(--muted); margin-bottom: 26px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.error { color: var(--red); font-size: 0.82rem; margin-bottom: 12px; }
button.primary {
  background: var(--grad); color: #fff;
  font-family: var(--font-display); font-weight: 700;
  border-radius: 999px; padding: 13px;
  box-shadow: var(--glow);
}
button.primary:active { transform: scale(0.98); }

.logout-row { text-align: center; margin-top: 30px; }
.logout-btn { font-size: 0.78rem; color: var(--muted); padding: 8px 16px; }
.logout-btn:active { color: var(--red); }

/* ---------------- タブバー ---------------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around;
  max-width: 560px; margin: 0 auto;
  height: calc(68px + env(safe-area-inset-bottom));
  padding: 7px 10px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  text-decoration: none; color: var(--muted);
}
.tab-pill {
  display: grid; place-items: center;
  width: 56px; height: 30px; border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}
.tab-pill svg { width: 21px; height: 21px; }
.tab-label { font-size: 0.66rem; font-weight: 500; }
.tabbar a.active { color: var(--blue); }
.tabbar a.active .tab-pill { background: var(--grad-soft); }

/* 送信方法のヒント。PCでのみ表示する（スマホは送信ボタンで完結するため） */
.composer-hint { display: none; }

/* ================================================================
   PC版レイアウト（900px以上）
   スマホ版のDOMをそのまま使い、CSSだけで役割を組み替える。
   理由: 幅1400pxの画面に560px幅のまま表示すると両脇が空いて
   「スマホの拡大版」に見え、1画面あたりの情報量も少ないため。
   マークアップを二重に持たないので、以後の修正も1箇所で済む。
   ================================================================ */
@media (min-width: 900px) {
  :root {
    /* 左サイドナビの幅。ラベル「ノートブック」が折り返さない最小幅から決めた。 */
    --rail: 248px;
  }

  body { padding-bottom: 40px; }
  body.app { padding-left: var(--rail); }
  /* 入力画面だけ下部コンポーザー分の余白を足す。理由: 他画面で同じ余白を
     取ると、ページ末尾に何もない空白が残るため。 */
  body.view-home { padding-bottom: 132px; }

  /* ---- 下タブバー → 左サイドナビ ---- */
  .tabbar {
    top: 0; bottom: 0; right: auto; left: 0;
    width: var(--rail); height: 100dvh;
    max-width: none; margin: 0;
    flex-direction: column; justify-content: flex-start;
    gap: 4px;
    /* 上端はブランドロゴ（position:fixed）のぶんを空ける */
    padding: 84px 14px 20px;
    background: rgba(255, 255, 255, 0.62);
    border-right: 1px solid var(--outline);
  }
  .tabbar a {
    flex: none;
    flex-direction: row; justify-content: flex-start; align-items: center;
    gap: 12px;
    padding: 11px 12px; border-radius: 14px;
    transition: background 0.18s, color 0.18s;
  }
  .tabbar a.active { background: var(--grad-soft); }
  .tabbar a.active .tab-pill { background: none; }
  .tab-pill { width: 26px; height: 26px; }
  .tab-pill svg { width: 22px; height: 22px; }
  .tab-label { font-size: 0.92rem; font-weight: 500; }

  /* ブランドロゴをサイドナビの頭に固定する。理由: DOM上は本文の先頭にあるが、
     PCではナビの見出しとして置くほうが視線の起点が1つにまとまるため。 */
  .brand {
    position: fixed; top: 0; left: 0; z-index: 41;
    width: var(--rail); height: 84px;
    justify-content: flex-start; gap: 10px;
    margin: 0; padding: 0 26px;
  }
  .brand-icon { width: 30px; height: 30px; border-radius: 9px; }
  .brand-name { font-size: 1.2rem; }

  /* ---- 本文の幅 ---- */
  .container { max-width: 1160px; padding: 34px 40px 40px; }
  /* ノート詳細だけ幅を絞る。理由: 長文は1行が長すぎると視線が戻れず読み落とすため。 */
  body.view-note .container { max-width: 900px; }
  body.auth .container { max-width: 480px; }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.15rem; }
  .pagehead { margin: 4px 2px 22px; }

  /* ---- 整理ボタン: アイコンのみ → ラベル付きピル ---- */
  /* 右端は本文カラムの右辺に合わせる（画面が広いほど中央寄りに来る）。
     理由: 画面右端に固定すると本文から遠く離れ、無関係な浮遊物に見えるため。 */
  .organize-btn {
    top: 30px;
    right: max(40px, calc((100vw - var(--rail)) / 2 - 540px));
    display: inline-flex; align-items: center; gap: 8px;
    width: auto; height: 40px; padding: 0 18px 0 15px;
    border-radius: 999px;
    font-family: var(--font-display); font-size: 0.85rem; font-weight: 500;
    transition: background 0.18s, box-shadow 0.2s;
  }
  .organize-btn::after { content: "AI整理"; }
  .organize-btn.running::after { content: "整理中…"; }

  /* ---- 入力（コンポーザー）は本文カラム幅に合わせて下部に残す ---- */
  /* 理由: 「思いついたら即放り込む」動線はPCでも下部固定が最短で、
     チャット型の操作感（送信後に末尾へ追記）も維持できるため。 */
  .composer {
    left: var(--rail); right: 0; bottom: 0;
    max-width: none; margin: 0;
    padding: 12px 40px 14px;
    background: rgba(255, 255, 255, 0.9);
  }
  .composer-row, .attach-previews, .composer-hint { max-width: 1080px; margin: 0 auto; }
  .composer textarea { font-size: 0.95rem; padding: 11px 18px; }
  .composer-hint {
    display: block;
    margin-top: 6px; padding-left: 56px;
    font-size: 0.7rem; color: var(--muted);
  }

  /* ---- タイムライン: 1列 → 複数列 ---- */
  /* 1枚が2〜4行の短いカードなので、横に並べたほうが一度に見渡せる。 */
  .day-label { font-size: 0.86rem; margin: 26px 2px 12px; }
  .memo-list {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
    align-items: start;
  }
  .memo { padding: 14px 16px 10px; margin-bottom: 0; }
  .memo-body { font-size: 0.9rem; -webkit-line-clamp: 4; cursor: pointer; }
  .memo-time { font-size: 0.74rem; }

  /* 削除ボタンはカードにポインタを載せたときだけ出す。
     理由: 常時表示だと一覧の情報密度が上がった分だけ×印が目障りになるため。
     キーボード操作時はfocus-visibleで必ず現れる。 */
  .memo .x { opacity: 0; transition: opacity 0.15s; }
  .memo:hover .x, .memo .x:focus-visible { opacity: 1; }

  /* ---- ノートブックの帯 ---- */
  .shelf {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  }
  .band { padding: 22px 22px; min-height: 106px; }
  .band-name { font-size: 1.14rem; }

  /* ---- ノート詳細 ---- */
  .note-list { gap: 10px; }
  .note-toggle { padding: 16px 20px; }
  .note-title { font-size: 1.05rem; }
  .note-detail { padding: 0 20px 14px; }
  .note-body { font-size: 0.95rem; }
  .ask { padding: 15px 16px 14px; }
  .ask-row input { font-size: 0.92rem; padding: 12px 18px; }
  .ask-answer { font-size: 0.9rem; padding: 14px 16px; }
  .note-images img, .note-img-add { width: 104px; height: 104px; }
  .memo-images img { width: 96px; height: 96px; }

  /* ---- ログイン ---- */
  .login-wrap { max-width: 380px; margin: 17dvh auto 0; }
  .login-logo { font-size: 2.7rem; }
}

/* 3列で1枚が広くなりすぎないよう、超ワイド画面では列を増やす */
@media (min-width: 1700px) {
  .memo-list, .shelf { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .container { max-width: 1400px; }
  .composer-row, .attach-previews, .composer-hint { max-width: 1320px; }
  .organize-btn { right: max(40px, calc((100vw - var(--rail)) / 2 - 660px)); }
}

/* ================================================================
   ポインタ操作（マウス）向けのホバー
   理由: スマホには:activeしか無く、PCでは「押せる場所」が
   触るまで分からないと操作の手掛かりが足りないため。
   ================================================================ */
@media (hover: hover) {
  .memo, .card { transition: box-shadow 0.2s, transform 0.2s; }
  .memo:hover { box-shadow: var(--shadow-2); }
  .band:hover { transform: translateY(-2px); box-shadow: 0 18px 44px -10px rgba(85, 95, 175, 0.42); }
  .tabbar a:hover { color: var(--text-2); }
  .tabbar a.active:hover { color: var(--blue); }
  .x:hover { background: var(--surface-2); color: var(--red); }
  .attach-btn:hover, .organize-btn:hover, .note-img-add:hover { background: var(--surface-2); }
  .note-toggle:hover .note-title-text { color: var(--blue); }
  .note-toggle:hover .note-chevron { color: var(--blue); }
  .send-btn:not(:disabled):hover, .ask-btn:not(:disabled):hover,
  button.primary:hover { filter: brightness(1.06); box-shadow: 0 10px 28px -8px rgba(79, 70, 229, 0.7); }
  .backlink:hover { color: var(--blue); }
  .logout-btn:hover { color: var(--red); }
  .lightbox-delete:hover { background: var(--red); border-color: var(--red); }
}
