:root {
  --theme-primary: #d4af37;
  --theme-bg: #080808;
  --theme-panel: #111;
  --border-color: #333;
  --text-main: #e0e0e0;
  --text-sub: #888;
  --header-height: 44px;

  /* ★変更: 等幅フォントを優先適用 */
  --editor-font: 16px 'Roboto Mono', 'Consolas', 'Monaco', monospace;
  --editor-line-height: 1.8;
  /* エディタとプレビュー共通の余白設定 (モバイルなどは微調整可) */

  --editor-padding: 0 10px 80vh 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--theme-bg);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  height: 100vh;
  overflow: hidden;
}

/* ==========================================
   ログイン画面 (マジックリンク認証)
   ========================================== */
.login-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: var(--theme-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-box {
  background: #111;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 40px 30px;
  text-align: center;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.login-logo {
  font-size: 28px;
  font-weight: bold;
  color: var(--theme-primary);
  margin-bottom: 10px;
  letter-spacing: 2px;
}

.login-desc {
  color: #888;
  font-size: 14px;
  margin-bottom: 25px;
}

.login-input {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #fff;
  padding: 14px 16px;
  border-radius: 8px;
  font-size: 16px;
  outline: none;
  margin-bottom: 15px;
  transition: 0.2s;
}

.login-input:focus {
  border-color: var(--theme-primary);
  background: #222;
}

.login-btn {
  width: 100%;
  background: var(--theme-primary);
  color: #000;
  border: none;
  padding: 14px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: 0.2s;
}

.login-btn:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.login-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.login-message {
  color: var(--theme-primary);
  font-size: 13px;
  margin-top: 20px;
  min-height: 20px;
}

/* GitHubログインボタン */
.login-btn.github-btn {
  background: #24292e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 15px;
}

.login-btn.github-btn:hover {
  background: #2f363d;
}

/* 区切り線 */
.login-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: #666;
  font-size: 12px;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #333;
}

.login-divider span {
  padding: 0 15px;
}

/* Form Elements */
input:-webkit-autofill,
textarea:-webkit-autofill,
input:-webkit-autofill:focus,
textarea:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--theme-primary) !important;
  -webkit-box-shadow: 0 0 0px 1000px var(--theme-bg) inset !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* ★追加: キャレット色を統一 */
input,
textarea,
.cm-content {
  caret-color: var(--theme-primary) !important;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Layout Structure */
.v2-layout {
  display: flex;
  width: 100%;
  height: 100%;
  position: relative;
}

/* Sidebar 1 (Memo List) */
.pane-sidebar {
  width: 320px;
  min-width: 200px;
  max-width: 80%;
  background: var(--theme-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 10px 10px 5px 10px;
  background: #0c0c0c;
  border-bottom: 1px solid #1a1a1a;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.search-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  width: 100%;
  background: #1a1a1a;
  border: 1px solid #333;
  color: #fff;
  padding: 6px 30px;
  border-radius: 4px;
  font-size: 13px;
  outline: none;
  transition: 0.2s;
}

.search-box input:focus {
  border-color: var(--theme-primary);
  background: #222;
}

.search-icon {
  position: absolute;
  left: 8px;
  font-size: 18px;
  color: #666;
}

.reset-btn {
  position: absolute;
  right: 2px;
  color: #666;
  display: none;
}

.spacer {
  flex: 1;
}

/* Buttons */
.tool-icon-btn,
.icon-btn-mini {
  background: transparent;
  border: 1px solid transparent;
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  width: 32px;
  height: 32px;
  transition: 0.2s;
  position: relative;
}

.tool-icon-btn:hover {
  color: var(--theme-primary);
  background: rgba(255, 255, 255, 0.05);
  border-color: #333;
}

.tool-icon-btn.has-url {
  color: var(--theme-primary);
  text-shadow: 0 0 5px rgba(212, 175, 55, 0.3);
}

.active-glow {
  color: var(--theme-primary) !important;
  text-shadow: 0 0 8px rgba(212, 175, 55, 0.6);
}

/* Sidebar List Items */
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.card {
  padding: 12px 10px;
  border-bottom: 1px solid #1a1a1a;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  position: relative;
}

.card:hover {
  background: #151515;
}

.card[data-active="true"] {
  background: #1f1f1f;
  border-left: 2px solid var(--theme-primary);
  padding-left: 8px;
}

.card.done {
  opacity: 0.5;
}

.card-check {
  display: none;
  margin-top: 3px;
}

.sidebar-list.multi-mode .card-check {
  display: block;
}

.card-indicator {
  color: var(--theme-primary);
  font-size: 14px;
  margin-top: 2px;
  cursor: pointer;
  transition: 0.2s;
}

.card-indicator:hover {
  transform: scale(1.2);
  text-shadow: 0 0 5px var(--theme-primary);
}

.card.done .card-indicator {
  color: #555;
}

.card-content {
  flex: 1;
  overflow: hidden;
}

.card-title {
  font-size: 13px;
  color: #ddd;
  line-height: 1.4;
  max-height: 2.8em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-meta {
  font-size: 10px;
  color: #666;
  margin-top: 4px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.card-tag {
  color: var(--theme-primary);
  opacity: 0.8;
}

.card-copy-btn,
.card-link-btn {
  opacity: 0;
  color: #666;
  font-size: 14px;
  margin-top: 2px;
  border-radius: 50%;
  padding: 2px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card:hover .card-link-btn {
  opacity: 1;
}

.card:hover .card-copy-btn {
  opacity: 1;
}

.card-copy-btn:hover,
.card-link-btn:hover {
  color: var(--theme-primary);
  background: rgba(255, 255, 255, 0.1);
}

/* Resizers */
.resizer-horizontal {
  height: 4px;
  cursor: row-resize;
  background: #000;
  border-top: 1px solid #222;
  border-bottom: 1px solid #222;
  flex-shrink: 0;
}

.resizer-vertical {
  width: 4px;
  cursor: col-resize;
  background: #000;
  border-left: 1px solid #222;
  border-right: 1px solid #222;
  z-index: 100;
}

.resizer-horizontal:hover,
.resizer-vertical:hover {
  background: var(--theme-primary);
}

/* Main Editor Area */
.pane-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--theme-panel);
  overflow: hidden;
}

.editor-workspace {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.editor-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-color);
  position: relative;
  min-width: 0;
}

.editor-pane.active {
  background: #141414;
}

.editor-pane:not(.active) {
  opacity: 0.8;
  filter: grayscale(0.5);
}

.pane-toolbar {
  height: 44px;
  border-bottom: 1px solid #222;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  background: #0e0e0e;
}

.status-select {
  appearance: none;
  background: transparent;
  border: 1px solid #333;
  color: #ccc;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  min-width: 50px;
  text-align: center;
}

.status-select option {
  background: #000;
  color: #fff;
}

.badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--theme-primary);
  color: #000;
  font-size: 9px;
  min-width: 14px;
  height: 14px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  pointer-events: none;
  z-index: 10;
}

.pane-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0 20px 20px;
  overflow: hidden;
  position: relative;
}

/* Inputs */
.url-input-row {
  padding-top: 10px;
}

.input-url {
  width: 100%;
  background: #080808;
  border: 1px solid #333;
  color: var(--theme-primary);
  font-family: monospace;
  font-size: 11px;
  padding: 6px;
  border-radius: 4px;
}

.input-title {
  width: 100%;
  background: transparent;
  border: none;
  font-size: 2em;
  color: var(--theme-primary);
  font-weight: bold;
  padding: 10px 0;
  outline: none;
  line-height: 1.3;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  margin-bottom: 10px;
}

/* Markdown Toolbar */
.markdown-toolbar {
  display: flex;
  gap: 5px;
  padding-bottom: 10px;
  margin-top: 10px;
  border-bottom: 1px solid #222;
}

.cm-h1 {
  font-size: 2.0em;
  line-height: 1.4;
  margin-top: 10px;
  font-weight: bold;
}

.cm-h2 {
  font-size: 1.5em;
  line-height: 1.4;
  margin-top: 10px;
  font-weight: bold;
}

.cm-h3 {
  font-size: 1.25em;
  line-height: 1.4;
  margin-top: 5px;
  font-weight: bold;
}

.cm-h4 {
  font-size: 1.1em;
  line-height: 1.4;
  margin-top: 5px;
  font-weight: bold;
}

.cm-h5 {
  font-size: 1.0em;
  line-height: 1.4;
  margin-top: 5px;
  font-weight: bold;
}

.cm-h6 {
  font-size: 1.0em;
  line-height: 1.4;
  margin-top: 5px;
  font-weight: bold;
}

/* CodeMirror v6 Container Fixes */
.cm-editor {
  height: 100%;
  width: 100%;
  font-size: 14px;
  background-color: var(--theme-panel);
}

.cm-scroller {
  overflow: auto;
  font-family: 'Roboto Mono', 'Consolas', monospace !important;
  line-height: 1.6;
}

/* フォーカス時のアウトライン削除（テーマ側で制御するため） */
.cm-editor.cm-focused {
  outline: none;
}

/* 既存のエディタコンテナの調整 */
.editor-body-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  /* CodeMirrorが自前でスクロールを持つため、コンテナは隠す */
}

.markdown-toolbar button {
  background: #1a1a1a;
  border: 1px solid #333;
  color: #888;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
}

.markdown-toolbar button:hover {
  color: #fff;
  border-color: #555;
}

.markdown-toolbar .sep {
  width: 1px;
  background: #333;
  margin: 0 5px;
}

/* Editor Body & Sync */
.editor-body-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.editor-content-shared {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: var(--editor-padding);
  border: none;
  font: var(--editor-font);
  line-height: var(--editor-line-height);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  box-sizing: border-box;
  padding-bottom: 80vh;
}

.input-body {
  z-index: 2;
  background: transparent;
  color: transparent;
  caret-color: var(--theme-primary);
  resize: none;
  outline: none;
  overflow-y: auto;
  -webkit-appearance: none;
}

.input-body::selection {
  background: rgba(212, 175, 55, 0.3);
  color: transparent;
}

.backdrop {
  z-index: 1;
  pointer-events: none;
  background: transparent;
  color: #ddd;
  overflow: hidden;
}

/* Syntax Highlight */
.hl-indent-guide {
  display: inline;
  box-shadow: -1px 0 0 0 rgba(255, 255, 255, 0.1);
}

.hl-symbol,
.hl-text,
.hl-bold,
.hl-code,
.hl-check-bracket,
.hl-check-x,
.hl-list-indent {
  font-weight: normal !important;
}

.hl-symbol {
  color: rgba(212, 175, 55, 0.5);
}

.hl-text {
  color: #fff;
}

.hl-bold {
  color: var(--theme-primary);
  text-shadow: 0 0 1px rgba(212, 175, 55, 0.3);
}

.hl-code {
  color: #aaddff;
  background: rgba(255, 255, 255, 0.05);
}

.hl-check-bracket {
  color: #666;
}

.hl-check-x {
  color: #666 !important;
  /* ★変更: 完了済みは少し暗くして目立たなくする */
  text-decoration: line-through;
  /* オプション: 打ち消し線 */
  opacity: 0.7;
}

/* ★追加: チェックボックスモードON時のスタイル */
.checkbox-mode-on .cm-content {
  cursor: default;
  /* テキスト選択カーソルではなく矢印に */
}

.checkbox-mode-on .hl-check-bracket,
.checkbox-mode-on .hl-check-x {
  cursor: pointer;
  /* チェックボックス部分は指アイコン */
}

.hl-list-indent {
  color: #a8a8a8;
}

/* ★変更: プレビュー画面のスタイルを大幅修正 */
.markdown-preview {
  /* position: absolute; を削除し、エディタと同じ配置にする */
  /* z-index: 3; も不要 */
  flex: 1;
  /* エディタと同じように残りの高さを埋める */
  display: none;
  /* 初期状態は非表示 */
  overflow: auto;
  /* スクロール可能に */

  background: var(--theme-panel);
  color: #e0e0e0;

  /* エディタと全く同じ余白・フォント設定を適用 */
  padding: var(--editor-padding);
  font-family: var(--editor-font);
  font-size: 16px;
  line-height: var(--editor-line-height);
  scroll-behavior: smooth;
}

.markdown-preview ul,
.markdown-preview ol {
  padding-left: 1.5em;
}

/* プレビュー内の見出しスタイル調整（タイトル入力欄と被らないように少し控えめに） */
.markdown-preview h1 {
  font-size: 1.8em;
  color: var(--theme-primary);
  border-bottom: 1px solid #444;
  margin-top: 0;
  /* 上部の余白を詰める（タイトル入力欄があるため） */
  margin-bottom: 0.8em;
}

.markdown-preview h2 {
  color: #eee;
  border-bottom: 1px solid #333;
}

.markdown-preview a {
  color: #64b5f6;
}

.markdown-preview pre {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 10px;
  overflow-x: auto;
  position: relative;
}

.markdown-preview pre::before {
  content: "CODE";
  position: absolute;
  top: 0;
  right: 0;
  background: #333;
  color: #aaa;
  font-size: 9px;
  padding: 2px 6px;
  border-bottom-left-radius: 4px;
}

.markdown-preview code {
  font-family: monospace;
  color: #aaddff;
}

/* Checkbox style */
.markdown-preview li:has(input[type="checkbox"]) {
  list-style-type: none;
  padding-left: 1.8em;
  position: relative;
}

.markdown-preview li>input[type="checkbox"] {
  position: absolute;
  left: 0.2em;
  top: 0.35em;
  margin: 0;
}

/* Floating Palette */
.floating-palette {
  position: absolute;
  top: 50px;
  left: 20px;
  width: 200px;
  height: 250px;
  background: rgba(15, 15, 15, 0.95);
  border: 1px solid var(--theme-primary);
  border-radius: 6px;
  z-index: 2000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
  display: none;
  flex-direction: column;
  overflow: hidden;
  min-width: 150px;
  min-height: 100px;
}

.palette-header {
  padding: 0 5px 0 10px;
  /* パディング調整 */
  height: 40px;
  /* 高さ固定 */
  background: #111;
  border-bottom: 1px solid #333;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: move;
}

/* ヘッダー内の入力欄 */
.header-tag-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 12px;
  outline: none;
  min-width: 0;
  /* Flexboxでの縮小許可 */
  padding: 5px;
}

.header-tag-input::placeholder {
  color: #555;
}

/* バツボタン */
.close-palette-btn {
  cursor: pointer;
  padding: 5px;
  color: #666;
}

.close-palette-btn:hover {
  color: #fff;
}

.palette-input {
  display: none;
  /* V2では非表示 (ヘッダーへ統合) */
}

.palette-content {
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  align-content: flex-start;
}

.chip {
  font-size: 10px;
  background: #222;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid #333;
  cursor: pointer;
  color: #aaa;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.chip:hover {
  border-color: var(--theme-primary);
  color: #fff;
}

.chip.active-tag {
  background: var(--theme-primary);
  color: #000;
}

.chip-remove {
  font-size: 12px;
  margin-left: 2px;
}

.chip-remove:hover {
  color: #cc3333;
}

.palette-resizer {
  width: 12px;
  height: 12px;
  position: absolute;
  bottom: 0;
  right: 0;
  cursor: se-resize;
  background: linear-gradient(135deg, transparent 50%, var(--theme-primary) 50%);
  opacity: 0.5;
}

/* Bulk Actions */
.bulk-actions {
  background: #222;
  color: #fff;
  padding: 8px;
  display: none;
  align-items: center;
  border-top: 1px solid var(--theme-primary);
}

.bulk-actions.show {
  display: flex;
}

.bulk-actions button {
  margin-left: 5px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  border: none;
  background: #444;
  color: #fff;
  border-radius: 2px;
}

.bulk-actions button.danger {
  background: #822;
}

/* Toast & Counts */
.char-count {
  font-size: 10px;
  color: #666;
  margin-right: 8px;
  font-family: monospace;
  min-width: 40px;
  text-align: right;
  transition: color 0.3s;
}

.limit-warning {
  color: #d4af37;
  font-weight: bold;
}

.limit-error {
  color: #ff4444;
  font-weight: bold;
}

#toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #222;
  border: 1px solid var(--theme-primary);
  color: var(--theme-primary);
  padding: 6px 15px;
  border-radius: 20px;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s;
  z-index: 3000;
  font-size: 11px;
  letter-spacing: 1px;
}

.close-pane-btn {
  position: absolute;
  top: 5px;
  right: 15px;
  z-index: 100;
  color: #666;
  cursor: pointer;
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid #333;
  transition: 0.2s;
}

.close-pane-btn:hover {
  color: #fff;
  background: #822;
  border-color: #f55;
}

.smart-copy-menu {
  position: fixed;
  background: #1a1a1a;
  border: 1px solid var(--theme-primary);
  border-radius: 4px;
  display: none;
  gap: 2px;
  padding: 4px;
  z-index: 5000;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
}

.copy-menu-item {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  cursor: pointer;
  border-radius: 3px;
}

.copy-menu-item:hover {
  background: var(--theme-primary);
  color: #000;
}

/* PC Hover Menu */
.copy-hover-menu {
  position: fixed;
  background: #1a1a1a;
  border: 1px solid var(--theme-primary);
  border-radius: 6px;
  padding: 4px;
  z-index: 5000;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.8);
}

.copy-hover-menu.show {
  display: flex;
}

.copy-hover-menu-item {
  padding: 6px 12px;
  color: #ccc;
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  border-radius: 4px;
}

.copy-hover-menu-item:hover {
  background: var(--theme-primary);
  color: #000;
}

/* Outline & Progress */
.task-progress-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #333;
}

.progress-bar-bg {
  width: 50px;
  height: 4px;
  background: #333;
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--theme-primary);
  width: 0%;
  transition: width 0.3s ease;
  box-shadow: 0 0 4px var(--theme-primary);
}

.progress-text {
  font-size: 9px;
  color: #888;
  font-family: monospace;
}

.outline-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  background: rgba(12, 12, 12, 0.98);
  border-left: 1px solid var(--theme-primary);
  z-index: 500;
  display: flex;
  flex-direction: column;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
}

.outline-resizer-left {
  position: absolute;
  left: -4px;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  z-index: 501;
  background: transparent;
}

.outline-resizer-left:hover {
  background: rgba(212, 175, 55, 0.3);
}

.outline-header {
  padding: 5px;
  border-bottom: 1px solid #333;
  color: var(--theme-primary);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 1px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #111;
  flex-shrink: 0;
}

.outline-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
  position: relative;
}

.outline-content::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 14px;
  width: 1px;
  background: rgba(255, 255, 255, 0.1);
  z-index: 0;
}

.outline-item {
  position: relative;
  cursor: pointer;
  color: #888;
  font-size: 12px;
  padding: 4px 10px 4px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.1s, background 0.1s;
  z-index: 1;
}

.outline-item:hover {
  color: #fff;
  background: rgba(212, 175, 55, 0.1);
}

.outline-item .material-icons-outlined {
  font-size: 14px;
  flex-shrink: 0;
  color: #555;
}

.outline-item::before {
  content: "";
  position: absolute;
  top: 50%;
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  display: none;
}

.outline-item::after {
  content: "";
  position: absolute;
  top: -10px;
  bottom: 50%;
  width: 1px;
  background: rgba(255, 255, 255, 0.15);
  display: none;
}

.outline-item.level-1 {
  padding-left: 10px;
  margin-top: 8px;
  color: var(--theme-primary);
  font-weight: 600;
}

.outline-item.level-1 .material-icons-outlined {
  color: var(--theme-primary);
}

.outline-item.level-1 .bg-mask {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 20px;
  background: var(--theme-panel);
  z-index: -1;
}

.outline-item.level-2 {
  padding-left: 28px;
  color: #ccc;
}

.outline-item.level-2::before,
.outline-item.level-2::after {
  display: block;
  left: 14px;
  width: 10px;
}

.outline-item.level-3 {
  padding-left: 46px;
  color: #aaa;
}

.outline-item.level-3::before,
.outline-item.level-3::after {
  display: block;
  left: 32px;
  width: 10px;
}

.outline-item.level-4 {
  padding-left: 64px;
  color: #999;
}

.outline-item.level-4::before,
.outline-item.level-4::after {
  display: block;
  left: 50px;
  width: 10px;
}

.outline-item.is-code {
  color: #64b5f6 !important;
  font-family: monospace;
  font-weight: normal !important;
  margin-top: 0 !important;
  opacity: 0.9;
}

.outline-item.is-code .material-icons-outlined {
  color: #64b5f6 !important;
  opacity: 0.7;
}

.measurement-clone {
  position: absolute;
  top: -9999px;
  left: -9999px;
  visibility: hidden;
  pointer-events: none;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-wrap: break-word;
  padding-bottom: 0 !important;
  height: auto !important;
}

/* Animation Keyframes */
@keyframes spin-save {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

.saving-spin {
  animation: spin-save 1s linear infinite;
  color: var(--theme-primary) !important;
}

.save-done {
  color: var(--theme-primary) !important;
}

@keyframes pulse-gold {
  0% {
    background-color: rgba(212, 175, 55, 0.05);
  }

  50% {
    background-color: rgba(212, 175, 55, 0.15);
  }

  100% {
    background-color: rgba(212, 175, 55, 0.05);
  }
}

.skeleton-wrapper {
  /* ★追加: エディタの上に重ねるための設定 */
  position: absolute;
  top: 0;
  left: 0;
  z-index: 50;
  background: var(--theme-panel);
  /* 背景色で後ろを隠す */
  pointer-events: none;
  /* クリックを透過 */

  /* 既存設定の調整 */
  width: 100%;
  height: 100%;
  /* エディタと同じ余白を使って開始位置を合わせる */
  padding: var(--editor-padding);
  padding-top: 10px;

  display: flex;
  flex-direction: column;
  gap: 15px;
}

.skeleton-line {
  width: 100%;
  height: 24px;
  min-height: 24px;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  animation: pulse-gold 1.5s infinite ease-in-out;
}

.skeleton-line.short {
  width: 40%;
}

.skeleton-line.medium {
  width: 70%;
}

.skeleton-line.long {
  width: 90%;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === V5 UI: PC Drilldown Pane (Sidebar 2) === */
.pane-drilldown {
  width: 240px;
  min-width: 180px;
  max-width: 350px;
  background: #0f0f0f;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding-bottom: 20px;
}

.drilldown-header {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  border-bottom: 1px solid #222;
  color: var(--theme-primary);
  font-weight: bold;
  font-size: 11px;
  letter-spacing: 1px;
}

.drilldown-section {
  padding: 15px 10px;
  border-bottom: 1px solid #1a1a1a;
}

.section-label {
  font-size: 10px;
  color: #666;
  margin-bottom: 8px;
  font-weight: bold;
  letter-spacing: 0.5px;
}

.fav-item-pc,
.tag-item-pc {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  margin-bottom: 2px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: #aaa;
  transition: 0.2s;
}

.fav-item-pc:hover,
.tag-item-pc:hover {
  background: #1a1a1a;
  color: #fff;
}

.fav-item-pc.active,
.tag-item-pc.active {
  color: var(--theme-primary);
  background: rgba(212, 175, 55, 0.1);
}

.tag-count {
  font-size: 10px;
  color: #555;
}

/* === MOBILE OPTIMIZATION (V5.2 Final) === */
.mobile-only {
  display: none !important;
}

@media (max-width: 768px) {

  /* Visibility Toggle */
  .desktop-only {
    display: none !important;
  }

  .mobile-only {
    display: flex !important;
  }

  /* Layout */
  body {
    overflow: hidden;
    position: relative;
    background: var(--theme-bg);
  }

  .v2-layout {
    flex-direction: column;
    height: 100vh;
    padding-top: 44px;
    padding-bottom: 34px;
  }

  /* Mobile Header */
  .mobile-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 44px;
    background: #0c0c0c;
    border-bottom: 1px solid #222;
    z-index: 2000;
    display: flex;
    align-items: center;
    padding: 0 4px;
  }

  .mobile-toolbar-icons {
    display: flex;
    align-items: center;
    gap: 2px;
  }

  .icon-btn {
    color: #888;
    background: transparent;
    border: none;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    position: relative;
  }

  .icon-btn:active {
    color: var(--theme-primary);
    background: rgba(255, 255, 255, 0.05);
  }

  .icon-btn.active-glow {
    color: var(--theme-primary);
    text-shadow: 0 0 5px rgba(212, 175, 55, 0.5);
  }

  .status-popup {
    position: absolute;
    top: 46px;
    left: 50px;
    background: #1a1a1a;
    border: 1px solid var(--theme-primary);
    border-radius: 6px;
    display: none;
    flex-direction: column;
    z-index: 2500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  }

  .status-popup.show {
    display: flex;
  }

  .status-popup div {
    padding: 10px 15px;
    color: #ccc;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #333;
  }

  .status-popup div:last-child {
    border-bottom: none;
  }

  .status-popup div:active {
    background: var(--theme-primary);
    color: #000;
  }

  /* V5 Sidebar Fullscreen */
  .pane-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100%;
    z-index: 3000;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--theme-bg);
    border-right: none;
    display: flex;
    flex-direction: column;
  }

  .pane-sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2500;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    backdrop-filter: blur(2px);
  }

  body.menu-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  /* Header in Sidebar */
  .sidebar-header {
    padding: 0;
    background: #0c0c0c;
    border-bottom: 1px solid #222;
    flex-shrink: 0;
  }

  .search-row {
    padding: 8px 10px;
    display: flex;
    gap: 10px;
    border-bottom: 1px solid #1a1a1a;
  }

  .search-box {
    height: 36px;
  }

  /* Mobile Smart Filter */
  .mobile-filter-container {
    background: #111;
    padding: 10px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .mobile-fav-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .mobile-fav-item {
    background: #1a1a1a;
    color: #ccc;
    border: 1px solid #333;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
  }

  .mobile-fav-item span {
    color: var(--theme-primary);
    font-size: 14px;
  }

  .mobile-active-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 4px;
  }

  .mobile-tag-chip {
    background: rgba(212, 175, 55, 0.15);
    color: var(--theme-primary);
    border: 1px solid var(--theme-primary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
  }

  .mobile-suggestions-row {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 4px;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .mobile-suggestions-row::-webkit-scrollbar {
    display: none;
  }

  .mobile-suggest-btn {
    white-space: nowrap;
    background: #222;
    border: 1px solid #333;
    color: #aaa;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 11px;
    cursor: pointer;
    flex-shrink: 0;
  }

  .mobile-suggest-btn.save-btn {
    color: var(--theme-primary);
    border-color: var(--theme-primary);
    font-weight: bold;
  }

  .mobile-suggest-btn:active {
    background: #333;
    color: #fff;
  }

  /* Editor Layout */
  .pane-main {
    width: 100%;
    height: 100%;
    position: relative;
  }

  .editor-workspace {
    width: 100%;
    height: 100%;
    display: block;
  }

  #editorPane1 {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    background: var(--theme-bg);
    display: flex !important;
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
    padding-top: 5px;
  }

  #editorPane2 {
    display: none !important;
  }

  .input-title {
    font-size: 1.25em;
    padding: 5px 0;
    margin: 0 10px 5px 10px;
    width: calc(100% - 20px);
  }

  .pane-content {
    padding: 0 10px;
  }

  /* Mobile Toolbar */
  .mobile-toolbar-bar {
    width: 100%;
    background: #111;
    border-bottom: 1px solid #333;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    overflow-x: auto;
    margin-bottom: 5px;
    display: none !important;
  }

  .mobile-toolbar-bar.show {
    display: flex !important;
    animation: fadeIn 0.2s ease-out;
  }

  .mobile-toolbar-bar button {
    background: #222;
    border: 1px solid #444;
    color: #aaa;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 11px;
    white-space: nowrap;
    min-width: 36px;
    height: 30px;
    flex-shrink: 0;
  }

  .mobile-toolbar-bar button:active {
    background: var(--theme-primary);
    color: #000;
  }

  .mobile-toolbar-bar .sep {
    width: 1px;
    background: #444;
    margin: 0 2px;
    height: 16px;
    flex-shrink: 0;
  }

  .mobile-toolbar-bar .close-key {
    border-color: transparent;
    background: transparent;
    color: #666;
    width: 30px;
    margin-left: auto;
  }

  .footer-tools {
    display: none !important;
  }

  .mobile-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 34px;
    background: #0c0c0c;
    border-top: 1px solid #222;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .footer-info {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 15px;
  }

  .char-count {
    font-size: 11px;
    color: #666;
    font-family: monospace;
  }

  .outline-panel {
    position: fixed !important;
    top: 44px;
    right: 0;
    bottom: 34px;
    width: 60% !important;
    z-index: 5000;
    border-left: 1px solid var(--theme-primary);
    background: rgba(10, 10, 10, 0.98);
    transform: translateX(100%);
    transition: transform 0.2s;
    display: flex !important;
  }

  .outline-panel.active {
    transform: translateX(0);
  }

  .floating-palette {
    position: fixed !important;
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 40vh !important;
    border-radius: 12px 12px 0 0;
    border: 1px solid var(--theme-primary);
    border-bottom: none;
    z-index: 6000;
    animation: slideUp 0.3s forwards;
  }

  .palette-resizer {
    display: none;
  }

  .markdown-preview h1 {
    font-size: 1.3em !important;
    border-bottom: 1px solid var(--theme-primary);
    margin-top: 10px;
  }

  .markdown-preview h2 {
    font-size: 1.15em !important;
    margin-top: 15px;
  }

  .markdown-preview h3 {
    font-size: 1.05em !important;
    margin-top: 10px;
  }

  .markdown-preview ul,
  .markdown-preview ol {
    margin: 0.6em 0;
  }

  .markdown-preview li {
    margin: 0.4em 0;
    line-height: 1.6;
  }
}

/* Mobile Floating Panel */
.floating-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 320px;
  background: rgba(15, 15, 15, 0.95);
  border: 1px solid var(--theme-primary);
  border-radius: 8px;
  z-index: 5000;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  padding: 10px 15px;
  background: rgba(212, 175, 55, 0.1);
  color: var(--theme-primary);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #333;
  font-size: 13px;
  font-weight: bold;
}

.close-panel {
  cursor: pointer;
}

.panel-body {
  padding: 15px;
}

.url-input-wrapper {
  display: flex;
  gap: 8px;
  margin-bottom: 15px;
}

.url-input-wrapper input {
  flex: 1;
  min-width: 0;
  background: #000;
  border: 1px solid #444;
  color: var(--theme-primary);
  padding: 8px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.action-btn,
.danger-btn {
  flex: 1;
  padding: 10px;
  border-radius: 4px;
  border: none;
  font-size: 13px;
  cursor: pointer;
  transition: 0.2s;
}

.action-btn {
  background: var(--theme-primary);
  color: #000;
}

.danger-btn {
  background: #444;
  color: #fff;
}

.action-btn:active {
  background: #b08d2b;
}

.danger-btn:active {
  background: #333;
}

/* Mobile Preview Enhancements */
.markdown-preview.mobile-view {
  padding: 20px 15px !important;
  background: #000 !important;
  font-size: 15px;
}

/* Finder Accordion */
.section-label {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.toggle-icon {
  transition: transform 0.2s;
}

.drilldown-section.collapsed>div:not(.section-label) {
  display: none !important;
}

.drilldown-section.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

/* URL Input Wrapper Integration (PC) */
.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.overlay-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.4) !important;
  border: none !important;
  z-index: 5;
}

/* Clear All Button */
.clear-all-btn {
  background: transparent;
  border: 1px solid #444;
  color: #888;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  transition: 0.2s;
}

.clear-all-btn:hover {
  border-color: #666;
  color: #fff;
}

/* Tag Suggestion UI */
.palette-content.suggestion-mode {
  flex-direction: column;
  flex-wrap: nowrap;
  overflow-x: hidden;
}

.tag-candidate-row {
  padding: 10px;
  border-bottom: 1px solid #222;
  cursor: pointer;
  transition: background 0.2s;
}

.tag-candidate-row:hover {
  background: rgba(212, 175, 55, 0.1);
}

/* サジェストエリア (横スクロール・2段) */
.palette-suggestions {
  height: 70px;
  /* 2行分程度の高さ */
  background: #0a0a0a;
  border-bottom: 1px solid #222;
  padding: 8px;

  /* 横スクロール設定 */
  display: flex;
  flex-direction: column;
  /* 縦に積んでから */
  flex-wrap: wrap;
  /* 横に折り返すことで「左から右へ」流れる2段組みになる */
  align-content: flex-start;
  /* 左詰め */
  overflow-x: auto;
  /* 横スクロール有効 */
  overflow-y: hidden;
  /* 縦スクロール禁止 */
  gap: 6px;
}

/* サジェスト内のチップスタイル */
.suggest-chip {
  background: #222;
  border: 1px solid #444;
  color: #aaa;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: 0.2s;
  height: 24px;
  /* 高さ固定 */
  display: flex;
  align-items: center;
}

.suggest-chip:hover {
  border-color: var(--theme-primary);
  color: #fff;
  background: rgba(212, 175, 55, 0.1);
}

.suggest-chip .match-highlight {
  color: var(--theme-primary);
  font-weight: bold;
}