/* ============================
   リセット・ベース
   ============================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: #f0f4f8;
  color: #1e293b;
  min-height: 100vh;
}

/* ============================
   ヘッダー
   ============================ */
.header {
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
  color: #fff;
  padding: 0;
  box-shadow: 0 4px 20px rgba(30,64,175,0.25);
}

.header-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  border-radius: 8px;
  padding: 4px 8px;
  margin: -4px -8px;
  transition: background 0.18s, opacity 0.18s;
  user-select: none;
}

.logo:hover {
  background: rgba(255,255,255,0.15);
  opacity: 0.9;
}

.logo:active {
  opacity: 0.7;
}

.logo i { font-size: 1.6rem; }

.header-sub {
  font-size: 0.8rem;
  opacity: 0.85;
  background: rgba(255,255,255,0.15);
  padding: 4px 12px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================
   メインコンテンツ
   ============================ */
.main {
  max-width: 860px;
  margin: 32px auto;
  padding: 0 16px 80px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ============================
   セクション共通
   ============================ */
.step-section {
  background: #fff;
  border-radius: 16px;
  padding: 28px 32px;
  box-shadow: 0 2px 16px rgba(0,0,0,0.07);
  transition: opacity 0.3s ease;
}

.step-section.hidden { display: none; }
.step-section.active { display: block; }

.step-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.step-badge {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 5px 12px;
  border-radius: 99px;
  white-space: nowrap;
}

.step-badge.success {
  background: linear-gradient(135deg, #059669, #10b981);
}

.step-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1e293b;
}

/* ============================
   ドロップゾーン
   ============================ */
.drop-zone {
  border: 2.5px dashed #93c5fd;
  border-radius: 14px;
  background: #eff6ff;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: #3b82f6;
  background: #dbeafe;
  transform: scale(1.01);
}

.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.drop-icon {
  font-size: 3.5rem;
  color: #3b82f6;
}

.drop-main {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1e40af;
}

.drop-sub {
  font-size: 0.85rem;
  color: #64748b;
}

/* ============================
   ファイル情報
   ============================ */
.file-info {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 14px 18px;
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: 10px;
}

.file-info.hidden { display: none; }

.file-info-icon {
  font-size: 2rem;
  color: #ef4444;
}

.file-info-text {
  flex: 1;
}

.file-name {
  font-weight: 600;
  font-size: 0.95rem;
  word-break: break-all;
}

.file-meta {
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 2px;
}

/* ============================
   タブ
   ============================ */
.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 9px 18px;
  border-radius: 8px;
  border: 1.5px solid #cbd5e1;
  background: #f8fafc;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover {
  border-color: #3b82f6;
  color: #1e40af;
  background: #eff6ff;
}

.tab-btn.active {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,0.35);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================
   範囲指定タブ
   ============================ */
.range-help {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fef9c3;
  border: 1px solid #fde047;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: #713f12;
  margin-bottom: 16px;
}

.range-help i { color: #ca8a04; margin-top: 2px; }
.range-help code {
  background: rgba(0,0,0,0.07);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.82rem;
}

.range-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.range-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  transition: border-color 0.18s;
}

.range-item:focus-within {
  border-color: #3b82f6;
  background: #eff6ff;
}

.range-item-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  min-width: 60px;
}

.range-input {
  flex: 1;
  padding: 7px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.9rem;
  color: #1e293b;
  outline: none;
  transition: border-color 0.18s;
}

.range-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.range-name-input {
  width: 160px;
  padding: 7px 12px;
  border: 1.5px solid #cbd5e1;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.88rem;
  color: #1e293b;
  outline: none;
  transition: border-color 0.18s;
}

.range-name-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.btn-remove-range {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.15s;
}

.btn-remove-range:hover { background: #fee2e2; }

/* ============================
   均等分割タブ
   ============================ */
.every-setting {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px;
  background: #f8fafc;
  border-radius: 10px;
}

.every-setting label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: #475569;
}

.every-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.input-num {
  width: 90px;
  padding: 8px 12px;
  border: 2px solid #93c5fd;
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  color: #1e40af;
  text-align: center;
  outline: none;
  transition: border-color 0.18s;
}

.input-num:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.every-preview {
  font-size: 0.88rem;
  color: #059669;
  font-weight: 500;
}

/* ============================
   1ページずつタブ
   ============================ */
.single-info {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px;
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: 10px;
}

.success-icon { font-size: 1.6rem; color: #10b981; margin-top: 2px; }

/* ============================
   サムネイルプレビュー
   ============================ */
.preview-section {
  margin-top: 28px;
  border-top: 1.5px solid #e2e8f0;
  padding-top: 24px;
}

.preview-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  max-height: 300px;
  overflow-y: auto;
  padding: 8px 4px;
}

.thumb-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: default;
}

.thumb-canvas {
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  width: 80px;
  height: 110px;
  object-fit: cover;
  background: #f8fafc;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  transition: border-color 0.18s, transform 0.18s;
}

.thumb-canvas:hover {
  border-color: #3b82f6;
  transform: scale(1.05);
}

.thumb-label {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 500;
}

.loading-wrap {
  color: #64748b;
  font-size: 0.9rem;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ============================
   アクションバー
   ============================ */
.action-bar {
  display: flex;
  gap: 12px;
  margin-top: 28px;
  flex-wrap: wrap;
}

/* ============================
   ボタン
   ============================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 22px;
  border-radius: 9px;
  border: none;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: #fff;
  box-shadow: 0 3px 10px rgba(59,130,246,0.35);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(59,130,246,0.45);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  box-shadow: 0 3px 10px rgba(16,185,129,0.35);
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(16,185,129,0.45);
}

.btn-outline {
  background: #fff;
  color: #475569;
  border: 1.5px solid #cbd5e1;
}

.btn-outline:hover {
  border-color: #3b82f6;
  color: #1e40af;
  background: #eff6ff;
}

.btn-lg {
  padding: 13px 32px;
  font-size: 1rem;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
}

/* ============================
   保存先フォルダーパネル
   ============================ */
.save-folder-panel {
  background: #f0f9ff;
  border: 2px solid #bae6fd;
  border-radius: 14px;
  padding: 20px 22px;
  margin-bottom: 18px;
}

.save-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0369a1;
  margin-bottom: 14px;
}

.save-folder-header i { font-size: 1.1rem; }

.fsa-note {
  font-size: 0.78rem;
  font-weight: 400;
  color: #b45309;
  background: #fef3c7;
  border: 1px solid #fde68a;
  padding: 3px 10px;
  border-radius: 99px;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
}

.fsa-note.hidden { display: none; }

/* 未選択状態 */
.folder-unselected-info {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.btn-folder {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 9px;
  border: 2px dashed #38bdf8;
  background: #fff;
  color: #0369a1;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
}

.btn-folder:hover {
  background: #e0f2fe;
  border-color: #0284c7;
}

.folder-tip {
  font-size: 0.82rem;
  color: #64748b;
}

/* 選択済み状態 */
.folder-selected-info {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1.5px solid #7dd3fc;
  border-radius: 10px;
  padding: 12px 16px;
}

.folder-selected-info.hidden { display: none; }

.folder-icon-sel {
  font-size: 1.8rem;
  color: #f59e0b;
}

.folder-sel-text { flex: 1; }

.folder-sel-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #1e293b;
  word-break: break-all;
}

.folder-sel-sub {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 2px;
}

/* ダウンロードアイテム内の保存済みバッジ */
.saved-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #d1fae5;
  color: #059669;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 99px;
  white-space: nowrap;
}

/* ============================
   完了画面
   ============================ */
.done-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: #f0fdf4;
  border: 1.5px solid #bbf7d0;
  border-radius: 12px;
  margin-bottom: 20px;
}

.done-icon {
  font-size: 2.8rem;
  color: #10b981;
}

.done-message {
  font-size: 1rem;
  font-weight: 600;
  color: #065f46;
}

.download-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
}

.download-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  transition: border-color 0.18s, background 0.18s;
}

.download-item:hover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.download-item-icon {
  font-size: 1.6rem;
  color: #ef4444;
}

.download-item-text {
  flex: 1;
}

.download-item-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.download-item-pages {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 2px;
}

.btn-dl {
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: #fff;
  border: none;
  padding: 7px 16px;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.18s;
  text-decoration: none;
}

.btn-dl:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(59,130,246,0.4);
}

/* ============================
   プログレスオーバーレイ
   ============================ */
.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.progress-overlay.hidden { display: none; }

.progress-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  min-width: 280px;
}

.progress-spinner {
  font-size: 2.4rem;
  color: #3b82f6;
  margin-bottom: 14px;
}

.progress-label {
  font-size: 0.95rem;
  color: #475569;
  margin-bottom: 14px;
  font-weight: 500;
}

.progress-bar-wrap {
  background: #e2e8f0;
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #1e40af, #3b82f6);
  border-radius: 99px;
  transition: width 0.3s ease;
  width: 0%;
}

/* ============================
   トースト
   ============================ */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #1e293b;
  color: #fff;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 2000;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.hidden { display: none; }

.toast.error { background: #dc2626; }
.toast.success { background: #059669; }

/* ============================
   回転セクション
   ============================ */
.rotate-section {
  margin-top: 28px;
  border-top: 1.5px solid #e2e8f0;
  padding-top: 22px;
}

.rotate-hint {
  font-size: 0.78rem;
  font-weight: 400;
  color: #94a3b8;
  margin-left: 10px;
}

.rotate-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* サムネイル内の回転ボタン */
.thumb-item {
  position: relative;
}

.thumb-rotate-btns {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 4px;
}

.btn-thumb-rotate {
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  color: #475569;
  transition: all 0.15s;
  padding: 0;
}

.btn-thumb-rotate:hover {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1e40af;
}

/* 回転角度バッジ */
.thumb-rotate-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #f59e0b;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
  pointer-events: none;
}

/* サムネイルcanvasを回転アニメーション */
.thumb-canvas {
  transition: transform 0.3s ease, border-color 0.18s;
}

.thumb-canvas.rotated {
  border-color: #f59e0b;
  box-shadow: 0 1px 6px rgba(245,158,11,0.35);
}

/* ============================
   スクロールバー
   ============================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 99px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ============================
   レスポンシブ
   ============================ */
@media (max-width: 600px) {
  .step-section { padding: 20px 16px; }
  .header-inner { padding: 16px; }
  .logo { font-size: 1.2rem; }
  .tab-btn { padding: 8px 12px; font-size: 0.8rem; }
  .btn-lg { padding: 11px 20px; font-size: 0.9rem; }
  .range-item { flex-wrap: wrap; }
  .range-name-input { width: 100%; }
  .action-bar { flex-direction: column; }
}
