:root {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #ffffff;
  --surface-2: #f0f0f0;
  --line: rgba(0, 0, 0, 0.14);
  --text: #000000;
  --muted: #737373;
  --rust: #b3402b;
  --serif: 'Fraunces', serif;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'Zen Kaku Gothic New', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* スマホでキャンバス端までパン/スワイプした際に、ブラウザ標準のpull-to-refresh
     (下端バウンスでのページリロード)が誤発火するのを防ぐ */
  overscroll-behavior: none;
}

.toolbar {
  position: relative;
  flex: none;
  z-index: 10;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(255, 255, 255, 0.85));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}

.toolbar h1 {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
  margin: 0;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- インフォメーションカードのヘッダーティッカー(鑑賞可能な展覧会をローテーション表示) ---------- */

.info-ticker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 420px;
  margin-left: 6px;
  padding: 5px 12px;
  background: var(--surface-2);
  border-radius: 999px;
  cursor: pointer;
}

.info-ticker:hover { background: #e6e6e6; }

.info-ticker-dot {
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2e7d32;
}

.info-ticker-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}

.info-ticker-progress {
  flex: none;
  display: flex;
  gap: 3px;
}

.info-ticker-progress span {
  width: 9px;
  height: 2px;
  border-radius: 1px;
  background: var(--line);
}

.info-ticker-progress span.active { background: #2e7d32; }

.toolbar button {
  font-family: var(--mono);
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 7px 12px;
  font-size: 11px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  flex: none;
  cursor: pointer;
}

.toolbar button:disabled { opacity: 0.35; cursor: not-allowed; }

/* グループビューイングモード切り替えボタン(js/app.jsのtoggleGroupViewing()、2026年9月追加)。
   ON中はCrewsの水色(cyan)に切り替えて、動いていることが一目で分かるようにする。 */
#group-viewing-btn.group-viewing-btn--active {
  background: rgba(85, 230, 247, 0.9);
  color: #06282c;
}

/* コメント履歴モーダル(js/app.jsのopenCommentHistory()、2026年9月追加)。既存の.modal-overlay/
   .modalを流用しつつ、リスト部分だけ専用のスタイルを足す。 */
.comment-history-modal { max-width: 460px; }
.comment-history-list { max-height: 50vh; overflow-y: auto; margin: 4px 0 16px; display: flex; flex-direction: column; gap: 8px; }
.comment-history-empty { font-size: 12px; color: var(--muted); margin: 0; }
.comment-history-row { display: flex; gap: 9px; align-items: flex-start; }
.comment-history-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  background: rgba(85, 230, 247, 0.25); border: 1px solid rgba(85, 230, 247, 0.6);
}
.comment-history-body { flex: 1; min-width: 0; }
.comment-history-meta {
  display: flex; align-items: center; gap: 6px; font-size: 11px; margin-bottom: 2px;
}
.comment-history-meta span {
  font-family: var(--mono); font-size: 8.5px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.04em;
}
.comment-history-text { font-size: 12px; line-height: 1.55; }

/* アップロード状況一覧モーダル(js/app.jsのopenUploadStatusList()、2026年9月追加)。
   端末⇔このブラウザの待機列(IndexedDB)⇔Driveの3者のうち、カードごとに実際に何が
   どこにあるか一目で分かるようにする診断用リスト。既存の.modal-overlay/.modalを流用しつつ、
   コメント履歴モーダルと同じ構造(行のリスト+行ごとの操作ボタン)を踏襲している。 */
.upload-status-modal { max-width: 480px; }
.upload-status-list { max-height: 56vh; overflow-y: auto; margin: 4px 0 16px; display: flex; flex-direction: column; gap: 10px; }
.upload-status-empty { font-size: 12px; color: var(--muted); margin: 0; }
.upload-status-row {
  display: flex; gap: 9px; align-items: flex-start; padding: 8px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.upload-status-thumb {
  width: 40px; height: 40px; border-radius: 3px; flex: none; overflow: hidden;
  background: var(--panel); display: flex; align-items: center; justify-content: center; font-size: 18px;
}
.upload-status-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.upload-status-body { flex: 1; min-width: 0; }
.upload-status-title {
  font-size: 12px; font-weight: 600; margin-bottom: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.upload-status-line { font-family: var(--mono); font-size: 10.5px; color: var(--text); line-height: 1.6; }
.upload-status-action { flex: none; display: flex; align-items: center; }
.upload-status-action button { font-size: 10.5px; padding: 5px 8px; }

.status {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* 時間のかかる処理(Drive同期・Gemini呼び出し・Overpass取得など)の進行を、ヘッダー下端の
   細い線で視覚化する。setStatus()の busy/progress オプションから共通で制御される
   (2026年9月、Mapping Storysの屋外取得が「押しても反応が無いように見える」不具合の対応として、
   1箇所だけでなくアプリ全体の重い処理に広げた)。所要時間が読めない処理は不定(indeterminate)の
   スライドアニメーション、件数が分かる処理(移行処理など)は実際の割合で幅を決める。 */
.status-progress {
  position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; overflow: hidden;
  background: rgba(0, 0, 0, 0.06);
}
.status-progress-bar {
  position: absolute; top: 0; left: 0; width: 0%; height: 100%;
  background: var(--text);
  transition: width 0.25s ease-out;
}
.status-progress.indeterminate .status-progress-bar {
  width: 30%;
  animation: status-progress-slide 1.1s ease-in-out infinite;
}
@keyframes status-progress-slide {
  0% { left: -30%; }
  100% { left: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .status-progress.indeterminate .status-progress-bar { animation: none; left: 0; width: 100%; opacity: 0.5; }
}

/* ---------- 年タブ・パンくず(セッションの入れ子ナビゲーション) ---------- */

.year-tabs {
  flex: none;
  min-width: 0;
  z-index: 9;
  display: flex;
  gap: 4px;
  padding: 0 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.year-tabs:empty { display: none; }

.year-tab {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 6px;
  cursor: pointer;
}

.year-tab:hover { color: var(--text); }
.year-tab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }

.breadcrumb {
  flex: none;
  min-width: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  min-height: 0;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}

.breadcrumb:empty { display: none; }

.breadcrumb .crumb {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 6px 0;
  cursor: pointer;
}

.breadcrumb .crumb:hover:not(:disabled) { color: var(--text); }
.breadcrumb .crumb.current { color: var(--text); font-weight: 600; cursor: default; }
.breadcrumb .crumb-sep { color: var(--muted); font-size: 10px; }

.canvas-viewport {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  cursor: grab;
  background-color: var(--bg);
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.12) 1px, transparent 1px);
  background-size: 26px 26px;
  /* 長押し(パイメニューのトリガー)でブラウザ標準のテキスト選択/コピーメニューが出るのを防ぐ */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* メモ欄だけは編集のため選択を許可する(親の user-select: none を打ち消す) */
.star-card-memo {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* 座談会の発言・質問はコピペしたいという要望(2026年9月)を受け、メモ欄と全く同じ仕組みに
   した: 既定はpointer-events:noneのまま(=キャンバスのパン/カードの移動を優先)、編集ガイドの
   Editボタン(またはEキー)を押すと.star-card-chat-editingが付いてauto化し、ドラッグで
   文字を選択できるようになる。テキスト自体は読み取り専用なので実際に書き換えることはできない
   (トグルなので、もう一度Editを押すか他のカード/キャンバスを操作すると編集ガイドごと解除される)。 */
.star-card-chat-text,
.star-card-chat-question {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  pointer-events: none;
}
.star-card-chat-editing .star-card-chat-text,
.star-card-chat-editing .star-card-chat-question {
  pointer-events: auto;
}

/* コメントカードの本文も同じ理由・同じ仕組みでコピペ可能にした(2026年9月追加) */
.star-card-comment-text {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
  pointer-events: none;
}
.star-card-comment-editing .star-card-comment-text {
  pointer-events: auto;
}

@media (max-width: 480px) {
  .toolbar h1 { font-size: 14px; }
  .toolbar button { padding: 6px 8px; font-size: 10px; }
}

.canvas-content {
  position: absolute;
  top: 0; left: 0;
  width: 0; height: 0;
  transform-origin: 0 0;
}

/* ダブルタップでの「全体を俯瞰」ズーム中だけtransformをアニメーションさせる
   (通常のドラッグ/ピンチ操作では毎フレーム書き換わるためtransitionを掛けない) */
.canvas-content--animated {
  transition: transform 0.35s ease-out;
}

/* ---------- Asterism(見た順の自動線 + ASTRガイドでの手動接続) ----------
 * .canvas-content の子として置き、カードと同じ生px座標系で線を引く(js/app.js参照)。
 * カードより前にDOMへ挿入しているので、z-indexなしで自然に線がカードの下に潜る。 */
.asterism-layer {
  position: absolute;
  top: 0; left: 0;
  /* 0x0 + overflow:visible でも仕様上は描けるはずだが、環境差の影響を受けにくいよう
     現実的なキャンバス範囲を覆う大きさを明示しておく(overflowはさらに保険として残す) */
  width: 20000px;
  height: 20000px;
  overflow: visible;
  pointer-events: none;
}

/* 自動線・手動線は見た目上区別しない(同じスタイル) */
.asterism-line {
  stroke: var(--muted);
  stroke-width: 2;
  opacity: 0.75;
}

/* ASTRドラッグ中の仮の線(接続先が決まるまでの追従表示) */
.asterism-line--drag {
  stroke: #2e7d32;
  stroke-width: 2;
  stroke-dasharray: 5 4;
  opacity: 0.9;
}

/* 見えている細い線(自動/手動どちらも)より広い透明な線を重ねてタップしやすくする(削除用) */
.asterism-line-hit {
  stroke: transparent;
  stroke-width: 16;
  pointer-events: auto;
  cursor: pointer;
}

/* ASTRで接続が成立した瞬間、「ピーン」の発音に合わせてその線を一瞬明るく光らせてから、
   通常の線の見た目へなめらかに戻す(js/app.jsのflashConnectedLine()が付け外しする)。 */
@keyframes asterism-connect-flash {
  0% {
    stroke: #2e7d32;
    stroke-width: 3.5;
    opacity: 1;
    filter: drop-shadow(0 0 7px rgba(46, 125, 50, 0.85));
  }
  100% {
    stroke: var(--muted);
    stroke-width: 2;
    opacity: 0.75;
    filter: drop-shadow(0 0 0 rgba(46, 125, 50, 0));
  }
}
.asterism-line--connect-flash {
  animation: asterism-connect-flash 0.8s ease-out forwards;
}

.tool-btn.active {
  background: var(--text);
  color: #fff;
}

/* ---------- ボトムツールバー(制作ツール: アップロード・カメラ・OCR・動画・音声) ---------- */

#bottombar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(0deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.85));
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- OCRのピクチャ・イン・ピクチャ表示(js/camera.jsのrunOcrInBackground()、2026年9月追加) ----------
   「読み取る」を押した瞬間にカメラは閉じ、OCR自体はここで進捗だけを示す。タップ等の操作は
   要求しない(pointer-events: none、下のキャンバス操作を一切妨げない)控えめな表示。 */
#ocr-pip {
  position: fixed;
  right: 12px;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  z-index: 55;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 20, 24, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-family: var(--sans);
  font-size: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}
#ocr-pip[hidden] { display: none; }

.ocr-pip-spinner {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  animation: ocr-pip-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes ocr-pip-spin { to { transform: rotate(360deg); } }

/* 読み取りが電波不良等でいつまでも終わらない場合の中止手段(2026年9月追加)。
   親の#ocr-pipはpointer-events:noneだが、このボタンだけ個別に有効化する。 */
#ocr-pip-cancel {
  pointer-events: auto;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
}
#ocr-pip-cancel:active { background: rgba(255, 255, 255, 0.32); }

/* ---------- テキスト選択時の「Googleで検索」ポップアップ(js/app.jsのinitTextSearchPopup()、
   2026年9月追加) ----------
   キャンバス全体でcontextmenuをpreventDefault()しているため(js/canvas.js)、カード内の
   テキスト(テクスト/コメント/座談会・メモ欄)をドラッグ選択してもOS標準の「Web検索」メニューが
   出せない。選択が確定した位置(pointerup座標)の近くにこの小さいポップアップを出し、押すと
   選択文字列でGoogle検索を新規タブで開く。 */
.text-search-popup {
  position: fixed;
  z-index: 210;
  transform: translate(-50%, -100%);
  pointer-events: none; /* ボタン自体には別途autoを付ける、外枠は当たり判定を持たない */
}
.text-search-popup[hidden] { display: none; }
.text-search-popup button {
  pointer-events: auto;
  display: block;
  background: rgba(20, 20, 24, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 8px 14px;
  margin-bottom: 8px;
  font-family: var(--sans);
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ---------- デイリーコメントのトースト(js/app.jsのmaybeShowDailyComment()、2026年9月追加) ----------
   ヘッダーの鑑賞可能日ティッカー(#infoTicker)と同じ「控えめなトースト表示」の作法を踏襲し、
   画面右上に浮かべる。既定で画面外(上)に隠れた状態から、showクラスでスライドイン/フェードする。 */
#daily-comment-toast {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 12px;
  z-index: 60;
  width: 240px;
  display: flex;
  gap: 9px;
  background: var(--panel, #fff);
  border: 1.5px solid rgba(85, 230, 247, 0.8);
  border-radius: 10px;
  box-shadow: 0 14px 30px rgba(6, 40, 44, 0.2);
  padding: 11px 12px;
  opacity: 0;
  transform: translateY(-10px) scale(0.96);
  transition: opacity 0.32s ease-out, transform 0.32s ease-out;
  pointer-events: none;
}
#daily-comment-toast.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.daily-comment-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
  background: rgba(85, 230, 247, 0.25); border: 1px solid rgba(85, 230, 247, 0.6);
}
.daily-comment-body { flex: 1; min-width: 0; }
.daily-comment-label {
  font-family: var(--mono); font-size: 8px; letter-spacing: 0.08em; color: var(--muted);
  text-transform: uppercase; margin-bottom: 2px;
}
.daily-comment-name { font-family: var(--mono); font-size: 10px; font-weight: 700; color: #06282c; margin-bottom: 3px; }
.daily-comment-text { font-size: 11px; line-height: 1.55; color: var(--text); }
.daily-comment-close {
  align-self: flex-start; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line);
  background: none; color: var(--muted); font-size: 8px; cursor: pointer; flex: none; line-height: 1;
}

.tool-btn {
  flex: 0 0 auto;
  min-width: 56px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.01em;
  color: var(--muted);
  background: none;
  border: none;
  border-radius: 8px;
  padding: 7px 11px 5px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.tool-btn:hover { background: var(--surface-2); color: var(--text); }
.tool-btn:disabled { opacity: 0.35; cursor: not-allowed; background: none; }
.tool-btn svg { width: 19px; height: 19px; flex-shrink: 0; }

.star-card {
  position: absolute;
  top: 0; left: 0;
  min-width: 140px;
  min-height: 100px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  touch-action: none;
  transition: box-shadow 0.15s ease-out;
}

/*
 * 俯瞰でカードが多いセッションを開くとモバイル端末でカクつく、という実機報告(2026年9月)
 * への対応として、一時期 .star-card へ content-visibility:auto を付けていたが撤回した。
 * 理由: content-visibility:auto は「画面外と判断された時だけ」ではなく常に
 * contain:layout style paint 相当を伴う(spec上、画面内表示に戻っても paint containment 自体は
 * 外れない)。このアプリの編集ガイドのヘックスバッジ(.star-card-hex、カード枠から意図的に
 * はみ出す配置)やサマリーカードのヘックスタブ(.star-card-summary-head、カード上辺をまたぐ
 * 配置)は、まさにこの paint containment で常時クリップされてしまい、「サマリーの人物アイコンが
 * 上端で見切れる」「編集ガイドのヘックスが表示されない」という実機報告(2026年9月)につながった。
 * ヘックスのはみ出しはCONSTELLATION全体の統一UI言語のため、カード種別ごとの除外では対処
 * しきれず、content-visibility:auto自体を撤回した。俯瞰時のカクつき対策は、代わりに
 * js/app.js の本画像フェッチの同時実行数制限(MEDIA_FETCH_CONCURRENCY)で対応している。
 */

/* 長押し開始直後(編集ガイドが出る前)の予兆: 影を徐々に濃くする */
.star-card--pressing {
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.22);
  transition: box-shadow 0.28s ease-out;
}

/*
 * 長押しが確定し「編集ガイド」が表示された状態のカード: 緑のリングと四隅・四辺の
 * ハンドル(トンボ)が現れ、ボディをドラッグすれば移動、ハンドルをドラッグすれば
 * 縦横別に自由変形できる。他のカード/キャンバスを操作すると解除される。
 * スマホ・PCで見た目/操作を統一しており、今後この編集ガイドに機能を追加していく想定。
 * transform はドラッグ中に毎フレーム書き換えられるため、ここに transition を掛けると
 * 追従がもたついて見える。box-shadow だけをなめらかに変化させる。
 */
.star-card--edit-guide {
  box-shadow: 0 0 0 2px #2e7d32, 0 20px 44px rgba(0, 0, 0, 0.3);
  transition: box-shadow 0.12s ease-out;
  z-index: 5;
}

/*
 * ASTRを長押しして線を引いている間、つながろうとしている2枚(押し込んだ元のカードと、
 * 今指/カーソルが乗っている先のカード)を同じ緑の発光で示す。押し込んだ元のカードは
 * 常に .star-card--edit-guide も同時に持っているため、box-shadowの同点カスケードで
 * 上のルールに負けないよう、ここでは !important で確実に上書きする。
 */
.star-card--astr-glow {
  box-shadow: 0 0 0 3px #2e7d32, 0 0 26px 8px rgba(46, 125, 50, 0.65) !important;
  z-index: 6;
}

/*
 * 編集ガイドのリサイズハンドル(緑のトンボ)。見た目は小さい正方形だが、指でも
 * 狙いやすいよう実際のヒット領域(24x24)は見た目より広く取ってある。
 */
.star-card-handle {
  position: absolute;
  width: 24px;
  height: 24px;
  transform: translate(-50%, -50%);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 6;
  touch-action: none;
}

.star-card--edit-guide .star-card-handle {
  display: flex;
}

.star-card-handle::after {
  content: '';
  width: 10px;
  height: 10px;
  background: #2e7d32;
  border: 2px solid #fff;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.star-card-handle[data-edge="nw"] { top: 0; left: 0; cursor: nwse-resize; }
.star-card-handle[data-edge="ne"] { top: 0; left: 100%; cursor: nesw-resize; }
.star-card-handle[data-edge="se"] { top: 100%; left: 100%; cursor: nwse-resize; }
.star-card-handle[data-edge="sw"] { top: 100%; left: 0; cursor: nesw-resize; }
.star-card-handle[data-edge="n"] { top: 0; left: 50%; cursor: ns-resize; }
.star-card-handle[data-edge="s"] { top: 100%; left: 50%; cursor: ns-resize; }
.star-card-handle[data-edge="e"] { top: 50%; left: 100%; cursor: ew-resize; }
.star-card-handle[data-edge="w"] { top: 50%; left: 0; cursor: ew-resize; }

/*
 * 編集ガイドのSci-Fiパネル(緑のヘックスバッジ)。Direction C案の実装版。
 * Caption/Edit=キャプション取得・編集、ASTR=カード同士を線で繋ぐ機能(見た目のみ、実装は未定)、
 * Depth=カードを意図的にぼかす、Delete=削除。
 */
.star-card-hex {
  position: absolute;
  width: 64px;
  height: 40px;
  clip-path: polygon(20% 0%, 80% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%);
  background: #2e7d32;
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 11px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  z-index: 7;
  cursor: pointer;
}

.star-card--edit-guide .star-card-hex {
  display: flex;
}

.star-card-hex--caption { left: 0; top: 22%; transform: translate(-115%, -50%); }
.star-card-hex--reply   { left: 0; top: 22%; transform: translate(-115%, -50%); }
.star-card-hex--edit    { left: 0; top: 78%; transform: translate(-115%, -50%); }
.star-card-hex--title   { left: 0; top: 22%; transform: translate(-115%, -50%); }
.star-card-hex--toggle  { left: 0; top: 22%; transform: translate(-115%, -50%); }
.star-card-hex--depth   { left: 100%; top: 22%; transform: translate(15%, -50%); }
.star-card-hex--delete  { left: 100%; top: 78%; transform: translate(15%, -50%); }
.star-card-hex--astr {
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  letter-spacing: 0.04em;
}
.star-card-hex--extract { left: 50%; top: 100%; transform: translate(-50%, 25%); }
.star-card-hex--summon  { left: 50%; top: 0%; transform: translate(-50%, -25%); }

.star-card-hex-strut {
  position: absolute;
  height: 2px;
  width: 20px;
  background: #2e7d32;
  opacity: 0.7;
  z-index: 6;
}
.star-card-hex-strut--caption, .star-card-hex-strut--edit, .star-card-hex-strut--title, .star-card-hex-strut--toggle, .star-card-hex-strut--reply { right: -20px; top: 50%; transform: translateY(-50%); }
.star-card-hex-strut--depth, .star-card-hex-strut--delete { left: -20px; top: 50%; transform: translateY(-50%); }
.star-card-hex-strut--extract { width: 2px; height: 20px; left: 50%; bottom: 100%; transform: translateX(-50%); }
.star-card-hex-strut--summon { width: 2px; height: 20px; left: 50%; top: 100%; transform: translateX(-50%); }

/* Depth: カードを意図的にぼかして視覚的な優先度を下げる */
.star-card--depth-blurred {
  filter: blur(3px);
}

/* Driveへのアップロードがバックグラウンドで進行中(まだサムネイルだけ)であることを控えめに示す */
.star-card--upload-pending {
  opacity: 0.7;
}
.star-card--upload-pending .star-card-media {
  outline: 1px dashed var(--line);
  outline-offset: -1px;
}

/* Driveへ未送信のまま待機している状態(js/upload-queue.js、2026年9月にDriveアップロードを
   完全手動化した際に「Wi-Fi待ち」から意味を変更)。手動で「☁ Driveへ送信」を押すまでの
   通常の待機なので、rust(赤系)は使わず控えめな青系にする。 */
.star-card--upload-queued .star-card-media {
  outline: 1px dashed #3b6fa0;
  outline-offset: -1px;
}

/* Driveへのアップロードが失敗し、この端末を離れると写真の実体が失われる状態を分かるようにする */
.star-card--upload-failed .star-card-media {
  outline: 1px dashed var(--rust);
  outline-offset: -1px;
}

/* カード左上の状態バッジ2種(2026年9月追加): 「端末へ保存したか」「Driveへ送信したか」を
   互いに独立して示す。片方だけ済んでいる状態もあり得るため(例: 端末へは保存済みだが
   Driveへはまだ、など)、CSSのcontentによる単一の::afterではなく実要素として2つ重ねられる
   ようにした。テキスト・表示/非表示はjs/app.jsのupdateCardStatusBadges()がcard.imageFileId /
   card.uploadFailed / card.uploadPending / card.deviceSaved を見て都度更新する。 */
.star-card-status-badges {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  pointer-events: none;
}

.star-card-badge {
  font-family: var(--mono);
  font-size: 9px;
  color: #fff;
  background: #3b6fa0;
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

/* Drive送信が失敗した時の強調色(赤系)。単なる「まだ送っていない」待機とは区別する */
.star-card-badge--urgent {
  background: var(--rust);
}

/* 「端末未保存」バッジはDriveバッジと見分けやすいよう別の色にする(紫系) */
.star-card-badge--device {
  background: #6a4fa0;
}

.star-card-media {
  flex: 1;
  /* リサイズ中、メモ欄(固定pxで高さがロックされている)にスペースを取られてflex:1側が
     0に近い高さまで潰れ、写真が実質消えて見える不具合があった。最低限の高さを保証する。 */
  min-height: 40px;
  background-color: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}

/*
 * 以前は写真をこの要素自体のbackground-imageとして表示していたが、キャンバス全体を
 * transform: scale()でズームする構成上、background-imageはモバイルブラウザで祖先の
 * ズーム倍率まで描画解像度が追従しない(実機で「本画像に切り替わってもなお小さい文字が
 * ぼやける」という報告があった、2026年9月)。<img>要素(デコード済みの実ピクセルを持つ)に
 * 置き換え、cover だとリサイズのたびに写真の一部が意図せずクロップされてしまう
 * (作品写真やキャプション札の一部が見切れる)ため contain で全体を縮尺表示する。
 */
.star-card-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.star-card-media video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.star-card-media-audio {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.star-card-media-audio audio {
  width: 100%;
}

/*
 * 高さは js/app.js の syncCardHeight() が内容に合わせて都度セットする(スクロールさせず全文表示)。
 * pointer-events は既定で無効にし、カードのドラッグ移動を優先する。編集ガイドのEditアクション
 * を押した時だけ js/app.js 側で 'auto' に切り替えて編集を受け付ける。
 */
.star-card-memo {
  resize: none;
  overflow: hidden;
  pointer-events: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--text);
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.5;
  padding: 6px 7px;
}

/*
 * メモの読み取り専用表示(2026年9月、ハイパーリンク対応で追加)。既定はこちらが見えており、
 * textarea(平文しか描画できずURLをクリックさせられない)はEdit中だけ表示する。見た目は
 * .star-card-memoに合わせつつ、URL部分だけ<a>としてクリックできるようpointer-eventsを
 * 個別に有効化する(周囲の文字は既定通りpointer-events:noneのままカード移動を優先する)。
 */
.star-card-memo-view {
  overflow: hidden;
  pointer-events: none;
  white-space: pre-wrap;
  word-break: break-word;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--text);
  font-family: var(--serif);
  font-size: 13px;
  line-height: 1.5;
  padding: 6px 7px;
}
.star-card-memo-view a { pointer-events: auto; color: #2e7d32; text-decoration: underline; }
.star-card-memo-favicon { width: 14px; height: 14px; vertical-align: -2px; margin-right: 3px; border-radius: 2px; }

/* 写真・動画・音声カードのメモ欄(Edit中のtextarea)は、抽出テキストなどで長くなっても
   無制限には伸ばさない。flex:1の写真エリアはflex-basisが0%のため、メモが際限なく伸びると
   写真側の再計算の余地がなくなり、リサイズのたびに写真が潰れて戻らなくなる不具合があった
   ため上限+内部スクロールにした。テキストカード(.star-card--textの直下)には写真が無く
   競合しないので対象外。 */
.star-card-media ~ .star-card-memo {
  max-height: 220px;
  overflow-y: auto;
}

/* ---------- キャプションのぞき見プレビュー(2026年9月、案Bとして採用) ----------
   写真・動画・音声・ストリートビューの読み取り専用ビュー(.star-card-memo-view)は、以前は
   textareaと同じmax-height:220px+内部スクロールだったが、pointer-events:noneのため
   タップ/ホイールでの実際のスクロールを受け付けず、情報量の多いCaption(複数キャプションの
   まとめ貼り等)が実質見切れたままになる不具合があった。常に低い固定高さの「のぞき見」に
   割り切り(=写真のリサイズと完全に無関係)、あふれる分は⛶ボタンの全画面ポップアップ
   (js/app.jsのshowMemoOverlay())で読む設計にした。 */
.star-card-memo-shell { position: relative; }
.star-card-memo-view--peek {
  max-height: 71px; /* 3行分表示(2026年9月、2行分の62pxから拡大) */
  overflow: hidden;
  position: relative;
}
.star-card-memo-view--peek.star-card-memo-view--overflowing::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 20px;
  background: linear-gradient(rgba(255, 255, 255, 0), var(--panel));
  pointer-events: none;
}
.star-card-memo-expand-btn {
  position: absolute;
  right: 4px;
  bottom: 2px;
  pointer-events: auto;
  z-index: 2;
  font-size: 11px;
  line-height: 1;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}
.star-card-memo-expand-btn[hidden] { display: none; }

/* 「⛶ 全文を見る」ポップアップの中身。既存の.modal-overlay/.modal(settings-modal等と同じ
   不透明な意匠、グラスモーフィズムなし)をそのまま使い、この2つだけ追加する。 */
.star-card-memo-overlay-modal { max-width: 560px; }
.star-card-memo-overlay-body {
  max-height: 60vh;
  overflow-y: auto;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.85;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 16px;
}
.star-card-memo-overlay-body a { color: #2e7d32; text-decoration: underline; }

/* 写真・動画カードの場合、高画質の本体を左に並べて見られるようにする(2026年9月追加)。
   モーダル自体を横に広げ、左に画像/動画、右にテキストの2カラムにする。スマホ幅では
   横に並べる余地が無いため縦積みに切り替える。 */
.star-card-memo-overlay-modal--with-media {
  max-width: 920px;
  width: 95%;
  display: flex;
  gap: 18px;
  align-items: flex-start;
}
.star-card-memo-overlay-modal--with-media .star-card-memo-overlay-media {
  flex: 1 1 48%;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
  max-height: 80vh;
  aspect-ratio: 4 / 3;
}
.star-card-memo-overlay-media img,
.star-card-memo-overlay-media video {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  display: block;
}
.star-card-memo-overlay-media-loading {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.star-card-memo-overlay-modal--with-media .star-card-memo-overlay-text {
  flex: 1 1 52%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.star-card-memo-overlay-modal--with-media .star-card-memo-overlay-body {
  flex: 1;
}
@media (max-width: 700px) {
  .star-card-memo-overlay-modal--with-media {
    flex-direction: column;
  }
  .star-card-memo-overlay-modal--with-media .star-card-memo-overlay-media {
    max-height: 45vh;
    width: 100%;
  }
}

/* ---------- セッションカード(入れ子セッションへのポータル) ---------- */

.star-card--session {
  padding: 0;
}

/*
 * 写真の角を丸めるための overflow:hidden はカード本体(.star-card--session)ではなく
 * ここ(.star-card-session-body)に付ける。カード本体に付けてしまうと、カード外側に
 * はみ出す配置になっている編集ガイドのヘックスパネル(Title/Edit/Depth/Delete)や
 * リサイズハンドルまで一緒にクリップされ、中央のASTRしか見えなくなってしまう。
 */
.star-card-session-body {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  cursor: pointer;
  touch-action: none;
  overflow: hidden;
  border-radius: 2px;
}

.star-card-session-body:hover .star-card-session-text { background: #e4e4e4; }

/* 中身の写真をランダムに数枚、タイトルとは別の帯として上部に敷く(写真が無ければ帯自体を出さない) */
.star-card-session-thumbs {
  flex: 0 0 44%;
  min-height: 36px;
  display: flex;
  overflow: hidden;
}

.star-card-session-thumb {
  flex: 1;
  background-size: cover;
  background-position: center;
}

/* タイトル/件数は常に地の色の上に乗るので、写真の内容に関わらず読みやすい */
.star-card-session-text {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 4px;
  padding: 8px 12px;
  text-align: left;
}

/* タイトルと入室ボタンを横並びにする行(2026年9月追加)。星座ボディ全面のタップに
   任せきりだった入室手段が、OCRボタンの表示バグ(css/style.cssの
   .star-card-title-ocr-btn[hidden]のコメント参照)によって奪われた実機報告を受け、
   タイトル横に常設・独立の入室ボタンを追加した。 */
.star-card-session-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
}

.star-card-session-enter-btn {
  flex: none;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  color: var(--muted); /* 地味な色にする指定(2026年9月)。派手な絵文字ドアから線画フォルダアイコンへ変更済み */
  cursor: pointer;
  padding: 0;
}

.star-card-session-enter-btn:hover { background: #fff; border-color: var(--text); color: var(--text); }

.star-card-session-name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--text);
  line-height: 1.3;
}

.star-card-session-name-input {
  width: 100%;
  font-family: var(--serif);
  font-style: italic;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--text);
  border-radius: 3px;
  padding: 2px 5px;
}

.star-card-session-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
}

/* Titleガイドでの編集中だけ現れる、OCRでタイトルを読み取るボタン */
.star-card-title-ocr-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  cursor: pointer;
  padding: 0;
}

.star-card-title-ocr-btn:hover { background: #fff; border-color: var(--text); }
/* **2026年9月修正**: 上の`display: flex`はクラスセレクタ(著者スタイル)のため、通常の
   カスケード規則上、常にUA既定の`[hidden]{display:none}`(ユーザーエージェントスタイル)より
   優先されてしまい、js/app.jsが`ocrBtn.hidden = true`で隠しているつもりでも実際には
   ずっと表示され続けていた。この24x24pxの丸ボタンがセッションカードの右上に常時
   重なっていたため、セッションへ入ろうとタップした位置がたまたまそこに重なると、入室では
   なくOCR(タイトル編集用)が起動してしまう不具合の原因になっていた。`[hidden]`付きの
   セレクタで明示的に上書きし、本来の意図通りTitle編集中だけ表示されるようにする。 */
.star-card-title-ocr-btn[hidden] { display: none; }

.star-card--session .star-card-memo,
.star-card--session .star-card-memo-view {
  margin: 0 8px 8px;
}

/* ---------- インフォメーションカード(展覧会の会期・時間を記録するリマインダー) ---------- */

.star-card--info {
  padding: 10px 12px;
}

.star-card-info-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.03em;
  color: #2e7d32;
  margin-bottom: 6px;
}
.star-card-info-badge.closed { color: var(--muted); }
.star-card-info-badge.unparsed { color: var(--muted); }
.star-card-info-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.star-card-info-title {
  font-family: var(--serif);
  font-size: 13.5px;
  line-height: 1.4;
  margin: 0;
}
/* 折りたたみ時だけタイトルを1行省略にする(展開時は全文表示) */
.star-card--info:has(.star-card-info-body[hidden]) .star-card-info-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.star-card-info-venue {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--muted);
  margin: 3px 0 0;
}

.star-card-info-body {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.star-card-info-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 10px 0 5px;
}
.star-card-info-label:first-child { margin-top: 0; }

.star-card-info-text {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 7px 8px;
  background: var(--bg);
  pointer-events: auto;
}

/* 解析済み後、コピペ欄を畳んで代わりに出すペンアイコン(ズームジェスチャーとの競合防止) */
.star-card-info-edit-raw-btn {
  display: block;
  width: 100%;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.02em;
  background: transparent;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
}
.star-card-info-edit-raw-btn:hover { color: var(--text); border-color: var(--text); }

.star-card-info-parse-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 8px 10px;
  cursor: pointer;
}
.star-card-info-parse-btn:hover { opacity: 0.85; }

.star-card-info-result {
  margin-top: 10px;
  padding: 10px 11px;
  background: var(--surface-2);
  border-radius: 4px;
  font-size: 11.5px;
  line-height: 1.7;
}
.star-card-info-result .row { display: flex; gap: 8px; }
.star-card-info-result .row b {
  flex: none;
  width: 52px;
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  padding-top: 2px;
}
.star-card-info-result .chip-row { display: flex; flex-wrap: wrap; gap: 4px; }
.star-card-info-result .chip {
  font-family: var(--mono);
  font-size: 9.5px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
}
.star-card-info-result .chip.closed { color: var(--rust); border-color: rgba(179, 64, 43, 0.35); }
.star-card-info-result .chip.exception { color: #2e7d32; border-color: rgba(46, 125, 50, 0.35); }

.star-card-info-link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.star-card-info-error {
  margin-top: 10px;
  padding: 10px 11px;
  background: rgba(179, 64, 43, 0.07);
  border: 1px solid rgba(179, 64, 43, 0.25);
  border-radius: 4px;
}
.star-card-info-error .title {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--rust);
  margin: 0 0 6px;
}
.star-card-info-error .hint {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}
.star-card-info-error .manual-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px 9px;
  margin-top: 8px;
}
.star-card-info-error .manual-fields label {
  font-family: var(--mono);
  font-size: 8.5px;
  color: var(--muted);
  display: block;
  margin-bottom: 3px;
}
.star-card-info-error .manual-fields input {
  width: 100%;
  font-family: var(--mono);
  font-size: 10.5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 5px 6px;
  background: #fff;
}
.star-card-info-fix-btn {
  display: block;
  width: 100%;
  margin-top: 9px;
  font-family: var(--mono);
  font-size: 10.5px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
}

.star-card-info-resync-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 10px;
  cursor: pointer;
}
.star-card-info-resync-btn:hover { border-color: var(--text); }

/* ---------------- ストリートビューカード ---------------- */
.star-card--streetview {
  padding: 8px 8px 10px;
}

.star-card-streetview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: grab;
}

.star-card-streetview-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.star-card-streetview-change-btn {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
}
.star-card-streetview-change-btn:hover { color: var(--text); border-color: var(--text); }

/* .star-card-mediaの汎用ルール(flex:1・min-height:40px)を継承しつつ、パノラマが
   窮屈にならないよう既定の最小高さだけ底上げする。 */
.star-card-media-streetview { min-height: 140px; position: relative; overflow: hidden; }

/*
 * iframeはpointer-events:autoのまま(=中は本物のストリートビューとして自由にドラッグ・
 * ズームできる)。クロスオリジンiframe内で起きたpointerdownはそもそも親のカード移動
 * リスナーまでバブリングしてこないため、カードの移動はヘッダー帯かハンドルから行う設計。
 */
.star-card-streetview-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.star-card-streetview-setup {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  background: var(--surface-2);
  border-radius: 4px;
}
.star-card-streetview-input {
  flex: 1;
  min-height: 50px;
  resize: none;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 7px 8px;
  background: #fff;
}
.star-card-streetview-go-btn {
  display: block;
  width: 100%;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 7px 0;
  cursor: pointer;
}
.star-card-streetview-go-btn:hover { opacity: 0.85; }
.star-card-streetview-warn {
  margin: 0;
  font-size: 10px;
  line-height: 1.5;
  color: var(--rust);
}

/* ---------------- サマリーカード ---------------- */
.star-card--summary {
  padding: 10px 12px 12px;
  padding-top: 30px;
}

/* ヘッダーの特注ヘックスタブ。カード上辺にまたがる形で2つ並べる(編集ガイドのヘックスと同じ意匠) */
.star-card-summary-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -62%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  width: max-content;
  max-width: 340px;
  gap: 6px;
  z-index: 4;
}
.star-card-summary-btn {
  position: relative;
  width: 104px;
  height: 38px;
  clip-path: polygon(12% 0%, 88% 0%, 100% 38%, 88% 100%, 12% 100%, 0% 38%);
  background: var(--text);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.22);
  transition: transform 0.12s ease-out, background 0.12s ease-out;
}
.star-card-summary-btn:hover:not(:disabled) { background: #2e7d32; transform: translateY(-1px); }
.star-card-summary-btn:disabled { opacity: 0.55; cursor: default; }
.star-card-summary-btn .emoji { font-size: 12.5px; line-height: 1; }

.star-card-summary-session {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 2px;
}
.star-card-summary-session .dot { width: 5px; height: 5px; border-radius: 50%; background: #2e7d32; flex: none; }

.star-card-summary-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
  margin: 8px 0 5px;
}

.star-card-summary-input {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 7px 8px;
  background: var(--bg);
  pointer-events: auto;
}

.star-card-summary-hint {
  font-size: 10px;
  line-height: 1.6;
  color: var(--muted);
  margin: 7px 0 0;
}

.star-card-summary-roundtable-btn {
  width: 100%;
  margin-top: 8px;
  padding: 7px 8px;
  border: none;
  border-radius: 4px;
  background: #2e7d32;
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 10.5px;
  cursor: pointer;
  pointer-events: auto;
}
.star-card-summary-roundtable-btn:hover { background: #256b29; }

.star-card-summary-question-btn {
  width: 100%;
  margin-top: 8px;
  padding: 7px 8px;
  border: 1px solid #2e7d32;
  border-radius: 4px;
  background: rgba(46, 125, 50, 0.1);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 700;
  font-size: 10.5px;
  cursor: pointer;
  pointer-events: auto;
}
.star-card-summary-question-btn:hover:not(:disabled) { background: rgba(46, 125, 50, 0.2); }
.star-card-summary-question-btn:disabled { opacity: 0.55; cursor: default; }

.star-card-summary-question-hint {
  font-size: 9px;
  line-height: 1.6;
  color: var(--muted);
  margin: 4px 0 0;
}

.star-card-summary-divider {
  margin: 10px 0;
  border-top: 1px dashed var(--line);
}

.star-card-summary-paste-input {
  width: 100%;
  min-height: 46px;
  resize: vertical;
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 11px;
  line-height: 1.6;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 6px 8px;
  background: var(--bg);
  pointer-events: auto;
}

.star-card-summary-paste-btn {
  width: 100%;
  margin-top: 6px;
  padding: 7px 8px;
  border: none;
  border-radius: 4px;
  background: #2e7d32;
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 10.5px;
  cursor: pointer;
  pointer-events: auto;
}
.star-card-summary-paste-btn:hover { background: #256b29; }

/* ---------- チャットカード「座談会」(mediaType:'chat'、2026年9月追加) ---------- */
.star-card--chat { border-color: #2e7d32; }

.star-card-chat-head {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 6px;
}
.star-card-chat-head .dot { width: 5px; height: 5px; border-radius: 50%; background: #2e7d32; flex: none; }

.star-card-chat-log {
  /* カードをリサイズハンドルで広げた時、会話ログがその分だけ大きく表示されて全体を俯瞰できる
     ようにしたい(2026年9月要望)ため、固定のmax-heightは持たせず、カード本体の高さに応じて
     flex:1で伸縮させる(ヘッダー・入力欄・ボタンなど他の要素は高さ固定のため、余った縦幅は
     すべてログに回る)。overflow-yは、それでも会話が長くて収まりきらない時の保険として残す。 */
  flex: 1;
  min-height: 60px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: auto;
}

.star-card-chat-empty { font-size: 10.5px; color: var(--muted); margin: 0; line-height: 1.6; }

.star-card-chat-question {
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(46, 125, 50, 0.08);
  border: 1px dashed rgba(46, 125, 50, 0.4);
}

.star-card-chat-line { display: flex; gap: 7px; align-items: flex-start; }
.star-card-chat-avatar {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; background: #f2f2f0; border: 1px solid var(--line);
}
/* .crewは元々.star-card-chat-line(発言の吹き出し全体)にだけ付ける想定だったが、タイピング
   ドット・宛先選択の選択肢一覧ではアバター単体に付けているため、両方のパターンに対応する。 */
.star-card-chat-line.crew .star-card-chat-avatar,
.star-card-chat-avatar.crew { background: rgba(85, 230, 247, 0.25); border-color: rgba(85, 230, 247, 0.6); }
.star-card-chat-bubble { flex: 1; min-width: 0; }
.star-card-chat-name { font-family: var(--mono); font-size: 8.5px; color: var(--muted); margin-bottom: 2px; }
.star-card-chat-text {
  font-size: 11px; line-height: 1.5;
  background: #f7f7f5; border-radius: 8px; border-top-left-radius: 2px;
  padding: 6px 8px; display: inline-block;
}

/* 座談会カスケード中の「考え中…」タイピングドット(2026年9月追加、runChatCascade()参照) */
.star-card-chat-typing { display: flex; gap: 7px; align-items: center; }
.star-card-chat-typing-dots {
  display: flex; gap: 3px; background: #f7f7f5; border-radius: 8px; border-top-left-radius: 2px;
  padding: 7px 9px;
}
.star-card-chat-typing-dots span {
  width: 4px; height: 4px; border-radius: 50%; background: var(--muted); display: block;
  animation: starCardChatTypingBounce 1s infinite ease-in-out;
}
.star-card-chat-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.star-card-chat-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes starCardChatTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.star-card-chat-target-tag { color: #2e7d32; font-weight: 400; }
.star-card-chat-question-img {
  display: block; margin-top: 6px; width: 72px; height: 54px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--line);
}

/* 質問コンポーザー(🎯宛先・📷写真添付・入力・送信、2026年9月に「次の発言を進める」の
   手動ボタンから作り替え) */
.star-card-chat-attach-preview {
  display: flex; align-items: center; gap: 6px; margin-top: 8px; pointer-events: auto;
}
.star-card-chat-attach-thumb {
  width: 28px; height: 28px; border-radius: 4px; object-fit: cover; border: 1px solid var(--line);
}
.star-card-chat-attach-clear {
  border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 50%;
  width: 16px; height: 16px; font-size: 8px; cursor: pointer; pointer-events: auto; line-height: 1;
}

.star-card-chat-target-popover {
  margin-top: 8px; padding: 7px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); pointer-events: auto;
}
.star-card-chat-target-label {
  font-family: var(--mono); font-size: 8px; letter-spacing: 0.05em; color: var(--muted);
  text-transform: uppercase; margin: 0 0 5px;
}
.star-card-chat-target-options { display: flex; flex-direction: column; gap: 1px; max-height: 140px; overflow-y: auto; }
.star-card-chat-target-option {
  display: flex; align-items: center; gap: 7px; padding: 4px 5px; border-radius: 4px;
  border: none; background: none; cursor: pointer; text-align: left; width: 100%; font-family: var(--sans);
}
.star-card-chat-target-option:hover { background: #f4f4f2; }
.star-card-chat-target-option .star-card-chat-avatar { width: 20px; height: 20px; font-size: 10px; }
.star-card-chat-target-option-name { font-size: 10.5px; flex: 1; }
.star-card-chat-target-option-check {
  width: 13px; height: 13px; border-radius: 3px; border: 1.5px solid var(--line); flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 8px; color: transparent;
}
.star-card-chat-target-option.checked .star-card-chat-target-option-check {
  background: rgba(85, 230, 247, 0.9); border-color: rgba(85, 230, 247, 0.9); color: #06282c;
}
.star-card-chat-target-summary {
  margin: 5px 0 0; padding-top: 5px; border-top: 1px solid var(--line);
  font-family: var(--mono); font-size: 8.5px; color: var(--muted);
}

.star-card-chat-composer-row { display: flex; align-items: center; gap: 5px; margin-top: 8px; }
.star-card-chat-target-btn, .star-card-chat-attach-btn {
  flex: none; width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); font-size: 12px; cursor: pointer; pointer-events: auto; position: relative;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.star-card-chat-target-btn.active { border-color: rgba(85, 230, 247, 0.9); background: rgba(85, 230, 247, 0.14); }
.star-card-chat-target-badge {
  position: absolute; top: -5px; right: -5px; min-width: 13px; height: 13px; padding: 0 2px;
  border-radius: 999px; background: rgba(85, 230, 247, 0.9); color: #06282c;
  font-family: var(--mono); font-size: 7.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.star-card-chat-composer-input {
  flex: 1; min-width: 0; font-family: var(--sans); font-size: 10.5px;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
  color: var(--text); background: var(--bg); pointer-events: auto;
}
.star-card-chat-send-btn {
  flex: none; width: 28px; height: 28px; border-radius: 6px; border: none;
  background: #2e7d32; color: #fff; font-size: 12px; cursor: pointer; pointer-events: auto;
  display: flex; align-items: center; justify-content: center; padding: 0;
}
.star-card-chat-send-btn:hover:not(:disabled) { background: #256b29; }
.star-card-chat-send-btn:disabled { opacity: 0.5; cursor: default; }

.star-card-chat-status { font-size: 9px; color: var(--muted); margin: 5px 0 0; min-height: 12px; }

/* ---------- コメントカード(mediaType:'comment'、2026年9月追加) ----------
   顔文字・名前・コメント本文だけの軽い読み取り専用カード。座談会と同じCrewsの水色(cyan)を
   踏襲しつつ、既存カードのメモ欄よりも小さく・素早く読める粒度にしてある。 */
.star-card--comment { border-color: rgba(85, 230, 247, 0.8); }
.star-card-comment-head { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.star-card-comment-avatar {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 13px;
  background: rgba(85, 230, 247, 0.25); border: 1px solid rgba(85, 230, 247, 0.6);
}
.star-card-comment-name { font-family: var(--mono); font-size: 9.5px; font-weight: 700; color: #06282c; }
.star-card-comment-text { font-size: 11px; line-height: 1.55; }

/* Crewsモジュール(js/modules/crews.js)が追加するペルソナのヘックス。既存のEducation/Academicと
   同じ意匠だが、水色(モジュール共通のcyan)で塗って「ここから先はペルソナ」と分かるようにする */
.star-card-summary-crew-btn {
  position: relative;
  width: 104px;
  height: 38px;
  clip-path: polygon(12% 0%, 88% 0%, 100% 38%, 88% 100%, 12% 100%, 0% 38%);
  background: #55e6f7;
  color: #06282c;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease-out, background 0.12s ease-out;
}
.star-card-summary-crew-btn:hover:not(:disabled) { background: #83eefb; transform: translateY(-1px); }
.star-card-summary-crew-btn:disabled { opacity: 0.55; cursor: default; }
.star-card-summary-crew-btn .emoji { font-size: 12.5px; line-height: 1; flex: none; }
/* 「名前：役割」形式は長くなりうるため省略記号にする(フルネームはtitle属性で見える) */
.star-card-summary-crew-btn .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 68px;
}

/* Crewsが生成したテクストカード。通常のテクストカードと一目で区別できるよう水色グラスモーフにする */
.star-card--crew {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.42)), rgba(85, 230, 247, 0.13);
  border-color: rgba(85, 230, 247, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 26px rgba(20, 120, 130, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}
.star-card-crew-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 8px 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(85, 230, 247, 0.5);
}
.star-card-crew-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(85, 230, 247, 0.5);
}
.star-card-crew-name {
  font-family: var(--sans);
  font-weight: 700;
  font-size: 11px;
  color: #083338;
}

/* WormGateのジャンプ着地演出と同じ視覚言語(緑のリング)を、こちらは基本機能側で独自に持つ */
.star-card--landed {
  box-shadow: 0 0 0 3px #2e7d32, 0 20px 44px rgba(0, 0, 0, 0.3) !important;
  transition: box-shadow 0.15s ease-out;
}

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  padding: 16px;
}

.modal-overlay.visible { display: flex; }

.modal {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}

/* 設定モーダルの右上に置く閉じるボタン(2026年9月追加)。既存の#settings-cancel-btnと
   表示条件を揃えている(初回の必須設定中は出さない)。 */
.modal-close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.modal-close-btn:hover { color: var(--text); }

.modal h2 {
  font-family: var(--serif);
  font-weight: 500;
  margin: 0 0 8px;
  font-size: 18px;
}

.modal-desc {
  margin: 0 0 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.modal label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 12px;
}

.modal input {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
}

.modal-error {
  margin: 0 0 12px;
  font-size: 12px;
  color: var(--rust);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.modal button.secondary {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

/* 元に戻せない破壊的な選択肢(写真の完全削除など)であることを視覚的にも区別するための強調色。
   showChoiceDialog()のdangerオプション用(2026年9月追加、Extractの誤操作による写真消失を防ぐため)。 */
.modal button.danger {
  background: var(--rust);
  border: 1px solid var(--rust);
  color: #fff;
}

/* 設定モーダル内の区切り線・「Driveへのアップロード」セクション見出し(2026年9月追加、
   Driveへの手動送信ボタンを誤操作の少ない設定モーダルへ移設した際に追加)。 */
.modal-divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

.settings-drive-upload-label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 6px;
}

/* ---------- Extract範囲選択オーバーレイ(自由形状でなぞって範囲を選ぶ、2026年9月追加) ----------
   常時黒背景のカメラオーバーレイと同じ、アプリ本体のテーマとは独立した見た目にする
   (フルスクリーンで写真そのものに集中させたいため)。 */
#extract-region-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 210;
  background: #0a0a0a;
  color: #fff;
  font-family: 'IBM Plex Mono', monospace;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  -webkit-user-select: none;
  user-select: none;
}
#extract-region-overlay.open { display: flex; }

#extract-region-close {
  position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 8px; z-index: 20;
  background: rgba(0, 0, 0, 0.55); border: 1px solid rgba(255, 255, 255, 0.25); color: #fff;
  font-family: inherit; font-size: 10px; padding: 7px 10px; border-radius: 14px; cursor: pointer;
}

.erx-hint {
  margin: 0; font-size: 10px; letter-spacing: 0.05em; color: rgba(255, 255, 255, 0.65);
  text-align: center;
}

.erx-stage {
  position: relative; touch-action: none; line-height: 0;
  max-width: min(92vw, 900px); max-height: 58vh;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}
.erx-stage img { display: block; max-width: min(92vw, 900px); max-height: 58vh; user-select: none; -webkit-user-drag: none; }
.erx-stage canvas { position: absolute; top: 0; left: 0; cursor: crosshair; }

.erx-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.erx-btn-primary, .erx-btn-secondary {
  padding: 9px 14px; border-radius: 6px; font-family: 'Zen Kaku Gothic New', sans-serif;
  font-weight: 700; font-size: 12px; cursor: pointer;
}
.erx-btn-primary { border: none; background: #3fae63; color: #06180d; }
.erx-btn-primary:hover:not(:disabled) { background: #59c67c; }
.erx-btn-primary:disabled { opacity: 0.4; cursor: default; }
.erx-btn-secondary { border: 1px solid rgba(255, 255, 255, 0.25); background: transparent; color: #fff; }
.erx-btn-secondary:hover { border-color: rgba(63, 174, 99, 0.6); }

/* ---------- CONSTELLATION PIE(キャンバス長押しメニュー) ---------- */

#pie-menu {
  position: fixed;
  inset: 0;
  z-index: 200;
  pointer-events: none;
}

.pie-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.pie-origin-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: #000000;
}

.pie-item {
  position: fixed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--muted);
  transform: translate(0, 0) scale(1);
  transition: transform 0.06s ease-out, background 0.06s ease-out, color 0.06s ease-out;
  will-change: transform;
}

.pie-item svg {
  width: 16px;
  height: 16px;
}

.pie-item-label {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.pie-item--active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
  z-index: 1;
}
