/* ==========================================================================
   mimatu Premium Design System & Stylesheet
   ========================================================================== */

/* --- Custom Variables & Theme Definition --- */
:root {
  /* Common variables */
  --font-primary: 'Inter', 'Noto Sans JP', sans-serif;
  --font-display: 'Outfit', 'Noto Sans JP', sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Status Colors */
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.12);
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.1);
  --color-info: #3b82f6;

  /* Theme-specific (Light Theme override) */
  --bg-primary: #f1f5f9; /* よりモダンな上品スレートグレー */
  --bg-secondary: #ffffff;
  --bg-tertiary: #edf0f5;
  --border-color: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-color: #4f46e5;
  --accent-light: #e0e7ff;
  --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --accent-glow: rgba(249, 115, 22, 0.15); /* オレンジ（ロゴカラー）の淡いグローに変更 */
  
  --glass-bg: rgba(248, 250, 252, 0.85); /* 上品なスレート半透明 */
  --glass-border: rgba(226, 232, 240, 0.8);
  --card-shadow: 0 12px 30px -10px rgba(15, 23, 42, 0.08), 0 4px 12px -5px rgba(15, 23, 42, 0.03); /* よりフワッとしたプレミアムな影 */
  --sidebar-shadow: 1px 0 0 var(--border-color);
  --header-shadow: 0 1px 0 var(--border-color);

  /* Sidebar Theme Colors (Light Mode - SNS Dark Navy Accent) */
  --sidebar-bg: #1c2438;
  --sidebar-border: rgba(255, 255, 255, 0.08);
  --sidebar-text-primary: #ffffff;
  --sidebar-text-secondary: #94a3b8;
  --sidebar-text-muted: #64748b;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
  --sidebar-hover-text: #ffffff;
  --sidebar-active-bg: linear-gradient(135deg, #f97316 0%, #a855f7 100%);
  --sidebar-active-text: #ffffff;
  --sidebar-badge-bg: rgba(255, 255, 255, 0.1);
  --sidebar-badge-text: #cbd5e1;
}

[data-theme="dark"] {
  /* ── 背景の3段階階調（下から上へ明るくなる） ──
     main content (最も暗い) → sidebar (中間) → header (最も明るい) */
  --bg-primary:   #0d0f18;   /* メインコンテンツ: 深い青みのある暗さ */
  --bg-secondary: #161929;   /* カード等: 少し浮き上がる */
  --bg-tertiary:  #1e2235;   /* ホバー・アクティブ背景 */
  --border-color: rgba(255, 255, 255, 0.09);
  --text-primary:   #f0f4ff;
  --text-secondary: #a8b4cc;
  --text-muted:     #5a6680;
  --accent-color: #6366f1;
  --accent-light: rgba(99, 102, 241, 0.15);
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --accent-glow: rgba(99, 102, 241, 0.3);

  /* ヘッダー: サイドバーより明るく、グラスモーフィズム強め */
  --glass-bg:     rgba(30, 35, 58, 0.92);   /* サイドバーより明るい */
  --glass-border: rgba(255, 255, 255, 0.10);
  --card-shadow:  0 20px 40px -15px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0,0,0,0.25);
  --sidebar-shadow: 1px 0 0 rgba(255,255,255, 0.06);
  --header-shadow:  0 1px 0 rgba(255,255,255, 0.07), 0 4px 16px rgba(0,0,0,0.3);

  /* サイドバー: メインより明るく、ヘッダーより少し暗め */
  --sidebar-bg:            #181c2e;   /* main(#0d0f18) より明るく */
  --sidebar-border:        rgba(255, 255, 255, 0.07);
  --sidebar-text-primary:  #e8eeff;
  --sidebar-text-secondary:#8896b3;
  --sidebar-text-muted:    #4e5a72;
  --sidebar-hover-bg:      rgba(255, 255, 255, 0.07);
  --sidebar-hover-text:    #ffffff;
  --sidebar-active-bg:     linear-gradient(135deg, #f97316 0%, #a855f7 100%);
  --sidebar-active-text:   #ffffff;
  --sidebar-badge-bg:      rgba(255, 255, 255, 0.08);
  --sidebar-badge-text:    #a8b4cc;
}

/* --- Core Reset & Typography --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  outline: none;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden; /* App operates in modular container layout */
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

/* --- Layout Structures --- */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header */
.app-header {
  height: 72px;
  background-color: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--header-shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  z-index: 100;
  position: relative;
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.app-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #f97316 0%, #a855f7 50%, #6366f1 100%); /* オレンジ〜パープル〜ブルーのSNSアクセント */
  z-index: 101;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 32px;
  flex: 1;
}

.app-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.logo-emoji {
  font-size: 26px;
  animation: float 3s ease-in-out infinite;
}

.logo-text {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 24px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.header-search-bar {
  position: relative;
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-search-bar input {
  width: 100%;
  background-color: var(--bg-tertiary);
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 11px 18px 11px 48px;
  font-size: 14px;
  transition: all var(--transition-normal);
  color: var(--text-primary);
}

.header-search-bar input:focus {
  border-color: var(--accent-color);
  background-color: var(--bg-secondary);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Main Container Panels */
.main-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 72px);
  position: relative;
}

/* Sidebar Navigation */
.sidebar {
  width: 280px;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  overflow-y: auto;
  z-index: 10;
  transition: all var(--transition-normal);
  position: relative; /* 子要素のドロップゾーンを底部に絶対配置するため追加 */
}

.sidebar-section {
  margin-bottom: 28px;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 8px;
}

.sidebar-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
  letter-spacing: 1.5px;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.menu-item i {
  width: 18px;
  height: 18px;
  color: var(--sidebar-text-muted);
  transition: color var(--transition-fast);
}

.menu-item:hover {
  background-color: var(--sidebar-hover-bg);
  color: var(--sidebar-hover-text);
}

.menu-item:hover i {
  color: var(--sidebar-hover-text);
}

.menu-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.menu-item.active i {
  color: var(--sidebar-active-text);
}

.menu-item .badge {
  margin-left: auto;
  font-size: 11px;
  background-color: var(--sidebar-badge-bg);
  color: var(--sidebar-badge-text);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.menu-item.active .badge {
  background-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 16px;
  box-shadow: 0 4px 10px var(--accent-glow);
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* Main Content Area */
.content-area {
  flex: 1;
  background-color: var(--bg-primary);
  padding: 40px;
  overflow-y: auto;
  transition: background-color var(--transition-normal);
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 20px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.content-filter-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

/* 表示切り替えトグル */
.view-mode-toggle {
  display: flex;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
  flex-shrink: 0;
}

.view-mode-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  width: 34px;
  height: 34px;
  border-radius: calc(var(--radius-md) - 2px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.view-mode-btn:hover {
  color: var(--text-primary);
  background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .view-mode-btn:hover {
  background-color: rgba(0, 0, 0, 0.03);
}

.view-mode-btn.active {
  background-color: var(--bg-secondary);
  color: var(--accent-color);
  box-shadow: var(--shadow-sm);
}

.sort-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.header-sort {
  flex-shrink: 0;
}

.sort-selector select {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.sort-selector select:focus {
  border-color: var(--accent-color);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  padding: 10px 18px;
  border: 1px solid transparent;
  user-select: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
  opacity: 0.95;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--text-muted);
}

.btn-icon {
  background: transparent;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-normal);
}

.btn-icon:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.btn-small-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
  display: flex;
  align-items: center;
}

.btn-small-icon:hover {
  color: var(--text-primary);
}

.btn-small-primary {
  background: var(--accent-gradient);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.btn-danger-text {
  background: transparent;
  border: none;
  color: var(--color-danger);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.btn-danger-text:hover {
  opacity: 0.8;
}

.btn-blur-nav {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255, 0.1);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-full);
}

.btn-blur-nav:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: translateY(-1px);
}

.btn-success {
  background-color: var(--color-success);
  color: white;
}

.btn-success:hover {
  background-color: #059669;
}

.btn-full-width {
  width: 100%;
}

/* Theme Icons */
.theme-icon-light {
  display: none;
}
.theme-icon-dark {
  display: block;
}
[data-theme="dark"] .theme-icon-light {
  display: block;
}
[data-theme="dark"] .theme-icon-dark {
  display: none;
}

/* --- Cards & Grid --- */
.manuals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 28px;
}

/* 画面幅が広いディスプレイや、ズーム縮小が適用された場合でも、
   カバー画像を最も美しく見せるためにグリッドの列数を最大「4列」に制限します */
@media (min-width: 1400px) {
  .manuals-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.manual-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.manual-card:hover {
  transform: translateY(-6px);
  border-color: #f97316; /* オレンジのアクセントボーダー */
  box-shadow: 0 20px 40px -12px rgba(249, 115, 22, 0.18), 0 1px 3px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .manual-card:hover {
  border-color: #a855f7; /* ダークモード時はパープル */
  box-shadow: 0 20px 40px -12px rgba(168, 85, 247, 0.25), 0 1px 3px rgba(0, 0, 0, 0.2);
}

.card-image-wrapper {
  aspect-ratio: 16 / 9;
  position: relative;
  background-color: var(--bg-tertiary);
  overflow: hidden;
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.manual-card:hover .card-image {
  transform: scale(1.05);
}

.card-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
}

.card-steps-count {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background-color: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  color: #ffffff;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  line-height: 1.4;
  margin-bottom: 8px;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 44px; /* Fixed height for clean grid alignment */
}

.card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 38px;
}

.card-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-secondary);
}

.card-date {
  display: flex;
  align-items: center;
  gap: 4px;
}

.card-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 4px;
  background: var(--accent-gradient);
  border-bottom-left-radius: var(--radius-md);
  transition: width var(--transition-normal);
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  max-width: 460px;
  margin: 0 auto;
}

.empty-icon {
  font-size: 54px;
  margin-bottom: 20px;
  animation: bounce 2s ease infinite;
}

.empty-state h2 {
  font-family: var(--font-display);
  font-weight: 700;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 24px;
}

/* --- Modals Overlays (SPA View screens) --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%; /* 100vwから100%に変更し、#appの解像度オートフィット縮小スケールに完全追従させます */
  height: 100%; /* 100vhから100%に変更 */
  background-color: rgba(5, 5, 8, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn var(--transition-normal);
}

/* 1. View Screen Layout */
.viewer-layout {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  animation: slideUp var(--transition-normal);
  color: var(--text-primary);
  position: relative; /* コメントドロワーの基準位置 */
  overflow: hidden;   /* ドロワーが隠れている間は画面外にはみ出させない */
}

.viewer-header {
  height: 72px;
  padding: 0 24px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.viewer-title-area {
  display: flex;
  align-items: center;
  gap: 16px;
}

.viewer-folder-badge {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.viewer-manual-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.viewer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.viewer-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Viewer Steps Navigation Left Panel */
.viewer-steps-sidebar {
  width: 320px;
  border-right: 1px solid var(--sidebar-border);
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
}

.sidebar-header-info {
  padding: 18px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--sidebar-text-muted);
}

.step-counter-badge {
  background-color: var(--sidebar-badge-bg);
  color: var(--sidebar-badge-text);
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.viewer-steps-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-nav-card {
  display: flex;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.step-nav-card:hover {
  background-color: var(--sidebar-hover-bg);
}

.step-nav-card.active {
  background: var(--sidebar-active-bg);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.2);
}

.step-nav-thumb-wrapper {
  width: 70px;
  aspect-ratio: 16 / 9;
  border-radius: 4px;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.1);
  position: relative;
  flex-shrink: 0;
  border: 1px solid var(--sidebar-border);
}

.step-nav-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.step-nav-num-tag {
  position: absolute;
  top: 2px;
  left: 2px;
  font-size: 9px;
  font-weight: 700;
  background-color: rgba(0,0,0,0.6);
  color: white;
  padding: 1px 4px;
  border-radius: 2px;
}

.step-nav-details {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.step-nav-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--sidebar-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step-nav-status {
  font-size: 11px;
  color: var(--sidebar-text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.step-nav-card.active .step-nav-title {
  color: var(--sidebar-active-text);
}

.step-nav-card.active .step-nav-status {
  color: rgba(255, 255, 255, 0.8);
}

.step-nav-card.read .step-nav-status {
  color: var(--color-success);
}

.step-nav-card.active.read .step-nav-status {
  color: #ffffff;
}

/* Viewer Main Presentation Area */
.viewer-main-canvas {
  flex: 1;
  min-height: 0; /* 子要素の高さに合わせて無理に広がらないようにし、レイアウト崩れを防ぐ */
  background-color: #07070a;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 800px;
  max-height: 100%; /* 親の高さ制限を超えて広がらないように調整 */
  aspect-ratio: 4 / 3; /* Standard aspect ratio for visual manual layouts */
  background-color: #121216;
  border-radius: var(--radius-sm);
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-wrapper img,
.canvas-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain; /* Keep original proportions */
  user-select: none;
  will-change: transform; /* 1.5倍ズーム時のパフォーマンス改善 */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.canvas-wrapper img {
  pointer-events: none;
}

.canvas-wrapper video {
  pointer-events: auto;
}

.annotations-overlay-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* 左右に浮かせる丸型のナビゲーションボタン */
.viewer-nav-side-buttons {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  max-width: 900px; /* 画像キャンバス（800px）のすぐ隣に配置するための最大幅制限 */
  display: flex;
  justify-content: space-between;
  padding: 0 16px; /* 画像キャンバスのすぐ隣に浮かせるパディング調整 */
  pointer-events: none; /* 背後の画像をクリックできるようにスルー */
  z-index: 10;
}

.btn-nav-round {
  pointer-events: auto; /* ボタン自体はクリック可能に */
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.btn-nav-round:hover {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  transform: scale(1.08);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-nav-round:disabled {
  opacity: 0.25;
  cursor: not-allowed;
  background-color: rgba(15, 23, 42, 0.2);
  transform: none;
  box-shadow: none;
}

.btn-nav-round i {
  width: 24px;
  height: 24px;
}

/* 画像とテキストパネルの間の独立したドットインジケーターバー */
.viewer-pagination-bar {
  width: 100%;
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 12px 0;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.step-bullets {
  display: flex;
  gap: 4px;
  align-items: center;
}

.bullet-dot {
  width: 28px; /* 判定領域全体の横幅 */
  height: 28px; /* 判定領域全体の縦幅 */
  border-radius: var(--radius-full);
  background-color: transparent;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

/* 実際に見えるドットを疑似要素で描画 */
.bullet-dot::after {
  content: '';
  display: block;
  width: 10px; /* 見た目の玉の大きさ（8pxから10pxに拡大） */
  height: 10px;
  border-radius: var(--radius-full);
  background-color: var(--text-muted); /* テーマ依存のカラーに変更して同化を防ぐ */
  opacity: 0.45; /* 非アクティブ時の明るさ */
  transition: all var(--transition-fast);
}

.bullet-dot:hover::after {
  background-color: var(--text-primary);
  opacity: 0.9;
  transform: scale(1.1);
}

.bullet-dot.active {
  width: 44px; /* アクティブ時の判定領域 */
}

.bullet-dot.active::after {
  background-color: var(--accent-color);
  width: 28px; /* アクティブ時の見た目の横幅（24pxから28pxに拡大） */
  height: 10px;
}

/* Viewer Details Text Right Panel */
/* 中央の画像とテキストを配置する縦型カラムコンテナ */
.viewer-center-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-primary);
}

.viewer-instruction-panel {
  width: 100%;
  height: 240px; /* 少し高さを増やして文字サイズ拡大に対応 */
  flex-shrink: 0;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: row; /* 横並びにする */
  align-items: center;
  justify-content: space-between;
  padding: 24px 36px;
  gap: 36px;
}

.instruction-header {
  flex: 0 0 320px; /* タイトル拡大に合わせて横幅を拡張 */
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.step-num-large {
  font-family: var(--font-display);
  font-size: 14px; /* 13pxから14pxに拡大 */
  font-weight: 800;
  color: var(--accent-color);
  letter-spacing: 2px;
  display: block;
  margin-bottom: 6px;
}

.step-title-text {
  font-family: var(--font-display);
  font-size: 24px; /* 20pxから24pxに拡大（Teachme Bizに近接） */
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.instruction-body {
  flex: 1; /* 詳細説明が中央の横幅をすべて使う */
  height: 100%;
  overflow-y: auto;
  padding-right: 8px;
}

.step-desc-text {
  font-size: 16px; /* 14pxから16pxに拡大（現場での視認性を最優先） */
  color: var(--text-primary); /* より高いコントラストに変更 */
  line-height: 1.7; /* 行間を広げて読みやすさを向上 */
  white-space: pre-wrap;
  padding-bottom: 32px; /* スクロールした際に最下部が見切れないように十分な余白を確保 */
}

.instruction-footer {
  flex: 0 0 420px; /* 横幅を拡張して2つのボタンが並ぶようにする */
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ビューワー下部の読了ボタンのサイズ調整 */
.instruction-footer .btn {
  font-size: 15px;
  padding: 12px 24px;
  width: 100%;
}

.btn-audio-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  min-width: 140px;
  font-size: 15px;
  padding: 12px 24px;
}

/* 2. Editor Layout Overrides */
.editor-layout {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  animation: slideUp var(--transition-normal);
  color: var(--text-primary);
}

.editor-header {
  height: 72px;
  padding: 0 24px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.editor-screen-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.editor-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.editor-steps-sidebar {
  width: 280px;
  border-right: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  display: flex;
  flex-direction: column;
}

.btn-small-primary {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

.editor-steps-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.step-edit-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
}

.step-edit-card:hover {
  border-color: var(--text-muted);
}

.step-edit-card.active {
  background-color: var(--accent-light);
  border-color: var(--accent-color);
}

.step-drag-handle {
  color: var(--text-muted);
  cursor: grab;
  display: flex;
  align-items: center;
}

.step-edit-card.dragging {
  opacity: 0.4;
  border: 1px dashed var(--accent-color);
}

.step-edit-card.drag-over {
  border-top: 2px solid var(--accent-color);
  background-color: rgba(99, 102, 241, 0.05);
}

.step-edit-title {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.editor-main-panel {
  flex: 1;
  padding: 32px;
  overflow-y: auto;
}

.editor-form-card, .editor-step-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px;
  box-shadow: var(--card-shadow);
  max-width: 1100px;
  margin: 0 auto;
}

.form-section-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 12px;
}

.form-group {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.required {
  color: var(--color-danger);
}

.form-group input, .form-group select, .form-group textarea {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent-color);
  background-color: var(--bg-secondary);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Step Edit Form Card */
.step-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
}

.edit-step-indicator {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--accent-color);
  letter-spacing: 1px;
}

.editor-step-columns {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 32px;
}

/* Image Annotator dropzone styles */
.step-image-editor {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.image-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.image-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.image-dropzone {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-tertiary);
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-fast);
}

.image-dropzone.dragover {
  border-color: var(--accent-color);
  background-color: var(--accent-light);
}

.dropzone-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.placeholder-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
}

.dropzone-text {
  font-size: 13px;
  color: var(--text-muted);
}

/* Active annotation workspace */
.annotation-workspace {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #121216;
}

.annotation-workspace img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
}

.drawing-surface {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  z-index: 10;
}

/* Annotation Tools styling */
.annotation-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}

.tool-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.divider {
  width: 1px;
  height: 20px;
  background-color: var(--border-color);
}

.tool-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.tool-btn:hover {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

.tool-btn.active {
  background-color: var(--accent-color);
  color: white;
  border-color: var(--accent-color);
}

.tool-btn i {
  width: 16px;
  height: 16px;
}

.color-picker-row {
  display: flex;
  gap: 8px;
}

.color-dot {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: transform var(--transition-fast);
  border: 2px solid transparent;
}

.color-dot:hover {
  transform: scale(1.2);
}

.color-dot.active {
  transform: scale(1.2);
  border-color: var(--text-primary);
}

.color-dot.red { background-color: #ff3b30; }
.color-dot.blue { background-color: #007aff; }
.color-dot.green { background-color: #34c759; }
.color-dot.yellow { background-color: #ffcc00; }

.ml-auto {
  margin-left: auto;
}

/* 3. Importer Modal */
.modal-card {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  animation: scaleIn var(--transition-normal);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-title h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
}

.modal-title-icon {
  color: var(--accent-color);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.modal-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

.import-help-box {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.import-help-box h4 {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.import-help-box p {
  font-size: 12px;
  color: var(--text-secondary);
}

.modal-footer {
  padding: 16px 24px;
  background-color: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* --- SVG Drawing styles --- */
.annotation-arrow {
  stroke-width: 5px;
  fill: none;
}

.annotation-rect {
  stroke-width: 4px;
  fill: none;
}

.annotation-circle {
  stroke-width: 4px;
  fill: none;
}

.annotation-text {
  font-family: var(--font-display), sans-serif;
  font-weight: 800;
  font-size: 24px;
  text-anchor: middle;
  dominant-baseline: middle;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--text-primary);
  color: var(--bg-secondary);
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  z-index: 2000;
  animation: slideUpFade 0.3s var(--transition-normal);
  display: flex;
  align-items: center;
  gap: 10px;
}

/* --- Animations --- */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes slideUpFade {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* --- Responsive Adjustments --- */
@media (max-width: 1024px) {
  .viewer-content {
    flex-direction: column;
  }
  .viewer-steps-sidebar {
    width: 100%;
    height: 140px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }
  .viewer-steps-list {
    flex-direction: row;
    height: 100%;
    padding: 10px;
  }
  .step-nav-card {
    flex-direction: column;
    width: 120px;
    flex-shrink: 0;
    align-items: center;
    padding: 6px;
    text-align: center;
  }
  .step-nav-details {
    width: 100%;
  }
  .step-nav-status {
    display: none;
  }
  .viewer-instruction-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
    height: auto;
    padding: 20px;
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .viewer-instruction-panel .instruction-header,
  .viewer-instruction-panel .instruction-body,
  .viewer-instruction-panel .instruction-footer {
    flex: none;
    width: 100%;
  }
  .editor-step-columns {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: 0 16px;
  }
  .header-search-bar {
    display: none; /* Hide search bar on mobile headers */
  }
  .sort-selector.header-sort {
    display: none; /* Hide sort selector on mobile headers */
  }
  .view-mode-toggle {
    display: none; /* Hide view mode toggle on mobile headers */
  }
  .sidebar {
    display: none; /* Collapsed on mobile by default */
  }
  .content-area {
    padding: 20px;
  }
  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}

/* ==========================================================================
   Image Zoom & Fullscreen Preview Styles
   ========================================================================== */

/* Zoom-in cursor on normal canvas-wrapper to indicate clickability */
.canvas-wrapper {
  cursor: zoom-in;
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
  will-change: transform; /* GPUレンダリングの最適化 */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* Fullscreen zoom active style */
.canvas-wrapper.fullscreen-active {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 95vw;
  height: 71.25vw; /* 4:3 standard aspect ratio */
  max-height: 95vh;
  max-width: 126.67vh; /* 4:3 aspect ratio ceiling */
  z-index: 2000; /* Placed above viewer-modal (z-index 1000) */
  background-color: #0c0c10;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  cursor: zoom-out;
  overflow: hidden;
  animation: zoomInNormal var(--transition-normal);
}

/* Semi-transparent dark background mask */
.canvas-wrapper.fullscreen-active::before {
  content: '';
  position: fixed;
  top: -100vh;
  left: -100vw;
  width: 300vw;
  height: 300vh;
  background: rgba(5, 5, 8, 0.96); /* 透過度をわずかに下げてボケなしでも背景を綺麗に遮断 */
  z-index: -1;
  cursor: zoom-out;
  animation: fadeInOverlay var(--transition-normal);
}

@keyframes zoomInNormal {
  from {
    transform: translate(-50%, -50%) scale(0.9);
    opacity: 0;
  }
  to {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
}

@keyframes fadeInOverlay {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* 動画サムネイルのプレビューデザイン */
.step-nav-thumb-wrapper.video-step {
  background-color: #000;
  border-color: rgba(99, 102, 241, 0.3) !important;
}

.video-thumb-preview {
  width: 100%;
  height: 100%;
  object-fit: cover; /* サムネイル枠いっぱいにトリミング表示 */
  background-color: #000;
  display: block;
}

/* ビデオサムネイル用再生アイコンオーバーレイ */
.video-thumb-icon-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.35); /* プレビューを少し暗くして再生ボタンを際立たせる */
  z-index: 2;
  transition: background-color var(--transition-fast);
}

.video-thumb-icon-overlay:hover {
  background-color: rgba(0, 0, 0, 0.15);
}

.video-play-mini-icon {
  width: 16px !important;
  height: 16px !important;
  color: white;
  fill: white; /* 三角矢印の中身を白く塗りつぶす */
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
}

/* 動画音声切り替えボタン（フローティング） */
.btn-video-audio-toggle {
  position: absolute;
  bottom: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background-color: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  z-index: 20;
}

.btn-video-audio-toggle:hover {
  background-color: var(--accent-color);
  border-color: var(--accent-color);
  transform: scale(1.08);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-video-audio-toggle i {
  width: 20px;
  height: 20px;
}

/* プレミアムテーマ切り替えスライドスイッチ */
.theme-toggle-switch {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  width: 72px;
  height: 38px;
  padding: 3px;
  cursor: pointer;
  position: relative;
  transition: all var(--transition-normal);
  overflow: hidden;
  display: flex;
  align-items: center;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-toggle-switch:hover {
  border-color: var(--accent-color);
  box-shadow: 0 0 12px var(--accent-glow);
}

.switch-track {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.switch-icon {
  color: var(--text-muted);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-normal);
}

.switch-icon i {
  width: 18px;
  height: 18px;
}

/* テーマ連動でアイコンカラーを設定 */
[data-theme="dark"] .icon-moon {
  color: #fbbf24; /* 鮮やかなイエロー */
}

[data-theme="light"] .icon-sun {
  color: #f97316; /* 鮮やかなオレンジ */
}

/* スイッチのツマミ */
.switch-thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  background: var(--accent-gradient);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform var(--transition-normal);
  z-index: 1;
}

/* ダークテーマ時は右へスライド */
[data-theme="dark"] .switch-thumb {
  transform: translateX(34px);
}

/* フォルダツリー構造のプレミアムスタイル */
.folder-parent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: 600;
  font-size: 13px;
  color: var(--sidebar-text-primary);
  margin-bottom: 2px;
}

.folder-parent-item:hover {
  background-color: var(--sidebar-hover-bg);
}

.folder-parent-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.folder-parent-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.folder-parent-left span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-chevron {
  width: 14px;
  height: 14px;
  color: var(--sidebar-text-muted);
  transition: transform var(--transition-normal);
  cursor: pointer;
}

.folder-chevron.expanded {
  transform: rotate(90deg);
  color: var(--sidebar-text-primary);
}

/* 子フォルダコンテナ */
.folder-children-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-left: 12px; /* 親に対してインデント */
  margin-top: 2px;
  margin-bottom: 8px;
  border-left: 1px dashed var(--sidebar-border); /* ツリーの点線 */
  margin-left: 18px; /* chevronとfolderアイコンの中間 */
}

.folder-child-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 12px;
  color: var(--sidebar-text-secondary);
}

.folder-child-item:hover {
  background-color: var(--sidebar-hover-bg);
  color: var(--sidebar-hover-text);
}

.folder-child-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.folder-child-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.folder-child-left span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- リスト表示用追加クラスの初期状態（グリッド時は非表示） --- */
.list-folder-badge,
.card-steps-count-text {
  display: none;
}

/* --- リスト表示モード (List View Mode) --- */
.manuals-grid.list-view-active {
  display: flex !important;
  flex-direction: column;
  align-items: stretch; /* グリッド既定の align-items:center を打ち消し、各カードを全幅に伸ばす（中身幅での横伸び防止） */
  gap: 16px;
}

.manuals-grid.list-view-active .manual-card {
  flex-direction: row;
  height: auto;
  align-items: center;
  padding: 12px 20px;
  gap: 20px;
  min-height: 80px;
}

/* ホバー時の横滑りエフェクト */
.manuals-grid.list-view-active .manual-card:hover {
  transform: translateX(6px);
  border-color: #f97316; /* オレンジのアクセントボーダー */
  box-shadow: 0 10px 25px -10px rgba(249, 115, 22, 0.18), var(--card-shadow);
}

[data-theme="dark"] .manuals-grid.list-view-active .manual-card:hover {
  border-color: #a855f7; /* ダークモード時はパープル */
  box-shadow: 0 10px 25px -10px rgba(168, 85, 247, 0.25), var(--card-shadow);
}

.manuals-grid.list-view-active .card-image-wrapper {
  width: 110px;
  height: 62px;
  aspect-ratio: 16 / 9;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* リスト表示時は画像の中のバッジとステップ数を非表示に */
.manuals-grid.list-view-active .card-image-wrapper .card-badge,
.manuals-grid.list-view-active .card-image-wrapper .card-steps-count {
  display: none;
}

.manuals-grid.list-view-active .card-content {
  padding: 0;
  flex: 1;
  min-width: 0; /* nowrapの説明文でカードが横に伸びるのを防ぐ（省略表示を効かせる） */
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.manuals-grid.list-view-active .card-main-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.manuals-grid.list-view-active .card-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* リスト表示時のみタイトル横に表示するフォルダバッジ */
.manuals-grid.list-view-active .list-folder-badge {
  display: inline-block;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.manuals-grid.list-view-active .card-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 0;
  height: auto;
  line-height: 1.4;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  max-width: 75%;
}

.manuals-grid.list-view-active .card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 0;
  height: auto;
  -webkit-line-clamp: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.manuals-grid.list-view-active .card-footer {
  margin-top: 0;
  border-top: none;
  padding-top: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  justify-content: flex-end;
  color: var(--text-secondary);
  font-size: 11px;
  flex-shrink: 0;
}

/* リスト表示時のみフッターに表示するステップ数 */
.manuals-grid.list-view-active .card-steps-count-text {
  display: flex;
  align-items: center;
  gap: 4px;
  background-color: rgba(14, 165, 233, 0.1);
  color: var(--accent-color);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

[data-theme="dark"] .manuals-grid.list-view-active .card-steps-count-text {
  background-color: rgba(56, 189, 248, 0.15);
}

.manuals-grid.list-view-active .card-progress-bar {
  height: 3px;
  bottom: 0;
}

/* レスポンシブ対応：中画面（タブレット以下）でリスト表示を最適化 */
@media (max-width: 900px) {
  .manuals-grid.list-view-active .card-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .manuals-grid.list-view-active .card-footer {
    width: 100%;
    justify-content: flex-start;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    margin-top: 4px;
  }
}

/* レスポンシブ対応：小画面（スマホ）ではリスト表示を実質グリッド風にして崩れを防ぐ */
@media (max-width: 600px) {
  .manuals-grid.list-view-active .manual-card {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    gap: 12px;
  }
  
  .manuals-grid.list-view-active .card-image-wrapper {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  
  .manuals-grid.list-view-active .card-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  
  .manuals-grid.list-view-active .list-folder-badge {
    margin-bottom: 4px;
  }
}

/* カンバスが全画面ズームのとき、左右のナビゲーションボタンを最前面かつ拡大画像の左右端のすぐ外側に配置 */
.canvas-wrapper.fullscreen-active ~ .viewer-nav-side-buttons {
  position: fixed;
  z-index: 2100;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  max-width: min(calc(126.67vh + 110px), 98vw);
  padding: 0 10px;
}
.canvas-wrapper.fullscreen-active ~ .viewer-nav-side-buttons .btn-nav-round {
  width: 56px;
  height: 56px;
  background-color: rgba(15, 23, 42, 0.85); /* 全画面時はより視認しやすく少し濃くする */
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

/* 画面幅が中程度（1200px以下 / PC画面の半分分割など）の時のヘッダー崩れ・検索窓つぶれ対策 */
@media (max-width: 1200px) {
  .app-header {
    padding: 0 16px;
    height: 64px;
  }
  .main-container {
    height: calc(100vh - 64px);
  }
  .header-left {
    gap: 16px;
  }
  .header-right {
    gap: 8px;
  }
  .header-search-bar {
    max-width: 400px;
    min-width: 250px;
    flex: 1;
  }
  .header-right .btn span {
    display: none;
  }
  .header-right .btn {
    padding: 8px; /* icon only */
  }
  /* 並び替えのラベル「並び替え:」を非表示にして省スペース化 */
  .sort-selector.header-sort label {
    display: none;
  }
  .sort-selector.header-sort select {
    padding: 6px 28px 6px 12px;
    font-size: 13px;
  }
  
  /* ボタンテキストを非表示にして丸型アイコン化し、はみ出しと改行を完全に防ぐ */
  .header-right .btn {
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: var(--radius-full);
    justify-content: center;
    gap: 0;
  }
  .header-right .btn span {
    display: none; /* テキストを非表示 */
  }
  .header-right .btn i {
    width: 18px;
    height: 18px;
    margin: 0;
  }
  
  /* テーマ切り替えとグリッド切り替えのサイズ調整 */
  .theme-toggle-switch {
    width: 60px;
    height: 34px;
  }
  .view-mode-btn {
    width: 30px;
    height: 30px;
  }
}

/* ==========================================================================
   Zoom Caption Overlay & Visibility Toggle Styles
   ========================================================================== */

/* 拡大時（ズーム時）の字幕（キャプション）コンテナ */
/* 拡大時（ズーム時）の字幕（キャプション）コンテナ - TikTok風グラデーションオーバーレイ */
.zoom-caption-container {
  display: none; /* 通常時は非表示 */
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 80px 40px 40px 40px; /* 上部にフェードを考慮した広い余白 */
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.4) 60%, rgba(0, 0, 0, 0) 100%);
  border-top: none;
  box-sizing: border-box;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  z-index: 10;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none; /* 下の動画の操作を邪魔しないようにする */
}

/* ズーム中（fullscreen-active）のみ display: flex で表示 */
.canvas-wrapper.fullscreen-active .zoom-caption-container {
  display: flex;
}

/* SNSヘッダー情報 */
.zoom-caption-sns-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  pointer-events: auto; /* インタラクティブ可能にする */
  transition: opacity 0.3s ease;
}

.zoom-caption-author {
  color: #ffffff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.zoom-caption-hashtags {
  color: #38bdf8; /* 明るいブルーでハッシュタグを演出 */
  font-size: 14px;
  font-weight: 600;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* キャプション本文のボディ */
.zoom-caption-body {
  max-width: 650px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  pointer-events: auto; /* 本文の選択や「もっと見る」ボタンのために必要 */
  transition: opacity 0.3s ease;
}

/* 字幕テキスト */
.zoom-caption-text {
  color: rgba(255, 255, 255, 0.95);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.6;
  text-align: left;
  width: 100%;
  max-height: 72px; /* 初期値: 3行分程度の高さ */
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: pre-wrap; /* 改行や空白を維持 */
  word-break: break-word;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* 全文展開（expanded）時のスタイル */
.zoom-caption-text.expanded {
  max-height: none !important; /* 制限なくすべての文字を表示 */
  overflow-y: visible !important;
}

/* アコーディオン切り替えボタン */
.zoom-more-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0 0 0;
  transition: color 0.2s ease;
  outline: none;
  font-family: inherit;
}

.zoom-more-btn:hover {
  color: #ffffff;
}

/* 右下アクションボタンエリア */
.zoom-caption-actions {
  position: absolute;
  right: 40px;
  bottom: 40px;
  display: flex;
  gap: 12px;
  pointer-events: auto;
  z-index: 12;
}

/* クロップ（余白カット拡大）トグルボタン */
.zoom-crop-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.zoom-crop-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

.zoom-crop-btn:active {
  transform: scale(0.95);
}

/* 表示・非表示トグルボタン */
.zoom-caption-toggle-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.zoom-caption-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.08);
}

.zoom-caption-toggle-btn:active {
  transform: scale(0.95);
}

/* 非表示（キャプション非表示）状態スタイル */
.zoom-caption-container.caption-hidden {
  background: transparent;
  pointer-events: none;
}

.zoom-caption-container.caption-hidden .zoom-caption-sns-header,
.zoom-caption-container.caption-hidden .zoom-caption-body {
  opacity: 0;
  pointer-events: none;
}

.zoom-caption-container.caption-hidden .zoom-crop-btn,
.zoom-caption-container.caption-hidden .zoom-caption-toggle-btn {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.15);
  pointer-events: auto;
}

/* 太いデフォルトスクロールバーを排除し、スマートで細いデザインに統一 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* 縦幅の低い液晶ディスプレイ（古いPCモニターやノートPC）向けのレスポンシブ調整 */
@media (max-height: 850px) {
  .viewer-instruction-panel {
    height: 160px !important;
    padding: 12px 24px !important;
    gap: 20px !important;
  }
  .instruction-header {
    flex: 0 0 220px !important;
  }
  .instruction-title {
    font-size: 20px !important;
  }
  .instruction-body-scroll {
    font-size: 14px !important;
  }
  .viewer-main-canvas {
    padding: 12px !important;
  }
  .btn-nav-round {
    width: 44px !important;
    height: 44px !important;
  }
}

/* ==========================================================================
   Multi-level Folder Tree & Drag & Drop Styles
   ========================================================================== */

/* フォルダアイテム全体のホバー・アクティブ移行 */
.folder-parent-item {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  user-select: none;
}

/* 右側レイアウトとホバー時の編集アクション */
.folder-parent-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.folder-actions-hover {
  display: none;
  align-items: center;
  gap: 4px;
}

.folder-parent-item:hover .folder-actions-hover {
  display: flex;
}

.btn-small-icon {
  background: none;
  border: none;
  color: var(--sidebar-text-muted) !important;
  padding: 2px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.btn-small-icon:hover {
  background-color: var(--sidebar-hover-bg) !important;
  color: var(--sidebar-hover-text) !important;
}

.btn-delete-hover:hover {
  background-color: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
}

/* ドラッグ＆ドロップ視覚エフェクト */
.folder-parent-item.dragging {
  opacity: 0.4;
  border: 1px dashed var(--accent-color) !important;
}

.folder-parent-item.drag-over {
  background-color: rgba(99, 102, 241, 0.15) !important;
  outline: 2px dashed var(--accent-color) !important;
  outline-offset: -2px;
}

/* マニュアルカードドラッグ中スタイル */
.manual-card.dragging {
  opacity: 0.4;
  transform: scale(0.98);
  border: 1px dashed var(--accent-color) !important;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3) !important;
}

/* フォルダ項目の子要素がドラッグイベントの判定を邪魔するのを防ぐ */
.folder-parent-item * {
  pointer-events: none;
}
/* ただし、右側の編集・削除ボタンなどのアクションはクリック可能にする */
.folder-parent-item button,
.folder-parent-item a,
.folder-parent-item .folder-parent-right,
.folder-parent-item .folder-parent-right * {
  pointer-events: auto;
}

/* フォルダリストの下部に十分なドロップ余白を設ける */
#folder-list {
  min-height: 250px; /* ドロップ用の最小高さを十分に確保 */
  padding-bottom: 60px; /* 余白へ落としやすくします */
}

/* フォルダセクションのタイトル行がドラッグオーバーされた時のエフェクト */
.sidebar-title-row.drag-over {
  background-color: rgba(99, 102, 241, 0.15) !important;
  outline: 2px dashed var(--accent-color) !important;
  border-radius: var(--radius-sm);
}

/* フォルダタイトルヘッダーの子要素がドラッグイベントの判定を邪魔するのを防ぐ */
.sidebar-title-row * {
  pointer-events: none;
}
/* ただし、追加ボタンはクリックできるようにする */
.sidebar-title-row button,
.sidebar-title-row button * {
  pointer-events: auto;
}

/* 一時的に出現するルート移動用のドラッグドロップゾーン */
.root-drop-zone {
  display: flex;
  position: fixed; /* 親要素のスクロールにクリップされないよう画面固定にします */
  bottom: 110px; /* フッターやプロフィールの上の位置に固定 */
  left: 20px; /* サイドバーの幅280pxの余白内にフィットさせます */
  width: 240px; /* コンテンツ幅に合わせて固定 */
  z-index: 100;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 12px;
  border: 2px dashed var(--accent-color) !important;
  border-radius: var(--radius-sm);
  background-color: var(--sidebar-bg); /* 背景を隠すために背景色を指定 */
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6); /* 浮かせるシャドウ */
  color: var(--accent-color);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  animation: slideUp var(--transition-fast) ease-in-out;
  transition: all var(--transition-fast) ease-in-out;
  pointer-events: auto;
}

.root-drop-zone.drag-over {
  background-color: rgba(99, 102, 241, 0.22) !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
  transform: scale(1.02);
}

.root-drop-zone * {
  pointer-events: none; /* ドロップイベント阻害を防ぐ */
}

/* --- AI Features UI Styles --- */

/* AIアシストボタンを含むラベル行 */
.form-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

/* AIアシストボタンのデザイン（きらめくグラデーション境界線と微細ホバー） */
.btn-ai-assist {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(168, 85, 247, 0.1) 100%);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: var(--radius-sm);
  color: #a855f7;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-ai-assist:hover {
  background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
  transform: translateY(-1px);
}

.btn-ai-assist i {
  width: 12px;
  height: 12px;
}

/* AI翻訳ボタンのコンテナとドロップダウン */
.ai-translation-container {
  position: relative;
  display: inline-block;
}

.btn-ai {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%) !important;
  color: #ffffff !important;
  border: none !important;
}

.btn-ai:hover {
  box-shadow: 0 0 15px rgba(124, 58, 237, 0.5) !important;
  transform: translateY(-1px);
}

/* AIドロップダウンメニュー (翻訳用) */
.ai-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  width: 220px;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  padding: 6px 0;
  animation: slideUp var(--transition-fast) ease-out;
}

.ai-dropdown-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 8px 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 4px;
}

.ai-dropdown-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-dropdown-item:hover {
  background-color: rgba(168, 85, 247, 0.08);
  color: #a855f7;
  padding-left: 20px;
}

/* AIポップアップメニュー (文章アシスト用、動的浮動配置) */
.ai-popup-menu {
  position: fixed;
  background-color: #1e293b; /* Sleek Dark Theme */
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  z-index: 10000;
  width: 250px;
  padding: 8px 0;
  animation: fadeIn var(--transition-fast) ease-out;
}

.ai-menu-header {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  padding: 6px 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 4px;
}

.ai-menu-item {
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.ai-menu-item:hover {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%);
  color: #d8b4fe;
  padding-left: 20px;
}

.ai-menu-item i {
  color: #a855f7;
  width: 14px;
  height: 14px;
}

/* AIローディング画面 */
.ai-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.85);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.3s ease-out;
}

.ai-loading-content {
  text-align: center;
  color: #ffffff;
  padding: 30px;
  border-radius: var(--radius-lg);
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(168, 85, 247, 0.3);
  box-shadow: 0 20px 40px rgba(0,0,0,0.6);
  max-width: 320px;
  width: 90%;
}

.ai-sparkles-anim {
  margin-bottom: 20px;
  display: inline-block;
}

.sparkle-lg {
  width: 48px;
  height: 48px;
  color: #a855f7;
  animation: pulseRotate 2s infinite ease-in-out;
}

#ai-loading-message {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 15px;
  color: #f1f5f9;
}

/* きらめくローディングバー */
.ai-loading-bar-container {
  height: 4px;
  width: 100%;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.ai-loading-bar {
  height: 100%;
  width: 45%;
  background: linear-gradient(90deg, #6366f1, #a855f7, #6366f1);
  background-size: 200% 100%;
  border-radius: 2px;
  animation: loadingSlide 1.5s infinite linear, shimmer 2s infinite linear;
}

/* アニメーション定義 */
@keyframes pulseRotate {
  0% {
    transform: scale(1) rotate(0deg);
    filter: drop-shadow(0 0 5px rgba(168, 85, 247, 0.4));
  }
  50% {
    transform: scale(1.15) rotate(180deg);
    filter: drop-shadow(0 0 15px rgba(168, 85, 247, 0.8));
  }
  100% {
    transform: scale(1) rotate(360deg);
    filter: drop-shadow(0 0 5px rgba(168, 85, 247, 0.4));
  }
}

@keyframes loadingSlide {
  0% {
    transform: translateX(-150%);
  }
  50% {
    transform: translateX(100%);
  }
  100% {
    transform: translateX(250%);
  }
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* --- Bulk Action & Duplicate CSS Styles --- */

/* カード内の複製ボタン */
.manual-card {
  position: relative; /* ボタン絶対配置の基準 */
}

.btn-card-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-fast) ease-in-out;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn-card-copy:hover {
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #ffffff;
  border-color: transparent;
  transform: scale(1.1);
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.5);
}

.manual-card:hover .btn-card-copy {
  opacity: 1;
  visibility: visible;
}

.btn-card-copy i {
  width: 14px;
  height: 14px;
}

/* カード内のチェックボックス */
.card-select-checkbox-wrapper {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  display: none;
  background-color: rgba(30, 41, 59, 0.85);
  border-radius: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* 複数選択モードがONの時 */
.bulk-select-active .card-select-checkbox-wrapper {
  display: block;
  animation: fadeIn var(--transition-fast);
}

.card-select-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #a855f7;
  display: block;
}

/* フローティング一括操作バー */
.bulk-action-bar {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid rgba(168, 85, 247, 0.3);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  margin-bottom: 20px;
  z-index: 100;
  animation: slideDown 0.3s ease-out;
}

.bulk-action-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text-primary);
}

.bulk-action-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* --- Undo / Redo CSS Styles --- */
.btn-icon-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast) ease-in-out;
}

.btn-icon-circle:hover:not(:disabled) {
  background-color: rgba(168, 85, 247, 0.08);
  border-color: rgba(168, 85, 247, 0.4);
  color: #a855f7;
  transform: translateY(-1px);
}

.btn-icon-circle:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: var(--border-color);
  color: var(--text-muted);
}

/* 複数選択モードで選択されたカードの強調スタイル */
.manual-card.selected {
  border-color: #a855f7 !important;
  box-shadow: 0 0 0 3px #a855f7, 0 8px 30px rgba(168, 85, 247, 0.35) !important;
  background-color: rgba(168, 85, 247, 0.05) !important;
  transform: translateY(-4px) !important;
}

/* エディタアクションコンテナの崩れ防止とボタン間隔調整 */
.editor-actions {
  display: flex;
  align-items: center;
  gap: 10px; /* ボタン同士の間隔 */
  flex-shrink: 0; /* 絶対に潰れないようにする */
}

/* 同化しがちなセカンダリボタンの境界線コントラストと背景色の調整 */
.editor-actions .btn-secondary,
#editor-duplicate-btn {
  background-color: var(--bg-primary) !important; /* ヘッダーの背景色と変えて視認性を向上 */
  border-color: rgba(0, 0, 0, 0.15) !important;
}

[data-theme="dark"] .editor-actions .btn-secondary,
[data-theme="dark"] #editor-duplicate-btn {
  background-color: var(--bg-tertiary) !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
}

.editor-actions .btn-secondary:hover,
#editor-duplicate-btn:hover {
  background-color: var(--bg-tertiary) !important;
  border-color: var(--text-muted) !important;
}

/* Undo / Redo ボタンの調整 */
.editor-actions .btn-icon-circle {
  border-color: rgba(0, 0, 0, 0.15) !important;
}

[data-theme="dark"] .editor-actions .btn-icon-circle {
  border-color: rgba(255, 255, 255, 0.15) !important;
}

/* --- Viewer Language Dropdown Styles --- */
.viewer-language-container {
  position: relative;
}

.viewer-lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 210px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  animation: fadeInDown 0.2s ease-out;
}

.lang-dropdown-header {
  padding: 8px 16px 10px 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 4px;
}

.viewer-lang-item {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition-fast) ease-in-out;
}

.viewer-lang-item:hover {
  background-color: rgba(168, 85, 247, 0.08);
  color: #a855f7;
}

.viewer-lang-item.active {
  background-color: rgba(168, 85, 247, 0.12);
  color: #a855f7;
  font-weight: 700;
}

.viewer-lang-item.active::after {
  content: "✓";
  font-size: 12px;
  color: #a855f7;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Global Language Dropdown Styles --- */
.global-language-container {
  position: relative;
}

.global-lang-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 210px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  z-index: 200;
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  animation: fadeInDown 0.2s ease-out;
}

.global-lang-item {
  width: 100%;
  padding: 10px 16px;
  background: transparent;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition-fast) ease-in-out;
}

.global-lang-item:hover {
  background-color: rgba(168, 85, 247, 0.08);
  color: #a855f7;
}

.global-lang-item.active {
  background-color: rgba(168, 85, 247, 0.12);
  color: #a855f7;
  font-weight: 700;
}

.global-lang-item.active::after {
  content: "✓";
  font-size: 12px;
  color: #a855f7;
}

/* ================================================================
   ステップ複数選択 UI
   ================================================================ */

/* チェックボックス: 通常時は半透明、ホバー/選択時に完全表示 */
.step-select-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 15px;
  height: 15px;
  min-width: 15px;
  border: 2px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  position: relative;
  margin-right: 2px;
  opacity: 0.4;
  transition: opacity 0.15s, border-color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.step-edit-card:hover .step-select-checkbox,
.step-select-checkbox:checked {
  opacity: 1;
}

.step-select-checkbox:checked {
  background: var(--accent-color, #f97316);
  border-color: var(--accent-color, #f97316);
}

.step-select-checkbox:checked::after {
  content: "";
  display: block;
  width: 4px;
  height: 8px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(1px, -1px);
  position: absolute;
  left: 3px;
  top: 0px;
}

/* 選択済みステップカードの強調ハイライト */
.step-edit-card.step-selected {
  background: linear-gradient(90deg, rgba(249,115,22,0.12), rgba(249,115,22,0.06)) !important;
  border-left: 3px solid var(--accent-color, #f97316) !important;
  box-shadow: inset 0 0 0 1px rgba(249,115,22,0.25);
}

/* 選択中アクションバー */
#step-select-action-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 10px;
  background: linear-gradient(135deg, rgba(249,115,22,0.15), rgba(249,115,22,0.08));
  border: 1px solid rgba(249,115,22,0.35);
  border-radius: 8px;
  margin: 4px 8px 2px;
  animation: slideDownFade 0.18s ease;
}

#step-select-count-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-color, #f97316);
  white-space: nowrap;
}

.step-select-bar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.step-select-bar-actions button {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid rgba(100,100,100,0.25);
  background: rgba(255,255,255,0.7);
  color: var(--text-secondary, #666);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.step-select-bar-actions button:hover {
  background: rgba(255,255,255,0.95);
  border-color: rgba(100,100,100,0.4);
  transform: translateY(-1px);
}

.step-select-bar-actions button svg {
  width: 11px;
  height: 11px;
}

/* まとめて削除ボタン: 赤系アクセント */
.btn-step-bulk-delete {
  background: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: #fff !important;
  border-color: transparent !important;
}

.btn-step-bulk-delete:hover {
  background: linear-gradient(135deg, #f87171, #ef4444) !important;
  box-shadow: 0 3px 8px rgba(239,68,68,0.4);
}

@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ================================================================
   ダークモード 階調・メリハリ強化
   main < sidebar < header の3段階輝度設計
   ================================================================ */

/* ヘッダー: 最も明るいレイヤー + 下側に強めのシャドウで浮き上がり感 */
[data-theme="dark"] .app-header {
  background: rgba(26, 30, 50, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 2px 0 rgba(255,255,255,0.04), 0 4px 24px rgba(0,0,0,0.45);
}

/* サイドバー: ヘッダーより少し暗く、メインより明るい */
[data-theme="dark"] .sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 2px 0 16px rgba(0,0,0,0.35);
}

/* メインコンテンツエリア: 最も暗いベースレイヤー */
[data-theme="dark"] .content-area {
  background: var(--bg-primary);
}

/* カード: bg-primary より一段浮き上がる + 縁を強調 */
[data-theme="dark"] .manual-card {
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.07);
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 1px 3px rgba(0,0,0,0.25);
}

[data-theme="dark"] .manual-card:hover {
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 8px 28px rgba(0,0,0,0.55), 0 0 0 1px rgba(99,102,241,0.2);
  transform: translateY(-3px);
}

/* セクション見出し・テキスト */
[data-theme="dark"] .section-title {
  color: var(--text-primary);
}

[data-theme="dark"] .section-subtitle {
  color: var(--text-secondary);
}

/* フォルダ・サイドバーの区切り線 */
[data-theme="dark"] .sidebar-section-label {
  color: var(--sidebar-text-muted);
  border-top: 1px solid rgba(255,255,255,0.05);
}

/* 検索バー */
[data-theme="dark"] .search-input-wrapper {
  background: rgba(13, 15, 24, 0.7);
  border-color: rgba(255,255,255,0.10);
}

/* ページ全体の bg をダークテーマに合わせる */
[data-theme="dark"] body {
  background: var(--bg-primary);
}

/* ============================================================
   印刷 / PDF出力（#print-container は印刷時のみ表示）
   ============================================================ */
#print-container {
  display: none;
}

@media print {
  /* アプリ本体・モーダル類をすべて隠し、印刷コンテナだけを表示する */
  body > *:not(#print-container) {
    display: none !important;
  }
  #print-container {
    display: block !important;
    color: #000;
    background: #fff;
    font-family: 'Noto Sans JP', sans-serif;
  }
  @page {
    margin: 14mm;
  }
}

.print-header {
  border-bottom: 3px solid #333;
  padding-bottom: 10px;
  margin-bottom: 18px;
}
.print-header h1 {
  font-size: 22px;
  margin: 0 0 6px;
}
.print-header .print-meta {
  font-size: 11px;
  color: #555;
}
.print-desc {
  font-size: 12px;
  color: #333;
  margin: 0 0 18px;
  white-space: pre-wrap;
}
.print-step {
  break-inside: avoid;
  page-break-inside: avoid;
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.print-step .print-step-no {
  font-size: 11px;
  font-weight: 700;
  color: #4f46e5;
  letter-spacing: 1px;
}
.print-step h2 {
  font-size: 15px;
  margin: 2px 0 8px;
}
.print-step img {
  display: block;
  max-width: 100%;
  max-height: 90mm;
  object-fit: contain;
  margin: 0 auto 8px;
  border: 1px solid #eee;
}
.print-step .print-video-note {
  border: 1px dashed #999;
  background: #f5f5f5;
  color: #555;
  text-align: center;
  padding: 14px;
  font-size: 12px;
  margin-bottom: 8px;
  border-radius: 6px;
}
.print-step .print-step-desc {
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  margin: 0;
}
.print-footer {
  margin-top: 16px;
  font-size: 10px;
  color: #777;
  text-align: right;
}

/* ============================================================
   コメントドロワー（右からスライド表示・メディア領域には影響しない）
   ============================================================ */
.comments-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 400px;
  max-width: 90vw;
  background-color: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  box-shadow: -12px 0 32px rgba(0, 0, 0, 0.18);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  z-index: 300;
  transform: translateX(105%);
  transition: transform 0.28s ease;
}
.comments-drawer.open {
  transform: translateX(0);
}

.comments-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--text-primary);
}
.comments-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.comments-count-badge {
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

.comments-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;            /* ドロワーの残り高さいっぱいに広げる */
  min-height: 0;
  overflow-y: auto;
}
.comment-item {
  background-color: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.comment-item .comment-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.comment-item .comment-author {
  font-weight: 600;
  color: var(--text-primary);
}
.comment-item .comment-body {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

.comments-empty {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.comment-form input,
.comment-form textarea {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.comment-form input:focus,
.comment-form textarea:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: -1px;
}
.comment-form button {
  align-self: flex-end;
}

/* コメント開閉ボタン（読了ボタンの隣・コンパクト表示） */
.instruction-footer #comments-toggle-btn {
  width: auto;
  flex-shrink: 0;
  white-space: nowrap;
}
