/* ==========================================================================
   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"] {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121e;
  --bg-tertiary: #19192a;
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --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(18, 18, 30, 0.8);
  --glass-border: rgba(255, 255, 255, 0.05);
  --card-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0,0,0,0.2);
  --sidebar-shadow: 1px 0 0 rgba(255,255,255, 0.05);
  --header-shadow: 0 1px 0 rgba(255,255,255, 0.05);

  /* Sidebar Theme Colors (Dark Mode) */
  --sidebar-bg: #0b0f19;
  --sidebar-border: rgba(255, 255, 255, 0.05);
  --sidebar-text-primary: #f8fafc;
  --sidebar-text-secondary: #cbd5e1;
  --sidebar-text-muted: #64748b;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.05);
  --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: #cbd5e1;
}

/* --- 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;
}

.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);
}

.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;
}

.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: 100vw;
  height: 100vh;
  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);
}

.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;
  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;
  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: 300px;
    min-width: 160px; /* 検索欄のつぶれを防止 */
  }
  /* 並び替えのラベル「並び替え:」を非表示にして省スペース化 */
  .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: 320px; /* 十分な高さに広げる */
  overflow-y: auto;
}

/* アコーディオン切り替えボタン */
.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;
}
