:root {
  --bg: #fafaf7;
  --fg: #222;
  --muted: #777;
  --accent: #2b6cb0;
  --border: #e5e5e0;
  --code-bg: #f1f1ec;
  --surface: #ffffff;
  --hover: #f0eee8;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #1a1a1a;
  --fg: #e4e4e4;
  --muted: #9a9a9a;
  --accent: #6aa9e9;
  --border: #333333;
  --code-bg: #2a2a2a;
  --surface: #242424;
  --hover: #2f2f2f;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    --bg: #1a1a1a;
    --fg: #e4e4e4;
    --muted: #9a9a9a;
    --accent: #6aa9e9;
    --border: #333333;
    --code-bg: #2a2a2a;
    --surface: #242424;
    --hover: #2f2f2f;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    "Yu Gothic", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.75;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.site-header .brand {
  text-decoration: none;
  color: var(--fg);
  font-weight: 600;
  font-size: 1.05em;
}

.menu {
  position: relative;
}
.menu-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  width: 36px;
  height: 36px;
  border-radius: 6px;
  font-size: 1.1em;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s;
}
.menu-toggle:hover { background: var(--hover); }
.menu.is-open .menu-toggle {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  /* 画面が狭くてもパネルが画面外にはみ出さないようにする */
  max-width: calc(100vw - 24px);
  width: max-content;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px 16px;
  z-index: 20;
  box-sizing: border-box;
}

.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 12px -16px;
}
.menu-section-label {
  color: var(--muted);
  font-size: 0.8em;
  margin-bottom: 8px;
  letter-spacing: 0.04em;
}
.theme-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.theme-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95em;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background 0.15s;
}
.theme-options label:hover { background: var(--hover); }
.theme-options input[type="radio"] { accent-color: var(--accent); }
.menu-panel[hidden] { display: none; }

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
}
.menu-item label {
  color: var(--muted);
  font-size: 0.85em;
  white-space: nowrap;
}
.menu-item input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}
.menu-item .fs-value {
  font-variant-numeric: tabular-nums;
  font-size: 0.85em;
  color: var(--muted);
  min-width: 3.5em;
  text-align: right;
}

.markdown-body {
  font-size: var(--md-font-size, 18px);
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

h1 { font-size: 1.6em; margin-top: 0; }

.dir-note {
  color: var(--muted);
  font-size: 0.9em;
}
.dir-note code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
}

.folder-count-inline {
  font-size: 0.78em;
  font-weight: normal;
  color: var(--muted);
  margin-left: 6px;
}
.file-folder {
  display: inline-block;
  font-size: 0.78em;
  color: var(--muted);
  background: var(--code-bg);
  padding: 1px 8px;
  border-radius: 10px;
  margin-right: 8px;
  vertical-align: middle;
  font-weight: normal;
}
.article-folder {
  margin: 0 0 6px;
  font-size: 0.9em;
  color: var(--muted);
}
.article-folder a {
  color: var(--muted);
}

.file-list {
  list-style: none;
  padding: 0;
  margin: 24px 0;
}
.file-list li {
  border-bottom: 1px solid var(--border);
}
.file-list li[hidden] { display: none; }
.file-card-link {
  display: block;
  padding: 14px 8px 6px;
  text-decoration: none;
  color: var(--fg);
  transition: background 0.15s;
}
.file-card-link:hover {
  background: var(--hover);
}
.file-title {
  font-size: 1.05em;
  font-weight: 600;
  color: var(--accent);
}
.file-summary {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9em;
  line-height: 1.5;
}
.file-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 8px 12px;
}
.file-tag {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.78em;
  color: var(--accent);
  background: var(--code-bg);
  border-radius: 10px;
  text-decoration: none;
  cursor: pointer;
}
.file-tag:hover {
  background: var(--accent);
  color: #fff;
}

/* ===== 検索ページ ===== */
.search-page {
  margin-top: 16px;
}
.search-control {
  position: relative;
}
.search-box {
  display: flex;
  gap: 8px;
}
.search-box input[type="search"] {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 1em;
}
.search-box input[type="search"]:focus {
  outline: none;
  border-color: var(--accent);
}
.search-box .btn-secondary {
  padding: 8px 14px;
  font-size: 1em;
  line-height: 1;
}

.active-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.active-tag {
  font-family: inherit;
  font-size: 0.82em;
  padding: 4px 10px;
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.active-tag .x {
  opacity: 0.8;
  font-size: 1em;
}
.active-tag:hover { filter: brightness(1.08); }

/* オートコンプリート */
.suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 5;
  max-height: 280px;
  overflow-y: auto;
}
.suggestions[hidden] { display: none; }
.suggestion {
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.95em;
}
.suggestion:hover,
.suggestion.is-active {
  background: var(--hover);
}
.suggestion-tag {
  color: var(--accent);
}
.suggestion-count {
  font-size: 0.8em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.search-summary {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.85em;
  min-height: 1.3em;
}

/* ===== 記事メタ（個別記事ページ） ===== */
.article-meta {
  margin: 10px 0 24px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}
.article-summary {
  color: var(--muted);
  font-style: italic;
  margin: 0 0 10px;
}
.article-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.empty {
  color: var(--muted);
  padding: 40px 0;
  text-align: center;
}

.back {
  margin-bottom: 20px;
}
.back a {
  color: var(--accent);
  text-decoration: none;
}
.back a:hover { text-decoration: underline; }

/* ===== 同フォルダ内の前後ナビ ===== */
.story-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 40px 0 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.story-nav a,
.story-nav-empty {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--fg);
  background: var(--surface);
  transition: background 0.15s, border-color 0.15s;
  min-height: 56px;
}
.story-nav a:hover {
  background: var(--hover);
  border-color: var(--accent);
}
.story-nav-prev { text-align: left; }
.story-nav-next { text-align: right; }
.story-nav-label {
  font-size: 0.78em;
  color: var(--muted);
}
.story-nav-title {
  font-weight: 600;
  color: var(--accent);
}
.story-nav-empty {
  visibility: hidden;
  background: transparent;
  border-color: transparent;
}
.breadcrumbs {
  font-size: 0.85em;
  color: var(--muted);
  margin: 8px 0 16px;
}
.breadcrumbs a {
  color: var(--muted);
  text-decoration: none;
}
.breadcrumbs a:hover {
  color: var(--accent);
  text-decoration: underline;
}
.breadcrumbs .crumb-current {
  color: var(--fg);
  font-weight: 600;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-top: 1.6em;
}
.markdown-body p { margin: 1em 0; }
.markdown-body code {
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.92em;
}
.markdown-body pre {
  background: var(--code-bg);
  padding: 14px;
  border-radius: 6px;
  overflow-x: auto;
}
.markdown-body pre code {
  background: transparent;
  padding: 0;
}
.markdown-body blockquote {
  border-left: 4px solid var(--border);
  margin: 1em 0;
  padding: 4px 16px;
  color: var(--muted);
}
.markdown-body table {
  border-collapse: collapse;
  margin: 1em 0;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 6px 12px;
}
.markdown-body img { max-width: 100%; }

.site-nav {
  display: flex;
  gap: 12px;
  margin-left: auto;
  margin-right: 8px;
}
.nav-link {
  text-decoration: none;
  color: var(--accent);
  font-size: 0.95em;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s;
}
.nav-link:hover { background: var(--hover); }

.chat {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  min-height: 200px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--surface);
  margin-top: 16px;
}
.msg {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 6px;
}
.msg-user {
  background: var(--hover);
}
.msg-agent {
  background: transparent;
  border-left: 3px solid var(--accent);
  padding-left: 14px;
}
.msg-role {
  font-size: 0.75em;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.msg-body {
  white-space: pre-wrap;
  font-size: 0.98em;
  line-height: 1.7;
  word-wrap: break-word;
}
.msg-event {
  font-size: 0.82em;
  color: var(--muted);
  padding: 3px 8px;
  margin: 4px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.msg-event-tool { color: var(--accent); }
.msg-event-perm { color: #b7791f; font-weight: 600; }
.msg-event-error { color: #c53030; }
.msg-event-info { color: var(--muted); font-style: italic; }
.msg-event-stderr { color: #b7791f; white-space: pre-wrap; }

html[data-theme="dark"] .msg-event-error,
@media (prefers-color-scheme: dark) {
  html[data-theme="system"] .msg-event-error { color: #fc8181; }
}

.chat-form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chat-form textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 1em;
  line-height: 1.6;
  resize: vertical;
}
.chat-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}
.chat-status {
  flex: 1;
  color: var(--muted);
  font-size: 0.85em;
  font-style: italic;
}
.btn-primary, .btn-secondary {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95em;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:disabled, .btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--surface);
  color: var(--fg);
}
.btn-secondary:hover:not(:disabled) { background: var(--hover); }

/* 通知有効化ボタン（控えめ表示）。granted/非対応/拒否時は JS が hidden にする。 */
.btn-notify { opacity: 0.85; }
.btn-notify[hidden] { display: none; }

/* ===== 進捗ステータスバー ===== */
.job-status {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9em;
  flex-wrap: wrap;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  display: inline-block;
}
.status-dot[data-state="running"] {
  background: #f6ad55;
  box-shadow: 0 0 0 0 rgba(246, 173, 85, 0.6);
  animation: pulse 1.4s infinite;
}
.status-dot[data-state="done"] { background: #48bb78; }
.status-dot[data-state="error"] { background: #e53e3e; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(246, 173, 85, 0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(246, 173, 85, 0); }
  100% { box-shadow: 0 0 0 0 rgba(246, 173, 85, 0); }
}
.status-text {
  font-weight: 600;
}
.status-elapsed {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.status-current {
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
}

.session-pill {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75em;
  color: var(--muted);
  background: var(--code-bg);
  padding: 2px 8px;
  border-radius: 4px;
}

/* ===== ジョブブロック / 書き出しファイル一覧 ===== */
.job-block {
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--border);
}
.job-block:last-child {
  border-bottom: none;
}
.job-events {
  margin: 4px 0 4px 8px;
}

.files-panel {
  margin-top: 14px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9em;
}
.files-panel summary {
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0;
}
.files-list {
  margin: 6px 0 4px;
  padding-left: 20px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  word-break: break-all;
}
.files-list li {
  padding: 2px 0;
}
.files-list a {
  color: var(--accent);
  text-decoration: none;
}
.files-list a:hover {
  text-decoration: underline;
}

/* ===== 待機パネル（許可・質問）===== */
.pending-panel {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.pending-panel[hidden] { display: none; }
body.awaiting-response .chat-status::before {
  content: "応答待ち ";
  color: #b7791f;
  font-style: normal;
  font-weight: 600;
}
.pending-head {
  font-weight: 600;
  color: #b7791f;
  font-size: 0.95em;
}
.pending-card {
  border: 1px solid var(--border);
  border-left: 4px solid #f6ad55;
  border-radius: 8px;
  background: var(--surface);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.question-card {
  border-left-color: var(--accent);
}
.pending-title {
  font-weight: 600;
  margin-bottom: 6px;
}
.pending-detail {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-all;
}
.pending-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.btn-deny {
  color: #c53030;
  border-color: var(--border);
}
.deny-reason {
  margin-top: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.9em;
}
.deny-reason[hidden] { display: none; }
.pending-error {
  margin-top: 8px;
  font-size: 0.85em;
}
.pending-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 2px;
}
.perm-badge {
  display: inline-block;
  font-size: 0.72em;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--fg);
  background: var(--code-bg);
}
.perm-badge-ext,
.perm-badge-sensitive,
.perm-badge-outside {
  color: #fff;
  background: #c53030;
  border-color: #c53030;
}
.perm-badge-sensitive { background: #b7791f; border-color: #b7791f; }
.perm-badge-source {
  color: var(--accent);
  background: var(--code-bg);
  border-color: var(--accent);
}

.pending-caution {
  margin: 8px 0 0;
  font-size: 0.85em;
  color: #b7791f;
  background: rgba(246, 173, 85, 0.12);
  border-radius: 6px;
  padding: 6px 10px;
  line-height: 1.5;
}
.pending-scope {
  margin-top: 8px;
  font-size: 0.8em;
  color: var(--muted);
  line-height: 1.5;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

/* 質問UI */
.question-block {
  margin: 10px 0;
}
.question-header {
  font-size: 0.78em;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.question-text {
  font-weight: 600;
  margin-bottom: 8px;
}
.question-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.option-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.92em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.option-btn:hover { background: var(--hover); }
.option-btn.selected {
  border-color: var(--accent);
  background: var(--hover);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.option-label { font-weight: 600; }
.option-desc {
  font-size: 0.85em;
  color: var(--muted);
  line-height: 1.5;
}

/* 質問カードの自由入力欄 */
.question-free {
  margin-top: 8px;
}
.question-free-label {
  font-size: 0.8em;
  color: var(--muted);
  margin-bottom: 4px;
}
.question-free-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.92em;
}
.question-free-input:focus {
  outline: none;
  border-color: var(--accent);
}
.question-free-input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

/* ===== スターターUI（ウェルカムカード）===== */
.welcome-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
  margin: 8px 0;
  box-shadow: var(--shadow);
}
.welcome-title {
  font-weight: 600;
  font-size: 1.05em;
  margin-bottom: 6px;
}
.welcome-lead {
  color: var(--muted);
  font-size: 0.9em;
  line-height: 1.6;
  margin-bottom: 12px;
}
.welcome-guide-btn {
  font-size: 0.95em;
}
.welcome-chips-label {
  margin-top: 14px;
  margin-bottom: 6px;
  font-size: 0.8em;
  color: var(--muted);
}
.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.welcome-chip {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg);
  font-family: inherit;
  font-size: 0.88em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.welcome-chip:hover {
  background: var(--hover);
  border-color: var(--accent);
}

/* ===== 添付（画像）===== */
.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.attach-preview[hidden] { display: none; }
.attach-item {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--surface);
  max-width: 260px;
}
.attach-item.attach-error {
  border-color: #c53030;
}
.attach-thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
/* PDF などサムネを作らない添付のアイコン表示。画像サムネと同じ枠サイズ。 */
.attach-thumb-file {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  background: var(--hover);
  color: var(--fg);
  object-fit: initial;
}
.attach-meta {
  min-width: 0;
  flex: 1;
}
.attach-name {
  font-size: 0.85em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-state {
  font-size: 0.75em;
  color: var(--muted);
}
.attach-error .attach-state { color: #c53030; }
.attach-remove {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.2em;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.attach-remove:hover { color: var(--fg); }

/* ドロップオーバーレイ */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(43, 108, 176, 0.12);
  border: 3px dashed var(--accent);
  color: var(--accent);
  font-size: 1.2em;
  font-weight: 600;
  pointer-events: none;
}
.drop-overlay[hidden] { display: none; }

/* ===== ギャラリー（アップロード済み画像）モーダル ===== */
.gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.gallery-modal[hidden] { display: none; }
.gallery-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.gallery-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(720px, 100%);
  max-height: 80vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.gallery-title {
  font-weight: 600;
  color: var(--fg);
}
.gallery-close {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.4em;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}
.gallery-close:hover {
  color: var(--fg);
  background: var(--hover);
}
.gallery-body {
  padding: 16px;
  overflow-y: auto;
}
.gallery-empty {
  color: var(--muted);
  text-align: center;
  padding: 32px 8px;
  font-size: 0.9em;
}
.gallery-empty.gallery-error { color: #c53030; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.gallery-cell {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.gallery-thumb {
  width: 100%;
  height: 110px;
  object-fit: cover;
  cursor: pointer;
  display: block;
  background: var(--hover);
  transition: opacity 0.15s;
}
.gallery-thumb:hover { opacity: 0.85; }
/* PDF などサムネ不可のセル用アイコン。画像サムネと同じ高さに揃える。 */
.gallery-thumb-file {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  color: var(--fg);
}
.gallery-thumb-broken { object-fit: contain; opacity: 0.5; }
.gallery-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 8px;
  font-size: 0.72em;
  color: var(--muted);
}
.gallery-size { color: var(--fg); }
.gallery-del {
  position: absolute;
  top: 4px;
  right: 4px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.95em;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.gallery-del:hover { background: #c53030; }

/* ===== 狭い画面向け ===== */
@media (max-width: 560px) {
  .site-header {
    padding: 10px 12px;
    gap: 8px;
  }
  .site-header .brand {
    font-size: 0.95em;
  }
  .site-nav {
    margin-left: auto;
    margin-right: 4px;
    gap: 6px;
  }
  .nav-link {
    padding: 4px 8px;
    font-size: 0.88em;
  }
  .menu-toggle {
    width: 34px;
    height: 34px;
  }
  .menu-panel {
    min-width: 0;
    width: calc(100vw - 24px);
    padding: 12px 14px;
  }
  .menu-divider {
    margin: 10px -14px;
  }
  main {
    padding: 20px 14px 60px;
  }
  h1 {
    font-size: 1.35em;
  }
  .chat {
    padding: 10px 12px;
  }
  .chat-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .chat-status {
    flex-basis: 100%;
    text-align: left;
  }
  .session-pill {
    flex-basis: 100%;
  }
  .job-status {
    padding: 8px 12px;
    font-size: 0.85em;
  }
  .status-current {
    flex-basis: 100%;
  }
}

/* ===== ブログ（独立サイト） ===== */
/* /blog 以下はビューワとは別の独立したブログサイトとして blogLayout で出力される。
   各コンテナは inline style で --persona-accent を持つ（未設定時は --accent にフォールバック）。
   本文タイポは .markdown-body を流用しつつ、記事本文は読み物らしい明朝系にする。 */

.blog-body {
  background:
    radial-gradient(1200px 400px at 50% -200px,
      color-mix(in srgb, var(--accent) 7%, transparent), transparent),
    var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- トップバー（独立サイトのヘッダー） --- */
.blog-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--persona-accent, var(--accent));
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.blog-brand {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  text-decoration: none;
  color: var(--fg);
}
.blog-brand-mark { font-size: 1.15em; }
.blog-brand-name {
  font-weight: 800;
  font-size: 1.2em;
  letter-spacing: 0.12em;
}
.blog-topnav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.blog-topnav-link {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9em;
  padding: 6px 12px;
  border-radius: 999px;
  transition: background 0.15s, color 0.15s;
}
.blog-topnav-link:hover {
  background: var(--hover);
  color: var(--fg);
}
.blog-topnav-ext {
  border: 1px solid var(--border);
}

.blog-main {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 24px 64px;
  width: 100%;
  box-sizing: border-box;
  flex: 1 0 auto;
}

/* --- サイトフッター --- */
.blog-site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.85em;
  text-align: center;
  padding: 20px 24px;
}
.blog-site-footer a { color: var(--muted); text-decoration: none; }
.blog-site-footer a:hover { color: var(--accent); text-decoration: underline; }
.blog-foot-brand { font-weight: 700; letter-spacing: 0.08em; }
.blog-foot-sep { margin: 0 8px; opacity: 0.5; }

/* --- 見出し共通 --- */
.blog-section-title {
  font-size: 0.95em;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  margin: 36px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}
.blog-section-count {
  font-size: 0.85em;
  color: var(--fg);
  background: var(--code-bg);
  border-radius: 999px;
  padding: 1px 10px;
}

/* --- インデックス /blog のヒーロー --- */
.blog-hero {
  text-align: center;
  padding: 28px 16px 8px;
}
.blog-hero-title {
  font-size: 2.2em;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin: 0 0 8px;
}
.blog-hero-mark { -webkit-text-fill-color: initial; }
.blog-hero-tagline {
  color: var(--muted);
  font-size: 1em;
  margin: 0;
}

/* --- 投稿主グリッド --- */
.blog-author-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: 14px;
}
.blog-author-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  text-decoration: none;
  color: var(--fg);
  min-width: 0;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.blog-author-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--persona-accent, var(--accent));
}
.blog-author-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--persona-accent, var(--accent)) 50%, var(--border));
}
.blog-avatar {
  flex-shrink: 0;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.55em;
  line-height: 1;
  background: color-mix(in srgb, var(--persona-accent, var(--accent)) 18%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--persona-accent, var(--accent)) 40%, var(--border));
}
.blog-author-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.blog-author-name { font-weight: 700; }
.blog-author-handle { font-size: 0.8em; color: var(--muted); }
.blog-author-tagline {
  font-size: 0.85em;
  color: var(--muted);
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.blog-author-count {
  font-size: 0.75em;
  color: var(--persona-accent, var(--accent));
  font-weight: 700;
  margin-top: 5px;
}

/* --- 新着フィード --- */
.blog-feed {
  list-style: none;
  padding: 0;
  margin: 0;
}
.blog-feed-item { border-bottom: 1px solid var(--border); }
.blog-feed-item:last-child { border-bottom: none; }
.blog-feed-link {
  display: flex;
  gap: 14px;
  padding: 16px 8px;
  text-decoration: none;
  color: var(--fg);
  border-radius: 10px;
  transition: background 0.15s;
}
.blog-feed-link:hover { background: var(--hover); }
.blog-feed-avatar {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3em;
  line-height: 1;
  background: color-mix(in srgb, var(--persona-accent, var(--accent)) 18%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--persona-accent, var(--accent)) 40%, var(--border));
}
.blog-feed-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.blog-feed-byline {
  font-size: 0.78em;
  color: var(--muted);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.blog-feed-handle { opacity: 0.85; }
.blog-feed-date { margin-left: auto; font-variant-numeric: tabular-nums; }
.blog-feed-title {
  font-weight: 700;
  font-size: 1.05em;
  color: var(--fg);
}
.blog-feed-link:hover .blog-feed-title { color: var(--persona-accent, var(--accent)); }
.blog-feed-summary {
  font-size: 0.88em;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- 投稿主ページ : カバー --- */
.blog-cover {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  margin-bottom: 22px;
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--persona-accent, var(--accent)) 22%, var(--surface)),
      var(--surface) 75%);
  border-top: 4px solid var(--persona-accent, var(--accent));
}
.blog-cover-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 24px 22px;
}
.blog-avatar-lg {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4em;
  line-height: 1;
  background: color-mix(in srgb, var(--persona-accent, var(--accent)) 22%, var(--surface));
  border: 2px solid color-mix(in srgb, var(--persona-accent, var(--accent)) 50%, var(--border));
}
.blog-cover-text { min-width: 0; }
.blog-cover-name { font-size: 1.5em; font-weight: 800; margin: 0; }
.blog-cover-handle { font-size: 0.85em; color: var(--muted); margin-top: 2px; }
.blog-cover-tagline {
  font-size: 0.95em;
  color: var(--fg);
  opacity: 0.85;
  margin: 8px 0 0;
  line-height: 1.5;
}
.blog-about {
  margin: 0 4px 8px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--fg);
}
.blog-about :first-child { margin-top: 0; }
.blog-about :last-child { margin-bottom: 0; }

/* --- 投稿主ページ : 記事カード --- */
.blog-postcard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 14px;
}
.blog-postcard {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  padding: 6px 18px 14px;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}
.blog-postcard:hover {
  box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--persona-accent, var(--accent)) 45%, var(--border));
  transform: translateY(-1px);
}
.blog-postcard-link {
  display: block;
  text-decoration: none;
  color: var(--fg);
  padding: 12px 0 8px;
}
.blog-postcard-date {
  font-size: 0.78em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.blog-postcard-title {
  font-size: 1.25em;
  font-weight: 800;
  margin: 6px 0 8px;
  line-height: 1.4;
}
.blog-postcard:hover .blog-postcard-title { color: var(--persona-accent, var(--accent)); }
.blog-postcard-summary {
  font-size: 0.92em;
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}
.blog-postcard-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.blog-postcard-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.blog-postcard-comments {
  margin-left: auto;
  font-size: 0.8em;
  color: var(--muted);
  white-space: nowrap;
}

/* --- タグ共通 --- */
.blog-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.blog-tag {
  display: inline-block;
  padding: 2px 10px;
  font-size: 0.76em;
  color: var(--persona-accent, var(--accent));
  background: color-mix(in srgb, var(--persona-accent, var(--accent)) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--persona-accent, var(--accent)) 25%, var(--border));
  border-radius: 999px;
  text-decoration: none;
}

/* --- 記事ページ --- */
.blog-breadcrumb { font-size: 0.82em; color: var(--muted); margin: 0 0 18px; }
.blog-breadcrumb a { color: var(--muted); text-decoration: none; }
.blog-breadcrumb a:hover { color: var(--persona-accent, var(--accent)); text-decoration: underline; }

.blog-article { max-width: 720px; margin: 0 auto; }
.blog-article-head {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.blog-article-title {
  font-size: 2em;
  font-weight: 800;
  line-height: 1.35;
  margin: 0 0 16px;
  letter-spacing: 0.01em;
}
.blog-article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.blog-byline {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--fg);
}
.blog-byline .blog-avatar { width: 42px; height: 42px; font-size: 1.25em; }
.blog-byline-text { display: flex; flex-direction: column; line-height: 1.3; }
.blog-byline-name { font-weight: 700; }
.blog-byline:hover .blog-byline-name { color: var(--persona-accent, var(--accent)); }
.blog-byline-handle { font-size: 0.78em; color: var(--muted); }
.blog-article-date {
  margin-left: auto;
  font-size: 0.82em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.blog-article-head .blog-tags { margin-top: 16px; }

/* 記事本文：読み物らしい明朝系・ゆったり行間 */
.blog-article-body {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", YuMincho, "Noto Serif JP", serif;
  line-height: 2;
  color: var(--fg);
  letter-spacing: 0.01em;
}
.blog-article-body p { margin: 0 0 1.4em; }
.blog-article-body h2 {
  font-size: 1.35em;
  margin: 1.8em 0 0.7em;
  padding-left: 12px;
  border-left: 4px solid var(--persona-accent, var(--accent));
  line-height: 1.5;
}
.blog-article-body h3 { font-size: 1.15em; margin: 1.6em 0 0.6em; }
.blog-article-body blockquote {
  margin: 1.4em 0;
  padding: 4px 16px;
  border-left: 3px solid color-mix(in srgb, var(--persona-accent, var(--accent)) 45%, var(--border));
  background: color-mix(in srgb, var(--persona-accent, var(--accent)) 6%, var(--surface));
  color: var(--muted);
  border-radius: 0 8px 8px 0;
}
.blog-article-body img { max-width: 100%; height: auto; border-radius: 10px; }
.blog-article-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

/* --- 前後記事ナビ --- */
.blog-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 40px 0 8px;
}
.blog-pager-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  text-decoration: none;
  color: var(--fg);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.blog-pager-link:hover {
  border-color: color-mix(in srgb, var(--persona-accent, var(--accent)) 50%, var(--border));
  background: var(--hover);
  transform: translateY(-1px);
}
.blog-pager-empty {
  border: 1px dashed var(--border);
  background: transparent;
  pointer-events: none;
}
.blog-pager-next { text-align: right; }
.blog-pager-dir { font-size: 0.78em; color: var(--muted); }
.blog-pager-title {
  font-weight: 700;
  font-size: 0.95em;
  color: var(--persona-accent, var(--accent));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* --- コメント欄 --- */
.blog-comments {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.blog-comments-title {
  font-size: 1.05em;
  font-weight: 700;
  margin: 0 0 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.blog-comments-count {
  font-size: 0.85em;
  color: var(--fg);
  background: var(--code-bg);
  border-radius: 999px;
  padding: 1px 10px;
}
.blog-comment-list { list-style: none; padding: 0; margin: 0; }
.blog-comment { display: flex; gap: 12px; padding: 12px 0; }
.blog-comment-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  line-height: 1;
  background: var(--hover);
  border: 1px solid var(--border);
}
.blog-comment-main {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}
.blog-comment-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.blog-comment-handle { font-weight: 700; font-size: 0.9em; }
.blog-comment-date { font-size: 0.76em; color: var(--muted); }
.blog-comment-body { font-size: 0.92em; line-height: 1.7; word-wrap: break-word; }
.blog-comment-reply {
  margin-left: 32px;
  padding-left: 12px;
  border-left: 2px solid color-mix(in srgb, var(--persona-accent, var(--accent)) 35%, var(--border));
}
.blog-comments-empty { color: var(--muted); font-size: 0.9em; padding: 8px 0; }

.blog-article-back { margin-top: 32px; }
.blog-article-back a {
  color: var(--persona-accent, var(--accent));
  text-decoration: none;
  font-size: 0.9em;
}
.blog-article-back a:hover { text-decoration: underline; }

/* --- 狭い画面 --- */
@media (max-width: 560px) {
  .blog-main { padding: 22px 16px 56px; }
  .blog-hero-title { font-size: 1.8em; }
  .blog-author-grid { grid-template-columns: 1fr; }
  .blog-cover-inner { gap: 14px; padding: 18px 16px; }
  .blog-avatar-lg { width: 64px; height: 64px; font-size: 2em; }
  .blog-cover-name { font-size: 1.3em; }
  .blog-article-title { font-size: 1.5em; }
  .blog-article-body { line-height: 1.95; }
  .blog-pager { grid-template-columns: 1fr; }
  .blog-pager-next { text-align: left; }
  .blog-pager-empty { display: none; }
  .blog-comment-reply { margin-left: 16px; }
}

/* ===== ログイン / 初回セットアップ ===== */
.login-body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  padding: 8vh 16px 40px;
}
#login-root { width: 100%; max-width: 420px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 28px 26px 30px;
}
.login-brand {
  font-weight: 600;
  font-size: 1.05em;
  color: var(--muted);
  margin-bottom: 18px;
  text-align: center;
}
.login-title {
  margin: 0 0 6px;
  font-size: 1.5em;
  text-align: center;
}
.login-lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 0.92em;
  line-height: 1.7;
}
.login-loading { color: var(--muted); text-align: center; margin: 8px 0; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-field { display: flex; flex-direction: column; gap: 5px; }
.login-field-label { font-size: 0.82em; color: var(--muted); }
.login-input {
  width: 100%;
  padding: 11px 12px;
  font-size: 1em;
  font-family: inherit;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.login-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.18);
}
.login-btn {
  width: 100%;
  padding: 12px 14px;
  font-size: 1em;
  font-family: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
  transition: filter 0.15s, opacity 0.15s;
}
.login-btn:hover { filter: brightness(1.07); }
.login-btn:disabled { opacity: 0.6; cursor: default; }
.login-btn-secondary {
  color: var(--fg);
  background: var(--surface);
  border-color: var(--border);
}
.login-btn-secondary:hover { background: var(--hover); filter: none; }
.login-or {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 0.82em;
  margin: 18px 0 14px;
}
.login-or::before, .login-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.login-or span { padding: 0 12px; }
.login-msg {
  margin: 4px 0 0;
  font-size: 0.88em;
  min-height: 1.2em;
  color: var(--muted);
}
.login-msg.is-err { color: #d14343; }
.login-msg.is-warn { color: #b7791f; }
.login-msg.is-ok { color: #2f855a; }
html[data-theme="dark"] .login-msg.is-err { color: #f08a8a; }
html[data-theme="dark"] .login-msg.is-warn { color: #e6b860; }
html[data-theme="dark"] .login-msg.is-ok { color: #82d3a4; }

/* ===== ヘッダーのアカウントメニュー ===== */
.menu-account { display: flex; flex-direction: column; gap: 4px; }
.menu-account-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 8px;
  font-size: 0.95em;
  font-family: inherit;
  color: var(--fg);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.menu-account-btn:hover { background: var(--hover); }
.menu-account-btn:disabled { opacity: 0.5; cursor: default; }

/* ===== パスキー管理モーダル ===== */
.pk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.pk-modal {
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.pk-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.pk-title { margin: 0; font-size: 1.15em; }
.pk-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.5em;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.pk-close:hover { color: var(--fg); }
.pk-body { padding: 16px 18px 20px; }
.pk-add { display: flex; flex-direction: column; gap: 10px; }
.pk-label-input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95em;
  font-family: inherit;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.pk-label-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.18);
}
.pk-add-btn {
  padding: 10px 14px;
  font-size: 0.95em;
  font-family: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  cursor: pointer;
}
.pk-add-btn:hover { filter: brightness(1.07); }
.pk-add-btn:disabled { opacity: 0.6; cursor: default; }
.pk-msg { margin: 12px 0 4px; font-size: 0.86em; min-height: 1em; color: var(--muted); }
.pk-msg.is-err { color: #d14343; }
.pk-msg.is-warn { color: #b7791f; }
.pk-msg.is-ok { color: #2f855a; }
html[data-theme="dark"] .pk-msg.is-err { color: #f08a8a; }
html[data-theme="dark"] .pk-msg.is-warn { color: #e6b860; }
html[data-theme="dark"] .pk-msg.is-ok { color: #82d3a4; }
.pk-list { list-style: none; margin: 8px 0 0; padding: 0; }
.pk-loading, .pk-empty { color: var(--muted); font-size: 0.9em; padding: 8px 2px; }
.pk-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 2px;
  border-top: 1px solid var(--border);
}
.pk-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.pk-item-name { font-size: 0.95em; word-break: break-word; }
.pk-item-date { font-size: 0.78em; color: var(--muted); }
.pk-del {
  flex: none;
  padding: 6px 12px;
  font-size: 0.85em;
  font-family: inherit;
  color: #d14343;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.pk-del:hover { background: var(--hover); }
.pk-del:disabled { opacity: 0.5; cursor: default; }

/* ===== しおり・読書位置 ===== */

/* トップ「続きから読む」カード */
.resume-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 12px 0 20px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  text-decoration: none;
  color: var(--fg);
  transition: background 0.15s, border-color 0.15s;
}
.resume-card:hover {
  background: var(--hover);
  border-color: var(--accent);
}
.resume-card-label {
  font-size: 0.8em;
  font-weight: 600;
  color: var(--accent);
}
.resume-card-title { font-size: 0.98em; word-break: break-word; }

/* /view 復帰チップ（画面下中央） */
.resume-chip {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  max-width: calc(100vw - 120px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 60;
}
.resume-chip-go {
  background: transparent;
  border: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 0.88em;
  padding: 9px 4px 9px 16px;
  cursor: pointer;
  white-space: nowrap;
}
.resume-chip-close {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 1.1em;
  line-height: 1;
  padding: 9px 12px 9px 8px;
  cursor: pointer;
}
.resume-chip-close:hover { color: var(--fg); }

/* しおり FAB（/view 右下固定） */
.bookmark-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 1.3em;
  line-height: 1;
  cursor: pointer;
  z-index: 60;
  transition: border-color 0.15s, transform 0.1s;
}
.bookmark-fab:hover { border-color: var(--accent); }
.bookmark-fab:active { transform: scale(0.94); }
.bookmark-fab:disabled { opacity: 0.6; cursor: default; }

/* トースト */
.wn-toast {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%) translateY(8px);
  background: var(--fg);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.88em;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 120;
  pointer-events: none;
  max-width: calc(100vw - 48px);
}
.wn-toast.is-show {
  opacity: 0.92;
  transform: translateX(-50%) translateY(0);
}

/* しおり一覧モーダル（pk-modal 流用＋差分） */
.bm-list .bm-item { align-items: flex-start; }
.bm-item-link {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: var(--fg);
}
.bm-item-link:hover .bm-item-title { color: var(--accent); }
.bm-item-title {
  font-size: 0.95em;
  font-weight: 600;
  word-break: break-word;
}
.bm-item-excerpt {
  font-size: 0.82em;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
