:root { color-scheme: light dark; }

[data-theme="dark"] {
  --bg-primary:   #313338;
  --bg-secondary: #2b2d31;
  --bg-tertiary:  #1e1f22;
  --bg-hover:     #35373c;
  --bg-active:    #404249;
  --text-primary: #dbdee1;
  --text-muted:   #949ba4;
  --text-bright:  #ffffff;
  --accent:       #5865f2;
  --accent-hover: #4752c4;
  --border:       #1e1f22;
  --pill-bg:      #2b2d31;
  --input-bg:     #383a40;
  --error:        #f23f42;
  --shadow:       0 8px 24px rgba(0,0,0,0.3);
}

[data-theme="light"] {
  --bg-primary:   #ffffff;
  --bg-secondary: #f2f3f5;
  --bg-tertiary:  #e3e5e8;
  --bg-hover:     #ebedef;
  --bg-active:    #d7d9db;
  --text-primary: #2e3338;
  --text-muted:   #6d6f78;
  --text-bright:  #060607;
  --accent:       #5865f2;
  --accent-hover: #4752c4;
  --border:       #e3e5e8;
  --pill-bg:      #e3e5e8;
  --input-bg:     #ebedef;
  --error:        #d92626;
  --shadow:       0 4px 12px rgba(0,0,0,0.1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; height: var(--app-height, 100dvh); position: fixed; top: 0; left: 0; width: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button, input, textarea { font-family: inherit; }

/* ---------- Auth screens ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  padding: 20px;
}
.auth-card {
  background: var(--bg-primary);
  padding: 32px;
  border-radius: 8px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.auth-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-bright);
  text-align: center;
}
.auth-subtitle {
  margin: 0 0 24px;
  color: var(--text-muted);
  text-align: center;
  font-size: 14px;
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field > span {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.auth-field input {
  background: var(--input-bg);
  color: var(--text-primary);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 15px;
  transition: border-color 0.15s;
}
.auth-field input:focus { outline: none; border-color: var(--accent); }
.auth-error { color: var(--error); font-size: 13px; min-height: 18px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 4px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-link {
  background: transparent;
  color: var(--text-muted);
}
.btn-link:hover { color: var(--text-bright); text-decoration: underline; }
.icon-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 16px;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-bright); }

/* ---------- Main app layout ---------- */
#app { display: flex; height: var(--app-height, 100dvh); overflow: hidden; }
#sidebar {
  width: 240px;
  min-width: 180px;
  max-width: 420px;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}
.sidebar-header h2 {
  margin: 0;
  font-size: 16px;
  color: var(--text-bright);
  font-weight: 700;
}

.channel-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.category { padding: 16px 8px 4px 16px; }
.category-name {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.channel-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  margin: 1px 8px;
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: background 0.1s, color 0.1s;
}
.channel-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.channel-item.active { background: var(--bg-active); color: var(--text-bright); }
.channel-item .ch-hash { font-weight: 700; opacity: 0.7; }

.user-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg-tertiary);
  min-height: 52px;
}
.user-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-bright);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Avatar ---------- */
.avatar, .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  user-select: none;
  background: #888;
}

/* ---------- Resize handle ---------- */
.resize-handle {
  width: 4px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  transition: background 0.15s;
}
.resize-handle:hover { background: var(--accent); }

/* ---------- Main area ---------- */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-primary);
}
.channel-header {
  height: 48px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  flex-shrink: 0;
}
.channel-hash { color: var(--text-muted); font-size: 20px; font-weight: 700; }
.channel-name { color: var(--text-bright); font-weight: 700; }
.channel-description {
  color: var(--text-muted);
  font-size: 13px;
  border-left: 1px solid var(--border);
  padding-left: 8px;
  margin-left: 8px;
}

/* ---------- Messages ---------- */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
}
.message {
  display: flex;
  gap: 12px;
  padding: 4px 8px;
  margin: 2px 0;
  border-radius: 4px;
}
.message:hover { background: var(--bg-hover); }
.message .message-body { min-width: 0; flex: 1; }
.message-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.message-author { font-weight: 500; color: var(--text-bright); }
.message-time { font-size: 12px; color: var(--text-muted); }
.message-edited { font-size: 11px; color: var(--text-muted); margin-left: 4px; }
.message-content {
  color: var(--text-primary);
  word-wrap: break-word;
  white-space: pre-wrap;
  min-height: 22px;
  padding: 4px 8px;
  margin: -4px -8px;
}
.message-content.clickable { cursor: pointer; }
.message:hover .message-content.clickable { color: var(--text-bright); }

.date-pill {
  align-self: center;
  margin: 16px 0 8px;
  padding: 2px 12px;
  background: var(--pill-bg);
  color: var(--text-muted);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
}

/* ---------- Message input ---------- */
.message-input-wrap {
  display: flex;
  gap: 8px;
  padding: 12px 16px 20px;
  background: var(--bg-primary);
  align-items: flex-end;
}
#message-input {
  flex: 1;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: none;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
  resize: none;
  min-height: 44px;
  max-height: 200px;
  line-height: 1.5;
}
#message-input:focus { outline: none; }
#send-btn { min-height: 44px; }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-active); }

/* ==========================================================
   Step B additions: reactions / threads / context menu /
   mention autocomplete / unread
   ========================================================== */

/* ---------- Unread badge (sidebar) ---------- */
.channel-item.unread .ch-name { color: var(--text-bright); font-weight: 700; }
.unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}

/* ---------- Unread separator (spec-matched) ---------- */
.unread-separator {
  border-top: 2px solid #EF4444;
  margin: 12px 0;
  position: relative;
  text-align: center;
  height: 0;
}
.unread-separator::before {
  content: "ここから未読";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-primary);
  color: #EF4444;
  padding: 0 12px;
  font-size: 12px;
  font-weight: bold;
}
/* Unread message styling */
.message.unread {
  font-weight: 600;
  border-left: 3px solid var(--accent);
  padding-left: 8px;
}

/* ---------- Message action bar (hover) ---------- */
.message { position: relative; }
.action-bar {
  position: absolute;
  top: -12px;
  right: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: none;
  padding: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 3;
}
.message:hover .action-bar { display: flex; }
.action-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  font-size: 16px;
  border-radius: 4px;
  line-height: 1;
}
.action-btn:hover { background: var(--bg-hover); }

/* ---------- Reactions ---------- */
.reactions-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.reactions-strip:empty { display: none; }
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.reaction-pill:hover { background: var(--bg-hover); }
.reaction-pill.mine {
  background: rgba(88,101,242,0.15);
  border-color: var(--accent);
  color: var(--text-bright);
}

/* ---------- Emoji picker ---------- */
.emoji-picker {
  position: fixed;
  z-index: 1000;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  width: 300px;
  max-height: 360px;
  overflow-y: auto;
}
.emoji-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  padding: 8px 4px 4px;
}
.emoji-section-title:first-child { padding-top: 2px; }
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.emoji-item {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  font-size: 20px;
  border-radius: 4px;
  line-height: 1;
  aspect-ratio: 1 / 1;
}
.emoji-item:hover { background: var(--bg-hover); }

/* ---------- Reply link ---------- */
.reply-link {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 10px;
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
}
.reply-link:hover { background: var(--bg-hover); text-decoration: underline; }

/* ---------- Thread panel ---------- */
#app.has-thread, body.thread-open #app { /* allows room for panel */ }
/* 返信（スレッド）表示中は中央のメイン列を隠す (院長指示 2026-05-30) */
body.thread-open #main { display: none !important; }
body.thread-open #resize-handle { display: none !important; }
/* デスクトップのみ: メインを消した分スレッドを広げる。
   モバイル(<=768px)はスレッドが position:absolute の全画面オーバーレイなので幅は触らない */
@media (min-width: 769px) {
  body.thread-open #thread-panel,
  body.thread-open .thread-panel { flex: 1 1 auto !important; width: auto !important; }
}
.thread-panel {
  width: 420px;
  flex-shrink: 0;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: var(--app-height, 100dvh);
}
.thread-header {
  height: 48px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
  flex-shrink: 0;
}
.thread-header-text { flex: 1; min-width: 0; }
.thread-title { font-weight: 700; color: var(--text-bright); font-size: 15px; line-height: 1.2; }
.thread-subtitle { color: var(--text-muted); font-size: 12px; line-height: 1.2; margin-top: 2px; }
.thread-close { margin-left: auto; flex-shrink: 0; }
.thread-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.thread-parent {
  padding: 8px 12px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.thread-replies { padding: 0 4px; }

/* "N件の返信" divider — line — label — line */
.thread-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
}
.thread-divider-line { flex: 1; height: 1px; background: var(--border); }
.thread-divider-label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.thread-input-wrap {
  flex-shrink: 0;
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-primary);
  align-items: flex-end;
}
.thread-input {
  flex: 1;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  min-height: 40px;
  max-height: 160px;
  line-height: 1.5;
}
.thread-input:focus { outline: none; }

/* ---------- Slack-style context menu ---------- */
.slack-menu {
  position: fixed;
  z-index: 1000;
  width: 360px;
  max-width: calc(100vw - 16px);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
[data-theme="light"] .slack-menu { background: #fff; }

.slack-divider {
  height: 1px; background: var(--border);
  margin: 6px 4px;
}

/* Tier 1: emoji quick actions */
.slack-emoji-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}
.slack-emoji-btn {
  width: 100%; aspect-ratio: 1 / 1;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.1s, border-color 0.1s;
}
.slack-emoji-btn:hover { background: var(--bg-hover); }
.slack-emoji-more {
  background: var(--bg-primary);
  border-color: var(--border);
  font-size: 18px;
}
[data-theme="light"] .slack-emoji-more { background: #fff; }

/* Tier 2: primary action cards */
.slack-cards-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.slack-card {
  height: 72px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 4px;
  font-family: inherit;
  transition: background 0.1s, border-color 0.1s;
}
[data-theme="light"] .slack-card { background: #fff; }
.slack-card:hover { background: var(--bg-hover); border-color: var(--accent); }
.slack-card-icon { font-size: 22px; line-height: 1; }
.slack-card-label { font-size: 12px; font-weight: 500; color: var(--text-primary); }

/* Tier 3: vertical menu items */
.slack-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  width: 100%;
  padding: 0 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  text-align: left;
  transition: background 0.1s;
}
.slack-item:hover { background: var(--bg-hover); }
.slack-item-icon  { font-size: 20px; width: 24px; text-align: center; flex-shrink: 0; }
.slack-item-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slack-item-arrow { color: var(--text-muted); font-size: 12px; }
.slack-item.danger { color: #EF4444; background: rgba(239,68,68,0.08); }
.slack-item.danger:hover { background: rgba(239,68,68,0.18); }
.slack-item.danger .slack-item-icon { color: #EF4444; }

/* Reminder submenu */
.slack-submenu {
  position: fixed;
  z-index: 1001;
  min-width: 200px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
[data-theme="light"] .slack-submenu { background: #fff; }

.slack-item-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.slack-item-disabled:hover { background: transparent; }

/* AI loading spinner */
.ai-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ai-spin 0.9s linear infinite;
  margin: 0 auto;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 8px;
  color: var(--text-primary);
}
.ai-loading-label { font-size: 14px; color: var(--text-muted); }

/* CO-AI thinking banner (bottom of messages / thread panel) */
.ai-thinking-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text-muted);
  align-self: flex-start;
  max-width: fit-content;
}
.ai-thinking-banner .ai-spinner {
  width: 16px;
  height: 16px;
  border-width: 2px;
  margin: 0;
}

.task-ai-list { max-height: 60vh; overflow-y: auto; }
.task-ai-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--bg-tertiary);
}
.task-ai-check { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
.task-ai-row-inline { display: flex; gap: 12px; }
.task-ai-row-inline > div { flex: 1; }
.task-ai-assignee { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.summary-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.summary-tab {
  flex: 1;
  padding: 6px 8px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.summary-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.summary-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.summary-output {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 12px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0;
}

.reminder-due-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.reminder-due-row input[type="date"],
.reminder-due-row select {
  flex: 1;
  min-width: 0;
}
/* Force native calendar picker indicator to be visible on dark theme */
.reminder-date-input::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
  opacity: 1;
}
[data-theme="light"] .reminder-date-input::-webkit-calendar-picker-indicator {
  filter: none;
}

/* forward modal selected state */
.user-picker-item.selected { background: var(--accent); color: #fff; }
.user-picker-item.selected .up-display { color: #fff; }

@media (max-width: 480px) {
  .slack-menu { width: calc(100vw - 16px); }
}

/* ---------- Inline edit ---------- */
.edit-textarea {
  width: 100%;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: inherit;
  font-size: 15px;
  resize: vertical;
  min-height: 36px;
  line-height: 1.5;
}
.edit-textarea:focus { outline: none; border-color: var(--accent); }
.edit-hint { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Mention autocomplete ---------- */
.mention-picker {
  position: fixed;
  z-index: 1000;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.3);
  max-height: 300px;
  overflow-y: auto;
}
.mention-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
}
.mention-item.selected,
.mention-item:hover {
  background: var(--accent);
  color: #fff;
}
.mention-item.selected .mention-name,
.mention-item:hover .mention-name { color: rgba(255,255,255,0.75); }
.mention-avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 11px;
  flex-shrink: 0; background: #888;
}
.mention-display { font-weight: 500; }
.mention-name { color: var(--text-muted); font-size: 13px; }

/* ==========================================================
   Step C additions: search / bookmarks panels, attachments,
   theme toggle, jump highlight
   ========================================================== */

/* ---------- Channel header actions ---------- */
.channel-header-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

/* ---------- Right side panel (search / bookmarks / thread share style) ---------- */
.side-panel {
  width: 420px;
  flex-shrink: 0;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: var(--app-height, 100dvh);
}
.side-panel-header {
  height: 48px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(0,0,0,0.2);
}
.side-panel-title { font-weight: 700; color: var(--text-bright); flex: 1; }
.side-panel-body { flex: 1; overflow-y: auto; padding: 8px 12px; }

/* ---------- Search panel ---------- */
.search-input {
  width: 100%;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 8px 0 12px;
  font-size: 14px;
  font-family: inherit;
}
.search-input:focus { outline: none; border-color: var(--accent); }
.search-result {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: background 0.1s;
}
.search-result:hover { background: var(--bg-hover); }
.search-result-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.search-result-channel { color: var(--accent); font-weight: 700; }
.search-result-author { color: var(--text-bright); margin-left: 6px; font-weight: 500; }
.search-result-content {
  color: var(--text-primary);
  font-size: 14px;
  white-space: pre-wrap;
  word-wrap: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.empty-state {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ---------- Bookmark panel ---------- */
.bookmark-item {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: background 0.1s;
}
.bookmark-item:hover { background: var(--bg-hover); }

/* ---------- Jump highlight (search/bookmark click) ---------- */
.message.jump-highlight { animation: jumpHighlight 2s ease-out; }
@keyframes jumpHighlight {
  0%   { background: rgba(255, 235, 59, 0.55); }
  100% { background: transparent; }
}

/* ---------- Attachments ---------- */
.icon-btn-large { padding: 8px 10px; font-size: 20px; }
.input-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.input-stack #message-input { width: 100%; min-height: 44px; }
.message-input-wrap.drag-over,
.thread-input-wrap.drag-over {
  background: rgba(88, 101, 242, 0.1);
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
}
.pending-attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary);
}
.pending-attachment.uploading { opacity: 0.6; }
.pending-attachment .pa-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-attachment .pa-size { color: var(--text-muted); font-size: 12px; }
.pending-attachment .pa-remove {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
}
.pending-attachment .pa-remove:hover { color: var(--error); }

.attachments {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}
/* 2026-05-22 院長指示: 添付写真を小さく表示 */
.attachment-image {
  max-width: 240px;
  max-height: 200px;
  border-radius: 6px;
  display: block;
  cursor: pointer;
  background: var(--bg-tertiary);
}
/* 添付画像の削除ボタン: 写真枠内の右上隅に絶対配置（左のアバターと重ならない） */
/* 2026-05-22 院長指示: 削除ボタンは写真に重ねず手前に独立配置（タップ拡大と衝突回避） */
.attachment-delete-btn {
  align-self: flex-start;
  padding: 4px 10px;
  border: 1px solid var(--border, #d8dee4);
  border-radius: 6px;
  background: var(--bg-tertiary, #f0f0f0);
  color: var(--text-primary, #333);
  font-size: 12px;
  line-height: 1.4;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.attachment-delete-btn:hover {
  background: rgba(200, 0, 0, 0.9);
  color: #fff;
  border-color: rgba(200, 0, 0, 0.9);
}
/* 写真のみのメッセージは本文枠を潰す（空の灰色帯を出さない） */
.message-content.message-content-empty {
  min-height: 0;
  padding: 0;
  margin: 0;
}
/* 2026-05-22: 写真タップで全画面ライトボックス拡大（Slack 方式） */
.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: zoom-out;
}
.image-lightbox-img {
  max-width: 96vw;
  max-height: 96vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}
.attachment-file {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border-radius: 6px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  max-width: 360px;
}
.attachment-file:hover { background: var(--bg-hover); color: var(--text-bright); }
.attachment-file .af-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.attachment-file .af-size { color: var(--text-muted); font-size: 12px; }

/* ==========================================================
   Phase 5 polish: toast, loading bar, login, responsive
   ========================================================== */

/* ---------- Toast notifications (bottom-right) ---------- */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: 380px;
  padding: 10px 14px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-left-color: var(--error); }
.toast-info  { border-left-color: var(--accent); }

/* ---------- Top loading bar (院長指示 2026-05-23: 非表示) ---------- */
.loading-bar,
.loading-bar.active { display: none !important; }

/* ---------- Login screen polish ---------- */
.auth-screen {
  background:
    radial-gradient(circle at 20% 20%, rgba(88,101,242,0.20), transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(88,101,242,0.10), transparent 60%),
    var(--bg-tertiary);
}
.auth-card {
  border: 1px solid var(--border);
}
.auth-title {
  font-size: 28px;
  letter-spacing: 0.02em;
  background: linear-gradient(135deg, var(--accent), #8a93f8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* ---------- Responsive: tablet ≤1024px ---------- */
@media (max-width: 1024px) {
  #sidebar { width: 200px; }
  .thread-panel, .side-panel { width: 360px; }
  .attachment-image { max-width: 240px; max-height: 200px; }
}

/* ---------- Responsive: mobile ≤768px ---------- */
@media (max-width: 768px) {
  body { font-size: 14px; }
  /* 2026-05-03 院長指示: 狭いウィンドウでもサイドバー常時表示 (元: 画面外に隠し sidebar-open で戻す) */
  #sidebar {
    width: 200px;
    flex-shrink: 0;
  }
  .resize-handle { display: none; }
  #main { width: 100%; }
  .thread-panel, .side-panel {
    position: absolute;
    right: 0; top: 0;
    height: 100%;
    width: 100%;
    z-index: 60;
  }
  .messages, .thread-body, .side-panel-body { padding: 8px; }
  .message-input-wrap, .thread-input-wrap { padding: 8px; padding-bottom: 12px; }
  .attachment-image { max-width: 240px; max-height: 200px; }
  .toast { min-width: 200px; max-width: calc(100vw - 32px); }
  .channel-header { padding: 0 8px; }
  .channel-description { display: none; }
  /* hamburger reveal: tap channel header hash to show sidebar */
  .channel-hash { cursor: pointer; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.05ms !important;
  }
}

/* ==========================================================
   Phase 6: DM / Reminders / Manuals / Projects
   ========================================================== */

.sidebar-section {
  border-top: 1px solid var(--border);
  padding: 4px 0;
}
.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}
.sidebar-section-header .icon-btn { font-size: 14px; padding: 2px 6px; }
.sidebar-list { display: flex; flex-direction: column; padding: 2px 0; }

.dm-item { gap: 8px; }
.dm-avatar {
  width: 20px; height: 20px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 10px;
  flex-shrink: 0;
  background: #888;
}
.project-item .ch-hash { opacity: 0.6; }

/* ---------- Reminder colors: sidebar-reminder.css に移動 (data-progress 方式) ---------- */
#reminder-overdue-badge {
  display: inline-block;
  color: var(--error);
  font-weight: 700;
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 2500;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: 8px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
}
.modal-title { padding: 16px 20px; font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--border); }
.modal-body  { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-buttons {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
}
.modal-label {
  display: block;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-muted); margin: 10px 0 4px;
}
.modal-body > textarea.search-input,
.modal-body > input.search-input,
.modal-body > select.search-input { margin: 0 0 4px; }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.form-row { display: flex; gap: 12px; }
.form-col { flex: 1; min-width: 0; }
.detail-row { padding: 6px 0; }
.detail-title { font-size: 18px; font-weight: 700; color: var(--text-bright); }
.detail-meta  { color: var(--text-muted); font-size: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.detail-pre   {
  background: var(--bg-tertiary);
  padding: 12px;
  border-radius: 6px;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: inherit;
  margin: 0;
  max-height: 50vh;
  overflow: auto;
}

/* ---------- User picker (DM / add member) ---------- */
.user-picker { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.user-picker-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.user-picker-item:hover { background: var(--bg-hover); }
.up-text { flex: 1; min-width: 0; }
.up-display { font-weight: 500; color: var(--text-bright); }
.up-name    { font-size: 12px; color: var(--text-muted); }

/* ---------- Overlay view (manuals / project detail) ---------- */
.overlay-view {
  position: fixed; inset: 0;
  background: var(--bg-primary);
  z-index: 1500;
  overflow: auto;
}
.overlay-view.hidden { display: none; }
.overlay-content {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.overlay-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--bg-secondary);
}
.overlay-title { flex: 1; font-size: 17px; font-weight: 700; color: var(--text-bright); }
.overlay-body  { padding: 16px; flex: 1; }

/* ---------- Manuals ---------- */
.manual-cat-title {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; color: var(--text-muted);
  padding: 16px 4px 6px; border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.manual-row {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  background: var(--bg-secondary);
  margin-bottom: 6px;
}
.manual-row:hover { background: var(--bg-hover); }
.manual-title { font-weight: 700; color: var(--text-bright); }
.manual-excerpt { color: var(--text-muted); font-size: 13px; margin: 4px 0; white-space: pre-wrap; }
.manual-meta { color: var(--text-muted); font-size: 11px; }

/* ---------- Project detail ---------- */
.project-desc { padding: 0 16px 10px; color: var(--text-muted); }
.project-members {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.pm-label { color: var(--text-muted); font-size: 12px; }
.pm-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; background: var(--bg-secondary); border-radius: 12px; font-size: 13px;
}
.pm-role { color: var(--text-muted); font-size: 11px; }

/* ---------- Kanban ---------- */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}
.kanban-col {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 10px;
  min-height: 200px;
}
.kanban-col-title {
  font-weight: 700;
  color: var(--text-bright);
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.task-card {
  background: var(--bg-primary);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background 0.1s;
}
.task-card:hover { background: var(--bg-hover); }
.task-title { font-weight: 500; color: var(--text-bright); margin-bottom: 4px; }
.task-assignee, .task-due { color: var(--text-muted); font-size: 12px; }

@media (max-width: 768px) {
  .kanban { grid-template-columns: 1fr; }
  .modal { max-width: 100%; max-height: 95vh; }
}

/* theme-toggle の focus 枠を消す (院長指示 2026-05-08, 単独再適用) */
#theme-toggle,
#theme-toggle:focus,
#theme-toggle:focus-visible,
#theme-toggle:active {
  outline: none !important;
  box-shadow: none !important;
  border: 0 !important;
}

/* sidebar-section-header 左寄せ (マニュアル位置のみ修正、ロールバックで再発したため再適用) — 2026-05-08 */
.sidebar-section-header { justify-content: flex-start !important; }

/* sidebar 全体スクロール (channel-list はノータッチで安全に) — 2026-05-08 */
#sidebar { overflow-y: auto !important; }

/* ============================================================
   ピン留めバー / メニュー / アイコンバー絵文字 (2026-05-12)
   ============================================================ */
.pinned-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 14px;
  background: var(--bg-secondary, #fafafa);
  border-bottom: 1px solid var(--border, #e3e4e8);
  align-items: center;
}
.pinned-bar[hidden] { display: none; }
.pinned-bar-header {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary, #555);
  margin-right: 8px;
  white-space: nowrap;
}
.pinned-bar-icon { font-size: 14px; }
.pinned-bar-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}
.pin-chip {
  display: inline-flex;
  align-items: stretch;
  background: var(--bg, #fff);
  border: 1px solid var(--border, #d1d5db);
  border-radius: 14px;
  overflow: hidden;
  font-size: 12px;
  max-width: 340px;
}
.pin-chip-body {
  background: transparent;
  border: 0;
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  color: var(--text, #111);
  max-width: 300px;
}
.pin-chip-body:hover { background: rgba(0,0,0,0.04); }
.pin-chip-author { font-weight: 700; flex-shrink: 0; }
.pin-chip-snippet {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pin-chip-unpin {
  background: transparent;
  border: 0;
  border-left: 1px solid var(--border, #d1d5db);
  padding: 0 8px;
  cursor: pointer;
  color: var(--text-secondary, #666);
  font-size: 12px;
}
.pin-chip-unpin:hover { color: #e53935; background: rgba(229,57,53,0.08); }
.message.pin-flash {
  background: rgba(255, 235, 130, 0.45) !important;
  transition: background 0.6s ease;
}

/* チャンネル内チェックリスト ウィジェット */
.message-content.checklist-widget {
  cursor: default;
  background: var(--bg-secondary, #f6f8fa);
  border: 1px solid var(--border, #d8dee4);
  border-radius: 8px;
  padding: 8px 10px;
  display: inline-block;
  min-width: 240px;
  max-width: 440px;
}
.checklist-widget .cl-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border, #e1e4e8);
}
.checklist-widget .cl-count { font-size: 12px; color: var(--text-secondary, #57606a); font-weight: 600; }
.checklist-widget .cl-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 2px;
  cursor: pointer;
  border-radius: 4px;
}
.checklist-widget .cl-item:hover { background: rgba(0,0,0,0.05); }
.checklist-widget .cl-box { font-size: 16px; line-height: 1.45; flex-shrink: 0; }
.checklist-widget .cl-item.done .cl-label { text-decoration: line-through; color: var(--text-secondary, #8b949e); }
.checklist-widget .cl-by { font-size: 11px; color: var(--text-secondary, #6b7280); white-space: nowrap; margin-left: auto; padding-left: 6px; }
.checklist-widget .cl-loading, .checklist-widget .cl-error { font-size: 13px; color: var(--text-secondary, #57606a); }
.checklist-widget .cl-error { color: #cf222e; }

/* v2-icon-bar の絵文字バッジ (ホーム/後で の視認性向上 2026-05-12) */
.v2-icon-bar .iconbar-emoji {
  display: inline-block;
  font-size: 16px;
  line-height: 1;
  margin-right: 0;
  margin-bottom: 2px;
}

/* ============================================================
   📌 ピン留め一覧オーバーレイ (サイドバーから開く、2026-05-12 v2)
   ============================================================ */
.v2-pinned-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 4000;
  align-items: flex-start;
  justify-content: center;
  padding: 80px 16px 16px;
}
.v2-pinned-overlay[data-open="1"] { display: flex; }
.v2-pinned-card {
  background: var(--bg, #fff);
  color: var(--text, #111);
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  width: min(560px, 100%);
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.v2-pinned-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #e3e4e8);
  background: var(--bg-secondary, #fafafa);
}
.v2-pinned-head strong { font-size: 15px; }
.v2-pinned-ch { color: var(--text-secondary, #555); font-size: 13px; }
.v2-pinned-close {
  margin-left: auto;
  background: transparent;
  border: 0;
  font-size: 16px;
  cursor: pointer;
  color: var(--text-secondary, #555);
}
.v2-pinned-close:hover { color: #e53935; }
.v2-pinned-body { padding: 8px 0; overflow-y: auto; }
.v2-pinned-empty { padding: 24px 16px; color: var(--text-secondary, #777); text-align: center; }
.v2-pinned-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border, #eef0f3);
}
.v2-pinned-item:last-child { border-bottom: 0; }
.v2-pinned-item-head { font-size: 12px; color: var(--text-secondary, #555); margin-bottom: 4px; }
.v2-pinned-author { font-weight: 700; color: var(--text, #111); }
.v2-pinned-content {
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-secondary, #fafafa);
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border, #eef0f3);
}
.v2-pinned-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.v2-pinned-jump, .v2-pinned-unpin {
  border: 1px solid var(--border, #d1d5db);
  background: var(--bg, #fff);
  color: var(--text, #111);
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.v2-pinned-jump:hover { background: rgba(0,0,0,0.04); }
.v2-pinned-unpin { color: #e53935; }
.v2-pinned-unpin:hover { background: rgba(229,57,53,0.08); }

/* 📌 ピン留めボタンを v2-icon-bar 内で他ボタンと統一 */
.v2-icon-bar button[data-name="pinned"] .iconbar-emoji {
  display: inline-block;
  font-size: 22px;
  line-height: 1;
}

/* ============================================================
   📌 ピン留めだけ表示モード (v3 - 2026-05-12)
   ============================================================ */
.v2-pin-view-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: #fef9e7;
  border-bottom: 1px solid #f6c343;
  font-size: 13px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.v2-pin-view-back {
  background: #fff;
  border: 1px solid #f6c343;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.v2-pin-view-back:hover { background: #fef3c7; }
.v2-pin-view-count { font-weight: 700; color: #92400e; }
.v2-pin-view-hint { color: #92400e; font-size: 12px; }
.v2-pin-view-confirm { display: inline-flex; gap: 6px; margin-left: auto; }
.v2-pin-view-confirm-go, .v2-pin-view-confirm-cancel {
  border: 1px solid #d1d5db;
  background: #fff;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}
.v2-pin-view-confirm-go { background: #dc2626; color: #fff; border-color: #dc2626; }
.v2-pin-view-confirm-go:hover { background: #b91c1c; }
.v2-pin-view-empty { padding: 32px 16px; color: var(--text-secondary, #777); text-align: center; }

.v2-pin-view-row {
  background: rgba(246, 195, 67, 0.06);
  border-left: 3px solid #f6c343;
}
/* 選択モード時のチェックボックスはアバターの左に並ぶ (flex item) */
.v2-pin-view-row .v2-pin-view-cb {
  width: 20px;
  height: 20px;
  cursor: pointer;
  flex: 0 0 auto;
  align-self: center;
  margin-left: 8px;
  margin-right: 4px;
}
.v2-pin-view-row .v2-pin-view-pinner {
  margin-left: 8px;
  font-size: 11px;
  color: #92400e;
  background: #fef3c7;
  padding: 2px 6px;
  border-radius: 4px;
}

.v2-pin-del-menu {
  position: absolute;
  background: #fff;
  color: #000;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  z-index: 9999;
  min-width: 220px;
  overflow: hidden;
  font-size: 13px;
}
.v2-pin-del-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 13px;
  border-top: 1px solid #e5e7eb;
}
.v2-pin-del-menu button:first-child { border-top: 0; }
.v2-pin-del-menu button:hover { background: #f3f4f6; }
.v2-pin-del-menu .v2-pin-del-all { color: #dc2626; }

/* フローティング選択削除コンファームバー (画面下中央, 2026-05-12 21:08) */
.v2-pin-confirm-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.18);
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  z-index: 5000;
  font-size: 13px;
}
.v2-pin-confirm-count { font-weight: 700; color: #92400e; }

/* 🔍 検索結果ビュー (案B、院長指示 2026-05-12 22:25) */
.v2-search-row {
  background: rgba(91, 110, 230, 0.04);
  border-left: 3px solid #5b6ee6;
}
.v2-search-row .v2-search-where {
  margin-left: 8px;
  font-size: 11px;
  color: #4b5563;
  background: #eef2ff;
  padding: 2px 6px;
  border-radius: 4px;
}
.v2-search-empty {
  padding: 32px 16px;
  color: var(--text-secondary, #777);
  text-align: center;
  font-size: 13px;
}

/* 📅 日付指定削除ダイアログ (院長指示 2026-05-12 22:34) */
.v2-pin-date-dialog {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 6000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.v2-pin-date-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  width: min(440px, 100%);
  overflow: hidden;
  color: #111;
}
.v2-pin-date-head { padding: 12px 16px; border-bottom: 1px solid #e5e7eb; font-weight: 700; }
.v2-pin-date-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.v2-pin-date-body label { display: block; }
.v2-pin-date-body input[type=date], .v2-pin-date-body select {
  display: inline-block; margin-left: 6px;
  border: 1px solid #d1d5db; border-radius: 6px; padding: 4px 8px; font-size: 13px;
}
.v2-pin-date-preview { background: #fef9e7; padding: 8px 10px; border-radius: 6px; color: #92400e; font-size: 12px; }
.v2-pin-date-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid #e5e7eb; }
.v2-pin-date-cancel, .v2-pin-date-go {
  border: 1px solid #d1d5db; background: #fff; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px;
}
.v2-pin-date-go { background: #dc2626; color: #fff; border-color: #dc2626; }
.v2-pin-date-go:hover { background: #b91c1c; }

/* 日付指定削除ダイアログのノート (院長指示 2026-05-12 22:48 シンプル化) */
.v2-pin-date-note { color: #6b7280; font-size: 12px; }

/* メッセージ本文は文字選択可能 (院長指示 2026-05-12 23:02: コピー操作のため明示的に有効化) */
.message-content,
.v2-pin-view-row .message-content,
.v2-search-row .message-content,
.v2-pin-view-row .message-body,
.v2-search-row .message-body {
  user-select: text;
  -webkit-user-select: text;
}

/* 日付指定削除ダイアログ: 対象一覧+チェックボックス (院長指示 2026-05-12 23:11 個別選択可能化) */
.v2-pin-date-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 0; font-size: 12px; color: #6b7280;
}
.v2-pin-date-allchk { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; }
.v2-pin-date-count { color: #92400e; font-weight: 700; }
.v2-pin-date-list {
  max-height: 260px; overflow-y: auto;
  border: 1px solid #e5e7eb; border-radius: 6px;
  background: #fafafa;
}
.v2-pin-date-list:empty { display: none; }
.v2-pin-date-item {
  display: grid;
  grid-template-columns: 22px 90px 110px 1fr;
  gap: 8px; align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid #eef0f3;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.v2-pin-date-item:last-child { border-bottom: 0; }
.v2-pin-date-item:hover { background: rgba(0,0,0,0.03); }
.v2-pin-date-item-cb { width: 16px; height: 16px; cursor: pointer; }
.v2-pin-date-item-date { color: #6b7280; font-variant-numeric: tabular-nums; }
.v2-pin-date-item-author { font-weight: 700; color: #111; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v2-pin-date-item-text {
  color: #111;
  user-select: text;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.v2-pin-date-empty { padding: 16px; text-align: center; color: #9ca3af; font-size: 12px; }

/* 2026-05-15 院長指示: 新規登録画面がmac でスクロール不能だったため。
   :not(.hidden) を付けて hidden state を上書きしないよう修正。 */
.auth-screen:not(.hidden) {
  overflow-y: auto;
  align-items: flex-start;
  padding-top: 40px;
  padding-bottom: 40px;
}

/* ===== 個人用定期チェックリスト pcheck（追加・既存規則は変更なし） ===== */
.pcheck-widget .pcheck-due { margin-left:8px; font-size:12px; color:#666; }
.pcheck-due-danger { color:#d32f2f !important; font-weight:700; }
.pcheck-status { margin:5px 0; display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.pcheck-overdue-badge { background:#d32f2f; color:#fff; font-size:11px; font-weight:700; padding:2px 8px; border-radius:10px; }
.pcheck-done-badge { background:#9e9e9e; color:#fff; font-size:11px; padding:2px 8px; border-radius:10px; }
.pcheck-count { font-size:12px; color:#666; }
.pcheck-close-btn { margin-top:6px; padding:6px 18px; background:#5b6ee1; color:#fff; border:none; border-radius:6px; cursor:pointer; font-weight:700; }
.pcheck-close-btn:disabled { background:#ccc; cursor:not-allowed; }
.pcheck-widget.pcheck-overdue { border:2px solid #d32f2f; border-radius:8px; padding:6px 8px; background:#fff5f5; }


/* ==========================================================================
   2026-06-11 iOSキーボード対策: flex子の min-height:0 不足を補正。
   visualViewport で親(--app-height)を縮めた時、flex子に min-height:auto が
   残ると .messages 等が縮まず composer/input が上へ押し出される問題の修正。
   ========================================================================== */
#main { min-height: 0; }
#sidebar { min-height: 0; }
.messages,
.thread-body,
.side-panel-body,
.channel-list { min-height: 0; }
.message-input-wrap,
.thread-input-wrap { flex-shrink: 0; }
.thread-panel,
.side-panel { min-height: 0; }

.attachment-delete-btn-small { align-self: flex-start; padding: 2px 8px; font-size: 11px; opacity: 0.6; }
.attachment-delete-btn-small:hover { opacity: 1; }

/* 2026-06-11 iOSキーボード対策: キーボード表示中は入力欄が position:fixed で
   フローから抜けるため、メッセージ一覧の下端に入力欄の高さぶん余白を確保する。
   --composer-h は app.js (_updateComposerForKeyboard) が設定。 */
body.kbd-open .messages { padding-bottom: var(--composer-h, 84px); }
