/* ベース */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { font-family: 'Meiryo', 'Hiragino Sans', sans-serif; color: #222; background: #f5f7fa; line-height: 1.6; }

/* ヘッダー */
.app-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #3b5998 100%);
  color: #fff;
  padding: 24px 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.header-inner { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.app-header h1 { font-size: 28px; font-weight: 700; }
.subtitle { font-size: 14px; opacity: 0.85; margin-top: 4px; }

/* メインレイアウト */
.app-main { max-width: 1200px; margin: 32px auto; padding: 0 24px 64px; }

/* ステップセクション */
.step-section {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}
.step-section h2 {
  font-size: 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1e3a8a;
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

/* 支店選択グリッド */
.branch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}
.branch-card {
  border: 2px solid #e0e4eb;
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.15s;
  background: #fff;
  text-align: center;
}
.branch-card:hover { border-color: #3b5998; background: #f0f4fc; }
.branch-card.selected {
  border-color: #1e3a8a;
  background: #e8efff;
  box-shadow: 0 0 0 2px rgba(30, 58, 138, 0.15);
}
.branch-card .branch-name { font-weight: 700; font-size: 15px; }
.branch-card .branch-addr { font-size: 11px; color: #666; margin-top: 4px; }

/* ドロップゾーン */
.drop-zone {
  border: 3px dashed #c0c8d4;
  border-radius: 10px;
  padding: 40px 20px;
  text-align: center;
  background: #fafbfd;
  transition: all 0.15s;
}
.drop-zone.dragover {
  border-color: #1e3a8a;
  background: #e8efff;
}
.drop-icon { font-size: 48px; margin-bottom: 12px; }
.drop-text { font-size: 16px; font-weight: 700; }
.drop-subtext { color: #888; font-size: 13px; margin: 8px 0; }
.drop-hint { font-size: 12px; color: #888; margin-top: 12px; }

/* ボタン */
.btn-primary {
  background: #1e3a8a;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #16306e; }
.btn-primary:disabled { background: #aab1bc; cursor: not-allowed; }
.btn-secondary {
  background: #fff;
  color: #1e3a8a;
  border: 2px solid #1e3a8a;
  border-radius: 6px;
  padding: 8px 22px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.btn-large { padding: 14px 36px; font-size: 16px; }
.btn-mini {
  background: #fff;
  color: #1e3a8a;
  border: 1px solid #1e3a8a;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-mini:hover { background: #e8efff; }

/* プレビューヘッダー */
.preview-header { gap: 8px !important; flex-wrap: wrap; }
.current-file-name {
  font-size: 15px;
  font-weight: 500;
  color: #444;
  background: #f0f4fc;
  padding: 4px 12px;
  border-radius: 4px;
  word-break: break-all;
  flex: 1;
}

/* ファイル切替タブ（プレビュー下） */
.page-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 12px 0 16px;
}
.page-tab {
  min-width: 40px;
  padding: 8px 12px;
  border: 2px solid #e0e4eb;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  transition: all 0.12s;
  position: relative;
}
.page-tab:hover { border-color: #3b5998; }
.page-tab.active {
  border-color: #1e3a8a;
  background: #1e3a8a;
  color: #fff;
}
.page-tab.error::after {
  content: '!';
  position: absolute;
  top: -6px;
  right: -6px;
  background: #c00;
  color: #fff;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.page-tab.done::after {
  content: '✓';
  position: absolute;
  top: -6px;
  right: -6px;
  background: #2c5;
  color: #fff;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* プレビュー本体 */
.preview-wrap { margin-bottom: 16px; }
.preview-stage {
  background: #f0f0f0;
  border: 1px solid #d0d4dc;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 400px;
  overflow: auto;
}
.preview-inner {
  position: relative;
  display: inline-block;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  background: #fff;
}
.preview-inner canvas {
  display: block;
  max-width: 100%;
  height: auto;
}
.preview-hint {
  font-size: 12px;
  color: #666;
  margin-top: 8px;
  text-align: center;
}
.preview-hint strong { color: #2a7; }

/* 帯領域オーバーレイ */
.obi-overlay {
  position: absolute;
  left: 0;
  right: 0;
  background: rgba(46, 204, 113, 0.22);
  border-top: 1px solid #2ecc71;
  border-bottom: 1px solid #2ecc71;
  cursor: move;
  user-select: none;
  touch-action: none;
  transition: background 0.1s;
}
.obi-overlay:hover, .obi-overlay.dragging {
  background: rgba(46, 204, 113, 0.35);
}
.obi-handle {
  position: absolute;
  left: 0;
  right: 0;
  height: 14px;             /* クリック領域は太く（操作しやすさ） */
  background: transparent;  /* 見た目は透明 */
  cursor: ns-resize;
  user-select: none;
  touch-action: none;
  z-index: 2;
}
/* 視覚的な細い境界線（3px） */
.obi-handle::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  margin-top: -1.5px;
  height: 3px;
  background: #2ecc71;
  pointer-events: none;
}
/* 中央の摘み（つまみ）小さく */
.obi-handle::after {
  content: '';
  position: absolute;
  left: 50%;
  margin-left: -18px;
  top: 50%;
  margin-top: -3px;
  width: 36px;
  height: 6px;
  background: #2ecc71;
  border-radius: 3px;
  pointer-events: none;
}
.obi-handle-top { top: -7px; }
.obi-handle-bottom { bottom: -7px; }
.obi-handle:hover::before, .obi-handle:hover::after { background: #1ea257; }

/* Before/After 切替タブ */
.before-after-toggle {
  display: inline-flex;
  border: 1px solid #1e3a8a;
  border-radius: 6px;
  overflow: hidden;
}
.ba-tab {
  padding: 6px 16px;
  border: none;
  background: #fff;
  color: #1e3a8a;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ba-tab.active {
  background: #1e3a8a;
  color: #fff;
}
.ba-tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* obi-meta */
.obi-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 10px 14px;
  background: #f8faff;
  border: 1px solid #e0e4eb;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}
.meta-item {
  background: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #e0e4eb;
}
#metaDetected {
  color: #2a7;
  font-weight: 600;
}
#metaDetected.manual {
  color: #c80;
}

/* アクション */
.action-row {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

/* ダウンロード */
.download-area { display: flex; flex-direction: column; gap: 10px; }
.download-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f0f4fc;
  border-radius: 6px;
  flex-wrap: wrap;
  gap: 8px;
}
.download-buttons { display: flex; gap: 8px; }
.download-buttons a {
  background: #1e3a8a;
  color: #fff;
  padding: 6px 14px;
  border-radius: 4px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}
.download-buttons a:hover { background: #16306e; }

/* 進捗オーバーレイ */
.progress-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.progress-box {
  background: #fff;
  border-radius: 12px;
  padding: 32px 48px;
  text-align: center;
  min-width: 300px;
}
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e0e4eb;
  border-top-color: #1e3a8a;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-bar {
  background: #e0e4eb;
  border-radius: 4px;
  overflow: hidden;
  height: 8px;
  margin-top: 16px;
}
.progress-fill {
  background: #1e3a8a;
  height: 100%;
  width: 0%;
  transition: width 0.3s;
}

/* フッター */
.app-footer { text-align: center; padding: 16px; color: #888; font-size: 12px; }

/* レスポンシブ */
@media (max-width: 768px) {
  .obi-meta { font-size: 12px; }
  .preview-stage { padding: 8px; }
  .obi-handle { height: 18px; }
  .obi-handle-top { top: -18px; }
  .obi-handle-bottom { bottom: -18px; }
}
