/* unthink v4: news-card 風レイアウト (mobile-first 402px) */
:root {
  --unthink-bg: #ffffff;
  --unthink-fg: #111111;
  --unthink-sub: #6b6b6b;
  --unthink-muted: #aeaaaa;
  --unthink-border: #ececec;
  --unthink-soft: #ffffff;
  --unthink-primary: #000000;
  --unthink-primary-fg: #ffffff;
  --unthink-frame: #d4efe9;   /* 左右の枠 */
}

@media (prefers-color-scheme: dark) {
  :root {
    --unthink-bg: #0e0e0e;
    --unthink-fg: #f2f2f2;
    --unthink-sub: #9a9a9a;
    --unthink-muted: #777777;
    --unthink-border: #222222;
    --unthink-soft: #1a1a1a;
    --unthink-primary: #ffffff;
    --unthink-primary-fg: #111111;
    --unthink-frame: #0f3833;
  }
}

html[data-theme="light"] {
  --unthink-bg: #ffffff; --unthink-fg: #111111; --unthink-sub: #6b6b6b;
  --unthink-muted: #aeaaaa; --unthink-border: #ececec; --unthink-soft: #ffffff;
  --unthink-primary: #000000; --unthink-primary-fg: #ffffff; --unthink-frame: #d4efe9;
}
html[data-theme="dark"] {
  --unthink-bg: #0e0e0e; --unthink-fg: #f2f2f2; --unthink-sub: #9a9a9a;
  --unthink-muted: #777777; --unthink-border: #222222; --unthink-soft: #1a1a1a;
  --unthink-primary: #ffffff; --unthink-primary-fg: #111111; --unthink-frame: #0f3833;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--unthink-frame);
  color: var(--unthink-fg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* ===== PCレスポンシブ（3カラム） ===== */
.unthink-desktop-layout { display: contents; }
.desktop-sidebar { display: none; }

@media (min-width: 768px) {
  body { background: var(--unthink-bg); }
  .unthink-desktop-layout {
    display: grid;
    grid-template-columns: 200px minmax(0, 520px) 280px;
    gap: 0;
    max-width: 1000px;
    margin: 0 auto;
    min-height: 100vh;
  }
  .desktop-sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
  .desktop-sidebar-left {
    padding: 20px 16px;
    border-right: 1px solid var(--unthink-border);
  }
  .desktop-sidebar-right {
    padding: 20px 16px;
    border-left: 1px solid var(--unthink-border);
  }
  .sidebar-brand {
    color: var(--unthink-fg);
    text-decoration: none;
    display: block;
    margin-bottom: 24px;
    line-height: 0;
  }
  .sidebar-brand .unthink-logo { width: 96px; height: 18px; display: block; }
  .sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }
  .sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 24px;
    font-size: 14px;
    color: var(--unthink-fg);
    text-decoration: none;
    transition: background 0.15s;
  }
  .sidebar-nav-item:hover { background: var(--unthink-border); }
  .sidebar-compose-btn {
    margin-top: 20px;
    margin-left: auto;
    margin-right: auto;
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--unthink-primary);
    color: var(--unthink-primary-fg);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }
  .sidebar-compose-btn:hover { opacity: 0.9; }
  .sidebar-user {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 36px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
  }
  /* 管理者モード切替（ユーザー名の上に配置） */
  .sidebar-admin-toggle {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 80px;
    padding: 8px 4px;
  }
  .sidebar-admin-toggle .admin-switch { width: 100%; }
  .sidebar-admin-toggle .admin-switch-label { color: var(--unthink-muted); font-size: 12px; }
  .sidebar-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--unthink-soft);
    color: var(--unthink-muted);
    flex-shrink: 0;
    text-decoration: none;
  }
  .sidebar-user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
  .sidebar-user-avatar-placeholder { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
  .sidebar-user-avatar:hover { color: var(--unthink-fg); }
  .desktop-sidebar-left { position: relative; }
  .sidebar-user-name {
    font-size: 12px;
    color: var(--unthink-muted);
    text-decoration: none;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sidebar-user-name:hover { color: var(--unthink-fg); }
  .sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    font-size: 11px;
    color: var(--unthink-muted);
    text-align: center;
  }
  .sidebar-section { margin-bottom: 24px; }
  .sidebar-section-title {
    font-size: 14px; font-weight: 700; margin: 0 0 10px;
    color: var(--unthink-fg);
  }
  .sidebar-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    color: var(--unthink-fg);
    text-decoration: none;
    border-bottom: 1px solid var(--unthink-border);
  }
  .sidebar-item:last-child { border-bottom: none; }
  .sidebar-item:hover { color: var(--unthink-muted); }

  /* アプリ本体の調整 */
  .unthink-app {
    max-width: none;
    width: 100%;
    min-width: 0;
    border-left: none;
    border-right: none;
  }

  /* PC: タブ位置調整（ヘッダ非表示のため） */
  .tabs { top: 0; }

  /* PC: モバイルヘッダを非表示（左サイドバーに移行） */
  .unthink-header { display: none !important; }

  /* PC: モバイルフッタを非表示 */
  .unthink-footer { display: none !important; }

  /* PC: FABを非表示（左サイドバーにcomposeボタンあり） */
  .unthink-fab,
  #fab-btn,
  button.unthink-fab { display: none !important; }

  /* PC: グローバルローディングの位置調整 */
  .global-loading { z-index: 200; }

}

.unthink-app {
  max-width: 402px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--unthink-bg);
  position: relative;
}

/* ヘッダ: 中央寄せのブランド */
.unthink-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--unthink-bg);
  padding: 14px 16px 10px;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  text-align: center;
  min-height: 52px;
  box-sizing: border-box;
}
.unthink-header .brand {
  grid-column: 2;
  color: var(--unthink-fg);
  text-decoration: none;
  line-height: 0;
  display: inline-flex;
  align-items: center;
}
.unthink-header .brand .unthink-logo { width: 96px; height: 18px; display: block; }
.unthink-header .header-back { grid-column: 1; justify-self: start; }
.unthink-header .header-right {
  grid-column: 3;
  justify-self: end;
  display: flex; align-items: center; gap: 6px;
}
.unthink-header.minimal { grid-template-columns: 40px 1fr 40px; }
.unthink-header .me { font-size: 11px; color: var(--unthink-muted); }
.unthink-header .header-user-avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  overflow: hidden; background: var(--unthink-soft); color: var(--unthink-muted);
  flex-shrink: 0; text-decoration: none;
}
.unthink-header .header-user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.unthink-header .header-user-avatar-placeholder { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.unthink-header .header-user-avatar:hover { color: var(--unthink-fg); }
.muted { color: var(--unthink-muted); }

.ut-icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

.icon-btn {
  background: none; border: none; color: var(--unthink-fg);
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
  padding: 0; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--unthink-soft); }
.icon-btn.small { width: 26px; height: 26px; }

.unthink-main { flex: 1; padding-bottom: 160px; }

/* タブ（おすすめ / フォロー中 / マイチーム） */
.tabs {
  display: flex;
  padding: 8px 8px 0;
  border-bottom: 1px solid var(--unthink-border);
  position: sticky; top: 52px; background: var(--unthink-bg); z-index: 10;
}
@media (min-width: 768px) {
  /* PC: モバイルヘッダ非表示なので tabs は viewport 上端に貼り付ける */
  body.is-app-page .tabs { top: 0 !important; }
  /* PC: メニュー(左サイドバー)を確実に固定 */
  body.is-app-page .desktop-sidebar-left {
    position: sticky !important;
    top: 0 !important;
    height: 100vh !important;
    align-self: start;
  }
}

/* (PC 1280px 以下のサイドバー圧縮は app.css 末尾で適用 — 他の app/home 用 grid 上書きの後で勝つ必要があるため) */
.tabs .tab {
  flex: 1;
  text-align: center;
  padding: 14px 0 14px;
  font-size: 15px;
  color: var(--unthink-fg);
  cursor: pointer;
  position: relative;
  font-weight: 500;
}
.tabs .tab::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 28%;
  right: 28%;
  height: 3px;
  background: transparent;
  border-radius: 2px;
}
.tabs .tab.active {
  font-weight: 700;
}
.tabs .tab.active::after {
  background: var(--unthink-fg);
}

/* 投稿カード: 左=タイトル+本文+メタ、右=サムネ、下=アクション行 */
.post-card {
  padding: 14px 16px;
  border-bottom: 1px solid var(--unthink-border);
  cursor: pointer;
}
.post-card:hover { background: rgba(0,0,0,0.015); }
@media (prefers-color-scheme: dark) {
  .post-card:hover { background: rgba(255,255,255,0.03); }
}
.post-card .top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: start;
  overflow: hidden;
}
.post-card .top.no-thumb {
  grid-template-columns: minmax(0, 1fr);
}
.post-card .body-col { min-width: 0; overflow: hidden; }
.post-card .title {
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
  color: var(--unthink-fg);
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: 0.01em;
}
.post-card .preview {
  margin-top: 4px;
  font-size: 16px;
  line-height: 1.55;
  color: var(--unthink-sub);
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card .reply-body {
  font-size: 16px;
  line-height: 1.6;
  color: var(--unthink-fg);
  word-break: break-word;
  white-space: pre-wrap;
}
.post-card .post-body {
  font-size: 16px;
  line-height: 1.6;
  color: var(--unthink-fg);
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card.is-reply { padding: 12px 16px; }
.post-card.is-reply .title {
  font-size: 14px;
  font-weight: 700;
  color: var(--unthink-fg);
  margin-bottom: 4px;
}

/* ===== スレッド表示専用レイアウト ===== */
.thread-post {
  position: relative;
  padding: 14px 16px;
  transition: background 0.3s;
}
.thread-post.highlight-flash {
  animation: highlight-pulse 2s ease-out;
}
@keyframes highlight-pulse {
  0%   { background: rgba(0,0,0,0.08); }
  50%  { background: rgba(0,0,0,0.04); }
  100% { background: transparent; }
}
.thread-post.highlight-flash {
  animation: highlight-pulse 3s ease-out;
}
.thread-post .thread-username {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.thread-post .thread-card {
  padding-left: 24px;
}
.thread-post .thread-body {
  font-size: 16px;
  line-height: 1.7;
  color: var(--unthink-fg);
  word-break: break-word;
}
/* ============ Markdown 描画 ============ */
.thread-body .md-h2,
.post-body .md-h2 { font-size: 17px; font-weight: 700; margin: 14px 0 6px; line-height: 1.4; }
.thread-body .md-h3,
.post-body .md-h3 { font-size: 15px; font-weight: 700; margin: 12px 0 4px; line-height: 1.4; }
.thread-body .md-h4,
.post-body .md-h4 { font-size: 14px; font-weight: 600; margin: 10px 0 4px; color: var(--unthink-sub, var(--unthink-fg)); }
.thread-body .md-list,
.post-body .md-list { margin: 6px 0; padding-left: 22px; }
.thread-body .md-list li,
.post-body .md-list li { margin: 2px 0; }
.thread-body .md-table,
.post-body .md-table {
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 13px;
  display: block;
  overflow-x: auto;
  max-width: 100%;
}
.thread-body .md-table th,
.thread-body .md-table td,
.post-body .md-table th,
.post-body .md-table td {
  border: 1px solid var(--unthink-border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.thread-body .md-table th,
.post-body .md-table th {
  background: var(--unthink-soft);
  font-weight: 600;
  white-space: nowrap;
}
.thread-body .md-pre,
.post-body .md-pre {
  background: var(--unthink-soft);
  border: 1px solid var(--unthink-border);
  border-radius: 8px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.5;
  margin: 8px 0;
}
.thread-body .md-pre code,
.post-body .md-pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}
.thread-body .md-inline-code,
.post-body .md-inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--unthink-soft);
  border: 1px solid var(--unthink-border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.92em;
}
/* 引用ブロック (> ...) */
.md-quote,
blockquote.md-quote {
  border-left: 4px solid var(--unthink-border);
  background: var(--unthink-soft);
  margin: 8px 0;
  padding: 10px 14px;
  color: var(--unthink-sub, var(--unthink-fg));
  font-style: italic;
}
/* 引用内のブロック要素は italic を継承させない */
.md-quote .md-h2, .md-quote .md-h3, .md-quote .md-h4,
.md-quote .md-list, .md-quote .md-table,
.md-quote .md-mermaid-host, .md-quote .md-chart,
.md-quote strong { font-style: normal; }
/* 区切り線 */
.md-hr {
  border: none;
  border-top: 1px solid var(--unthink-border);
  margin: 12px 0;
}

/* 長い URL の表示は1行で省略 */
.long-url {
  display: inline-block;
  max-width: 100%;
  vertical-align: bottom;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* クイック選択肢ボタン (clarify_reply) */
.quick-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}
.quick-option {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--unthink-fg);
  background: var(--unthink-bg);
  border: 1px solid var(--unthink-border);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s, border-color 0.12s;
}
.quick-option:hover:not(:disabled) {
  background: var(--unthink-soft);
  border-color: var(--unthink-fg);
}
.quick-option:disabled {
  cursor: default;
  opacity: 0.55;
}
.quick-option.quick-option-selected {
  background: var(--unthink-fg);
  color: var(--unthink-bg);
  border-color: var(--unthink-fg);
  opacity: 1;
}

/* 「作成した資料を開く」ボタン (task_reply 投稿) */
.task-doc-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--unthink-fg);
  background: var(--unthink-soft);
  border: 1px solid var(--unthink-border);
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.task-doc-open:hover { background: var(--unthink-border); }
.task-doc-open .ut-icon { color: var(--unthink-muted); }

/* 資料ポップアップモーダル */
.task-doc-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.task-doc-modal[hidden] { display: none; }
.task-doc-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
  cursor: pointer;
}
.task-doc-dialog {
  position: relative;
  z-index: 1;
  background: #fff;
  width: 96vw;
  max-width: 900px;
  height: 92vh;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.task-doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}
.task-doc-title {
  font-weight: 700;
  color: #111;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  padding-right: 12px;
}
.task-doc-header-actions { display: flex; align-items: center; gap: 6px; }
.task-doc-action {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; font-size: 13px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  color: #111;
  cursor: pointer;
  font-family: inherit;
}
.task-doc-action:hover { background: #f3f4f6; }
.task-doc-close {
  width: 32px; padding: 0;
  justify-content: center; font-size: 18px;
}
.task-doc-meta {
  padding: 6px 18px;
  font-size: 12px;
  color: #6b7280;
  border-bottom: 1px solid #e5e7eb;
}
.task-doc-stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #fff;
}
.task-doc-loading {
  padding: 40px;
  text-align: center;
  color: #6b7280;
}
.task-doc-iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}
@media (max-width: 600px) {
  .task-doc-dialog {
    width: 100vw; height: 100vh; max-width: none; border-radius: 0;
  }
  .task-doc-action span { display: none; }
}

/* OGP プレビューカード */
.ogp-card {
  display: block;
  margin: 10px 0 4px;
  border: 1px solid var(--unthink-border);
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: var(--unthink-fg);
  background: var(--unthink-bg);
  transition: transform 0.12s, box-shadow 0.12s;
  position: relative;
}
.ogp-card:hover {
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  transform: translateY(-1px);
}
.ogp-image-wrap {
  position: relative;
  width: 100%;
  background: #000;
  aspect-ratio: 1.91 / 1; /* OGP 推奨比 */
  overflow: hidden;
}
.ogp-image-wrap.ogp-img-err {
  display: none; /* 画像読み込み失敗時はオーバーレイのみ表示 */
}
.ogp-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.ogp-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 14px 12px;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.78) 0%, rgba(0,0,0,0.45) 60%, rgba(0,0,0,0) 100%);
}
.ogp-overlay .ogp-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.ogp-overlay .ogp-host {
  margin-top: 4px;
  font-size: 11px;
  opacity: 0.85;
  text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}
.ogp-text-only {
  padding: 12px 14px;
}
.ogp-text-only .ogp-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--unthink-fg);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ogp-text-only .ogp-host {
  margin-top: 4px;
  font-size: 11px;
  color: var(--unthink-muted);
}

/* アプリ内通知トースト */
.unthink-toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
  pointer-events: none;
}
.unthink-toast {
  pointer-events: auto;
  background: var(--unthink-bg);
  color: var(--unthink-fg);
  border: 1px solid var(--unthink-border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15), 0 2px 6px rgba(0,0,0,0.08);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: start;
  animation: unthink-toast-in 0.22s ease-out;
  font-size: 13px;
}
@keyframes unthink-toast-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.unthink-toast-icon {
  width: 28px; height: 28px;
  background: var(--unthink-soft);
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--unthink-muted);
}
.unthink-toast-body { min-width: 0; }
.unthink-toast-head { line-height: 1.4; }
.unthink-toast-snippet {
  color: var(--unthink-muted);
  font-size: 12px;
  margin-top: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.unthink-toast-actions {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.unthink-toast-open {
  font-size: 12px;
  color: var(--unthink-fg);
  text-decoration: none;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--unthink-soft);
}
.unthink-toast-open:hover { background: var(--unthink-border); }
.unthink-toast-close {
  background: none;
  border: none;
  color: var(--unthink-muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}
@media (max-width: 480px) {
  .unthink-toast-host {
    top: 8px;
    right: 8px;
    left: 8px;
    max-width: none;
  }
}
/* Mermaid 図 */
.md-mermaid-host,
.md-mermaid-svg {
  margin: 10px 0;
  background: var(--unthink-bg);
  border: 1px solid var(--unthink-border);
  border-radius: 8px;
  padding: 10px;
  overflow-x: auto;
}
.md-mermaid-svg svg { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.md-mermaid {
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--unthink-muted);
}
/* Chart.js コンテナ */
.md-chart {
  position: relative;
  margin: 10px 0;
  padding: 10px;
  background: var(--unthink-bg);
  border: 1px solid var(--unthink-border);
  border-radius: 8px;
  /* 縦潰れ防止: 16:9 アスペクト比 + 最低 320px の高さを確保 */
  aspect-ratio: 16 / 9;
  min-height: 320px;
  max-height: 520px;
  width: 100%;
  box-sizing: border-box;
}
.md-chart canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.md-render-error {
  color: #e0245e;
  font-size: 12px;
  padding: 8px;
}
.md-render-error + pre {
  background: var(--unthink-soft);
  padding: 8px;
  font-size: 12px;
  overflow: auto;
  white-space: pre-wrap;
}

/* 画像クリック可能インジケータ — task 生成画像 + Mermaid + Chart のみ */
.thread-image.is-task-image,
.attachment-image.is-task-image img,
.md-mermaid-svg,
.md-chart canvas[data-rendered] {
  cursor: zoom-in;
}
/* 通常の投稿画像はクリック反応なし（カーソルもデフォルト） */
.thread-image:not(.is-task-image),
.attachment-image:not(.is-task-image) img {
  cursor: default;
}

/* 画像ライトボックス */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.image-lightbox[hidden] { display: none; }
.image-lightbox-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.86);
  cursor: zoom-out;
}
.image-lightbox-dialog {
  position: relative;
  z-index: 1;
  max-width: 96vw;
  max-height: 96vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.image-lightbox-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}
.image-lightbox-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.image-lightbox-btn:hover {
  background: rgba(255,255,255,0.2);
}
.image-lightbox-btn span { white-space: nowrap; }
.image-lightbox-close {
  font-size: 22px;
  line-height: 1;
  width: 36px;
  padding: 4px 0;
  justify-content: center;
}
.image-lightbox-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
}
.image-lightbox-img {
  display: block;
  width: 96vw;
  height: calc(96vh - 60px);
  max-width: 96vw;
  max-height: calc(96vh - 60px);
  object-fit: contain;
  border-radius: 6px;
  background: #ffffff;
}
@media (max-width: 480px) {
  .image-lightbox-btn span { display: none; }
  .image-lightbox-btn { padding: 8px; }
}
.thread-post .thread-image-wrap {
  margin-top: 10px;
  border-radius: 10px;
  overflow: hidden;
  background: #f0f0f0;
}
.thread-post .thread-image {
  display: block;
  width: 100%;
  height: auto;
  max-height: 360px;
  object-fit: cover;
}
.thread-post .thread-meta-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.thread-post .thread-actions {
  display: flex; align-items: center; gap: 18px;
  font-size: 12px; color: var(--unthink-muted);
}
.thread-post .thread-actions button {
  background: none; border: none; color: inherit; padding: 0; cursor: pointer;
  font-size: inherit; display: inline-flex; align-items: center; gap: 4px;
  font-family: inherit;
}
.thread-post .thread-actions button.active { color: var(--unthink-fg); font-weight: 600; }
.thread-post .thread-actions button.active .ut-icon { fill: currentColor; }
.thread-post .thread-time {
  font-size: 11px; color: var(--unthink-muted); margin-left: auto;
}

/* インデントは廃止: スレッドは全件フラットに並べる。
   どの投稿への返信かは「返信元」バッジで示し、クリックでジャンプ */
.thread-post .thread-rail { display: none; }

/* 返信元バッジ（ユーザー名の右に表示） */
.reply-to-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
  padding: 1px 8px 1px 6px;
  border-radius: 999px;
  background: var(--unthink-soft);
  border: 1px solid var(--unthink-border);
  color: var(--unthink-muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.6;
  vertical-align: middle;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reply-to-badge:hover {
  background: var(--unthink-border);
  color: var(--unthink-fg);
}
.reply-to-badge .ut-icon {
  flex-shrink: 0;
  color: var(--unthink-muted);
}

.post-card .thumb {
  display: block;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  object-fit: cover;
  background: #f0f0f0;
}
.post-card .thumb-link { display: block; width: 72px; height: 72px; flex-shrink: 0; }
.post-card .post-content-link,
.post-card .thumb-link {
  display: block;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}
.post-card .post-content-link:hover .title { text-decoration: underline; }
a.handle { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; }

/* ユーザー名前のアバターバッジ (丸+頭文字1桁) */
.user-avatar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6em;
  height: 1.6em;
  min-width: 1.6em;
  min-height: 1.6em;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  color: #fff;
  font-size: 0.75em;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
  flex: 0 0 auto;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0;
  user-select: none;
  padding: 0;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
a.handle:hover { text-decoration: underline; }
.post-card .meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--unthink-muted);
}
.post-card .meta > * { margin-right: 12px; }
.post-card .meta > *:last-child { margin-right: 0; }
.post-card .meta .time::before { content: ''; }
.ai-badge { display: none; }

/* 管理者モードのみ表示する要素 */
body:not(.is-admin) .llm-badge,
body:not(.is-admin) .llm-tokens,
body:not(.is-admin) .admin-only { display: none !important; }

/* スマホ: アプリページは横100%幅(フッター・FAB含む) */
@media (max-width: 767px) {
  body.is-app-page .unthink-app {
    max-width: none !important;
    width: 100% !important;
  }
  body.is-app-page .unthink-footer {
    max-width: none !important;
    width: 100% !important;
    left: 0 !important;
    transform: none !important;
  }
  body.is-app-page .unthink-fab {
    right: 16px !important;
  }
}

/* 2階層目ページのタイトルバー(PC表示時のみ) */
.page-title-bar { display: none; }
@media (min-width: 768px) {
  .page-title-bar {
    display: block;
    padding: 24px 24px 8px;
    box-sizing: border-box;
  }
  .page-title-bar .page-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--unthink-fg);
    letter-spacing: 0.01em;
  }
}

/* アプリ全幅レイアウト(home/search/notifications/profile/menu 共通) */
@media (min-width: 768px) {
  body.is-app-page .unthink-desktop-layout {
    grid-template-columns: 200px minmax(0, 1fr) !important;
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
  }
  body.is-app-page .desktop-sidebar-right { display: none !important; }
  body.is-app-page .desktop-sidebar-left { border-right: none !important; }
  body.is-app-page .unthink-app {
    max-width: none !important;
    width: 100% !important;
  }
  /* 非ホームページ: 右カラム max-width 720px(中央寄せ) */
  body.is-app-page:not(.is-home-page) .unthink-app > *:not(.compose-modal):not(.llm-prompt-modal):not(.global-loading):not(.unthink-fab):not(.unthink-footer):not(.glasp-extension):not(.glasp-extension-toaster) {
    width: 100%;
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
  }
  /* モーダル/オーバーレイ系は viewport 全体に展開させる */
  body.is-app-page .compose-modal,
  body.is-app-page .llm-prompt-modal,
  body.is-app-page .global-loading {
    max-width: none !important;
    width: auto !important;
    margin: 0 !important;
  }
}

/* 管理者モードスイッチ（汎用） */
.admin-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.admin-switch input { position: absolute; opacity: 0; pointer-events: none; }
.admin-switch-track {
  position: relative; display: inline-block;
  width: 32px; height: 18px;
  background: var(--unthink-border, #d1d5db);
  border-radius: 999px;
  transition: background 0.18s;
}
.admin-switch-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.18s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.admin-switch input:checked + .admin-switch-track { background: var(--unthink-primary, #2563eb); }
.admin-switch input:checked + .admin-switch-track .admin-switch-thumb { transform: translateX(14px); }
.admin-switch-label { font-size: 12px; color: var(--unthink-muted); }

/* LLM モデルバッジ（デバッグ用）— 本文末尾にインライン表示される小さなピル */
.llm-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 600;
  line-height: 14px;
  letter-spacing: 0.02em;
  border-radius: 999px;
  vertical-align: 1px;
  color: #fff;
  background: #999;
  white-space: nowrap;
  user-select: none;
}
.llm-badge.llm-gem   { background: #4285f4; }  /* Gemini   blue   */
.llm-badge.llm-cld-h { background: #d97706; }  /* Haiku    orange */
.llm-badge.llm-cld-s { background: #b45309; }  /* Sonnet   brown  */
.llm-badge.llm-cld-o { background: #78350f; }  /* Opus     dark   */
.llm-badge.llm-grk   { background: #111111; }  /* Grok     black  */
.llm-badge.llm-gpt   { background: #10a37f; }  /* OpenAI   green  */
.llm-badge.llm-gen   { background: #6b7280; }  /* fallback gray   */

/* バッジ右の入出力トークン量（デバッグ用、極小） */
.llm-tokens {
  display: inline-block;
  margin-left: 4px;
  padding: 0;
  font-size: 9px;
  line-height: 14px;
  letter-spacing: 0.02em;
  vertical-align: 1px;
  color: var(--unthink-muted, #6b7280);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}
.llm-tokens:hover { text-decoration: underline; }
.llm-badge[data-llm-prompt-toggle] { cursor: pointer; }

/* LLM プロンプトモーダル（デバッグ） */
.llm-prompt-modal[hidden] { display: none; }
.llm-prompt-modal {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
}
.llm-prompt-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.55);
}
.llm-prompt-dialog {
  position: relative;
  background: var(--unthink-bg, #fff);
  color: var(--unthink-fg, #111);
  border-radius: 12px;
  width: min(720px, 92vw);
  max-height: 86vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}
.llm-prompt-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  font-weight: 600;
}
.llm-prompt-header-actions { display: flex; align-items: center; gap: 10px; }
.llm-prompt-edit {
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 6px;
  background: #eef2ff; color: #3730a3;
  text-decoration: none;
}
.llm-prompt-edit:hover { background: #c7d2fe; }
.llm-prompt-close {
  background: none; border: none;
  font-size: 22px; line-height: 1;
  cursor: pointer; color: inherit; padding: 4px 8px;
}
.llm-prompt-meta {
  padding: 8px 16px;
  font-size: 12px;
  color: var(--unthink-muted, #6b7280);
  border-bottom: 1px solid #f3f4f6;
  font-variant-numeric: tabular-nums;
}
.llm-prompt-body {
  overflow: auto;
  padding: 12px 16px 16px;
  flex: 1;
}
.llm-prompt-body pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, "Courier New", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}
.post-card .actions {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--unthink-muted);
}
.post-card .actions button {
  background: none; border: none; color: inherit; padding: 0; cursor: pointer;
  font-size: inherit; display: inline-flex; align-items: center; gap: 4px;
  font-family: inherit;
}
.post-card .actions button.active { color: var(--unthink-fg); font-weight: 600; }
.post-card .actions button.active .ut-icon { fill: currentColor; }
.post-card .actions .count { font-variant-numeric: tabular-nums; }
.post-card .actions .spacer { flex: 1; }

/* ポストメニュー */
.post-menu { position: relative; }
.post-menu-btn {
  background: none; border: none; color: var(--unthink-muted);
  font-size: 14px; cursor: pointer; padding: 4px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.post-menu-btn:hover { background: var(--unthink-soft); }
.post-menu-items {
  display: none; position: absolute; right: -4px; top: calc(100% + 8px);
  background: var(--unthink-bg);
  border: 1px solid var(--unthink-border);
  border-radius: 12px;
  min-width: 180px;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  padding: 6px;
  overflow: hidden;
}
.post-menu-items.open {
  display: block;
  animation: unthink-menu-in 0.12s ease-out;
}
@keyframes unthink-menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
/* ポインタ: ⋯ボタンの下向き三角 */
.post-menu-items::before,
.post-menu-items::after {
  content: '';
  position: absolute;
  right: 12px;
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
}
.post-menu-items::before {
  top: -7px;
  border-bottom: 7px solid var(--unthink-border);
}
.post-menu-items::after {
  top: -6px;
  border-bottom: 7px solid var(--unthink-bg);
}
.post-menu-items button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  background: none; border: none;
  padding: 10px 14px;
  font-size: 14px; color: var(--unthink-fg);
  cursor: pointer; font-family: inherit;
  border-radius: 8px;
  line-height: 1.3;
}
.post-menu-items button + button { margin-top: 2px; }
.post-menu-items button:hover { background: var(--unthink-soft); }
.post-menu-items button .ut-icon { color: var(--unthink-muted); flex-shrink: 0; }
.post-menu-items button.destructive { color: #e0245e; }
.post-menu-items button.destructive:hover { background: rgba(224, 36, 94, 0.08); }
.post-menu-items button.destructive .ut-icon { color: #e0245e; }

/* フッタ: 4アイテム + 右寄りFAB */
.unthink-footer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 402px;
  background: var(--unthink-bg);
  border-top: 1px solid var(--unthink-border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: center;
  padding: 6px 0 10px;
  z-index: 30;
}
.unthink-footer .nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; color: var(--unthink-muted);
  padding: 4px 0;
}
.unthink-footer .nav-item .label { margin-top: 0; }
.unthink-footer .nav-item.active { color: var(--unthink-fg); }

/* FAB（フッタの少し上・アプリ右端から16px） */
.unthink-fab {
  position: fixed;
  bottom: 88px;
  right: calc(max(0px, (100% - 402px) / 2) + 16px);
  width: 56px; height: 56px;
  background: var(--unthink-primary);
  color: var(--unthink-primary-fg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  z-index: 31;
  border: none; cursor: pointer;
  text-decoration: none;
  transition: opacity .18s ease, transform .18s ease;
}
.unthink-fab.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(24px);
}

/* 投稿作成ページ */
.compose {
  padding: 12px 16px;
  border-bottom: 8px solid var(--unthink-soft);
}
.compose textarea {
  width: 100%; border: none; outline: none; resize: vertical;
  font-family: inherit; font-size: 15px; min-height: 80px;
  background: transparent; color: var(--unthink-fg);
}
.compose .compose-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.btn {
  display: inline-block; padding: 6px 18px; border-radius: 15px;
  background: var(--unthink-primary); color: var(--unthink-primary-fg);
  border: none; font-size: 14px; cursor: pointer; font-family: inherit;
}
.btn.btn-secondary { background: transparent; color: var(--unthink-muted); }

.section-title { padding: 14px 16px 6px; font-weight: 700; font-size: 14px; }
.list-item { padding: 10px 16px; border-bottom: 1px solid var(--unthink-border); font-size: 14px; }

.hashtag-chip { color: var(--unthink-primary); font-weight: 500; }
.mention-chip { color: var(--unthink-primary); font-weight: 500; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.attachment-image { display: block; max-width: 100%; }
.attachment-image img { max-width: 100%; max-height: 320px; border-radius: 8px; display: block; }
.attachment-file { display: inline-block; padding: 6px 10px; background: var(--unthink-soft); border-radius: 8px; font-size: 13px; }
.compose-attach-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.compose-attach-preview img { max-width: 80px; max-height: 80px; border-radius: 6px; }
.compose-attach-preview .pending { font-size: 12px; color: var(--unthink-muted); }

.search-bar {
  position: sticky; top: 52px; z-index: 10; background: var(--unthink-bg);
  padding: 10px 16px;
}
@media (min-width: 768px) {
  /* PC: search-bar の sticky を解除 */
  body.is-app-page .search-bar { position: static !important; top: auto !important; }
}
.search-input-wrap { position: relative; }
.search-input-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--unthink-muted); pointer-events: none;
}
.search-bar input {
  width: 100%; padding: 10px 14px 10px 36px; border: 1px solid var(--unthink-border);
  border-radius: 20px; font-size: 14px; background: var(--unthink-soft); color: var(--unthink-fg);
  outline: none;
}

a.notification-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; border-bottom: 1px solid var(--unthink-border);
  color: inherit; text-decoration: none;
}
a.notification-item:hover { background: var(--unthink-border); }
.notification-item.unread { background: var(--unthink-soft); }
.notification-item .dot { width: 8px; height: 8px; background: var(--unthink-primary); border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.notification-item .notif-icon { color: var(--unthink-muted); display: inline-flex; margin-top: 2px; }
.notification-item .body { font-size: 13px; line-height: 1.5; flex: 1; }
.notification-item .notif-head { font-size: 13px; }
.notification-item .notif-team {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--unthink-muted); margin-top: 2px;
}
.notification-item .notif-team .ut-icon { color: var(--unthink-muted); }
.notification-item .notif-snippet {
  font-size: 12px; color: var(--unthink-sub);
  margin-top: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.notification-item .time { font-size: 11px; color: var(--unthink-muted); display: block; margin-top: 4px; }

/* おすすめタブの投稿プロンプト（隠れメニュー） */
.prompt-drawer {
  border-bottom: 1px solid var(--unthink-border);
  background: var(--unthink-bg);
}
.prompt-drawer .prompt-toggle {
  display: flex; align-items: center; gap: 6px;
  width: 100%; padding: 10px 16px;
  background: transparent; border: none; cursor: pointer;
  font-size: 13px; color: var(--unthink-sub);
  text-align: left;
}
.prompt-drawer .prompt-toggle:hover { background: var(--unthink-soft); }
.prompt-drawer .prompt-toggle-chevron {
  margin-left: auto;
  transition: transform .18s ease;
  display: inline-flex; align-items: center;
}
.prompt-drawer.open .prompt-toggle-chevron { transform: rotate(90deg); }
.prompt-drawer .prompt-list {
  display: none;
  flex-wrap: wrap; gap: 6px;
  padding: 0 16px 12px;
}
.prompt-drawer.open .prompt-list { display: flex; }
.prompt-drawer .prompt-chip {
  font-size: 12px; padding: 6px 12px;
  border: 1px solid var(--unthink-border);
  border-radius: 16px;
  background: var(--unthink-bg);
  color: var(--unthink-fg);
  cursor: pointer;
}
.prompt-drawer .prompt-chip:hover {
  background: var(--unthink-soft);
  border-color: var(--unthink-fg);
}
.prompt-drawer .prompt-chip:disabled {
  opacity: 0.5;
  cursor: progress;
}
.prompt-drawer .prompt-chip.loading {
  background: var(--unthink-soft);
}

/* グローバル投稿モーダル */
.compose-modal { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; justify-content: flex-end; }
.compose-modal[hidden] { display: none; }
.compose-modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.4);
}
.compose-modal-sheet {
  position: relative; z-index: 1;
  width: 100%; margin: 0;
  background: var(--unthink-bg);
  border-radius: 16px 16px 0 0;
  padding: 0 0 20px;
  display: flex; flex-direction: column;
  max-height: 70vh;
  animation: compose-slide-up 0.2s ease-out;
}
@keyframes compose-slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.compose-modal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
}
.compose-modal-title {
  flex: 1; font-size: 15px; font-weight: 700;
}
.compose-modal-context {
  padding: 0 16px 6px; font-size: 12px; color: var(--unthink-muted);
  display: flex; align-items: center; gap: 6px;
}
.compose-modal-context:empty { display: none; }
.compose-modal-context .ctx-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 12px;
  background: var(--unthink-border); font-size: 11px; font-weight: 600;
  color: var(--unthink-fg);
}
.compose-modal-body {
  flex: 1; min-height: 100px; max-height: 40vh;
  border: none; outline: none; resize: none;
  font-family: inherit; font-size: 15px; line-height: 1.6;
  padding: 8px 16px;
  background: transparent; color: var(--unthink-fg);
}
.compose-modal-preview {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px;
}
.compose-modal-preview:empty { display: none; }
.compose-modal-preview img { max-width: 60px; max-height: 60px; border-radius: 6px; }
.compose-modal-preview .pending { font-size: 11px; color: var(--unthink-muted); }
.compose-modal-toolbar {
  padding: 6px 10px 0; display: flex; align-items: center;
}
.compose-modal-footer {
  padding: 10px 16px 0;
}
.compose-modal-footer[hidden] { display: none; }
.compose-modal-team-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--unthink-muted);
  font-size: 13px;
  text-decoration: none;
  padding: 4px 0;
}
.compose-modal-team-link:hover { color: var(--unthink-fg); }
.compose-modal-team-link.is-pill {
  padding: 8px 24px;
  border: 1.5px solid var(--unthink-muted);
  border-radius: 22px;
  background: var(--unthink-bg);
  color: var(--unthink-fg);
  font-size: 13px;
  transition: background 0.15s, border-color 0.15s;
}
.compose-modal-team-link.is-pill:hover { border-color: var(--unthink-fg); }
.compose-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

/* PC: 投稿モーダルを中央配置の通常ポップアップに（ベース定義の後に置いて source-order で勝たせる） */
@media (min-width: 768px) {
  .compose-modal {
    justify-content: center;
    align-items: center;
  }
  .compose-modal-sheet {
    max-width: 600px;
    width: 92vw;
    margin: 0;
    border-radius: 16px;
    max-height: 80vh;
    animation: compose-fade-in 0.18s ease-out;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  }
}
@keyframes compose-fade-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

/* スピナー */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--unthink-border);
  border-top-color: var(--unthink-fg);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
.spinner.large { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.global-loading {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
}
.global-loading[hidden] { display: none; }
.global-loading-content {
  background: var(--unthink-bg);
  padding: 24px 32px;
  border-radius: 16px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.2);
  flex-wrap: wrap; justify-content: center;
  max-width: calc(100% - 32px);
}
.global-loading-text {
  font-size: 14px; color: var(--unthink-fg); font-weight: 500;
}
.global-loading-cancel {
  background: transparent; border: 1px solid var(--unthink-border);
  color: var(--unthink-muted); padding: 4px 12px; border-radius: 999px;
  font-size: 12px; cursor: pointer;
}
.global-loading-cancel[hidden] { display: none; }
.global-loading-cancel:hover { color: var(--unthink-fg); border-color: var(--unthink-fg); }

.empty { padding: 40px 20px; text-align: center; color: var(--unthink-muted); font-size: 13px; }

/* メニューページ */
.menu-list { padding: 8px 0; }
.menu-list a {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--unthink-border);
  font-size: 14px; color: var(--unthink-fg);
}
.menu-list a .label { display: flex; align-items: center; gap: 12px; }
.menu-list a .chevron { color: var(--unthink-muted); display: inline-flex; }

/* ページタイトル左の戻るボタン (共通スタイル) */
.single-feed-back {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--unthink-fg);
  width: 32px; height: 32px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex-shrink: 0;
}
.single-feed-back svg { display: block; }
.single-feed-back:hover { background: var(--unthink-soft); }

/* ==============================================================
 * PC: 横幅 1280px 以下はサイドバーをアイコン幅に圧縮
 * 他の app/home 用 grid-template-columns 上書きの後で勝たせるため
 * app.css の末尾に配置(カスケード優先)
 * ============================================================== */
@media (min-width: 768px) and (max-width: 1280px) {
  body.is-home-page .unthink-desktop-layout,
  body.is-app-page  .unthink-desktop-layout {
    grid-template-columns: 60px minmax(0, 1fr) !important;
  }
  .desktop-sidebar-left { padding: 16px 8px 16px 16px !important; }
  /* ロゴ → 「U」一文字に置換 */
  .sidebar-brand {
    margin-bottom: 14px !important;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    color: var(--unthink-fg);
    font-weight: 800;
    font-size: 18px;
    margin-left: auto;
    margin-right: auto;
    position: relative;
  }
  .sidebar-brand .unthink-logo { display: none !important; }
  .sidebar-brand::before { content: 'U'; }
  .sidebar-nav-item {
    justify-content: center !important;
    padding: 8px 4px !important;
    gap: 0 !important;
  }
  .sidebar-nav-item > span { display: none !important; }
  .sidebar-compose-btn { width: 36px !important; height: 36px !important; margin-top: 10px !important; }
  .sidebar-user { left: 4px !important; right: 4px !important; justify-content: center !important; padding: 6px 0 !important; }
  .sidebar-user-name { display: none !important; }
  .sidebar-admin-toggle { left: 4px !important; right: 4px !important; padding: 6px 0 !important; }
  .sidebar-admin-toggle .admin-switch-label { display: none !important; }
}
