* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", sans-serif;
  background: #f4f5f7;
  color: #1c1c1e;
}
.screen { min-height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* ---- ログイン画面 ---- */
#login-screen {
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: white;
  border-radius: 16px;
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  text-align: center;
}
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card p { color: #666; font-size: 13px; margin-bottom: 20px; }
.login-card input, .login-card select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 16px;
  margin-bottom: 12px;
}
.primary-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 10px;
  background: #2f6fed;
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
.primary-btn:disabled { background: #b9c6e6; }
.error-text { color: #d5322f; font-size: 13px; margin-top: 8px; min-height: 16px; }

/* ---- ホーム画面 ---- */
#home-screen { padding-bottom: 90px; }
.top-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: white; border-bottom: 1px solid #e5e5e5;
  position: sticky; top: 0; z-index: 5;
}
.top-bar h2 { font-size: 16px; margin: 0; }
.tabs { display: flex; background: white; border-bottom: 1px solid #e5e5e5; }
.tab-btn {
  flex: 1; padding: 14px; text-align: center; border: none; background: none;
  font-size: 15px; color: #888; border-bottom: 3px solid transparent; cursor: pointer;
}
.tab-btn.active { color: #2f6fed; border-bottom-color: #2f6fed; font-weight: 600; }

.folder-bar { display: flex; flex-wrap: wrap; gap: 14px; padding: 16px 16px 4px; }
.folder-tiles { display: contents; }
.folder-tile {
  width: 120px; border: 1px solid #eee; border-radius: 14px; padding: 14px 12px; background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06); cursor: pointer; text-align: left; font-family: inherit;
  transition: box-shadow .15s ease, border-color .15s ease, background .15s ease;
}
.folder-tile .fi { font-size: 26px; margin-bottom: 6px; }
.folder-tile .fn { font-size: 13px; font-weight: 700; word-break: break-all; }
.folder-tile .fc { font-size: 11px; color: #888; margin-top: 2px; }
.folder-tile.drag-over { border-color: #2f6fed; box-shadow: 0 0 0 2px #2f6fed inset; background: #f0f5ff; }
.new-folder-tile { color: #667; border-style: dashed; }
.new-folder-tile:hover { border-color: #2f6fed; color: #2f6fed; }

.crumb { display: flex; align-items: center; gap: 8px; padding: 4px 16px 8px; font-size: 12.5px; color: #888; }
.crumb b { color: #1c1c1e; }

.video-card[draggable="true"] { cursor: grab; }
.video-card.dragging { opacity: 0.4; }

.video-list { padding: 16px; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); }
.video-card {
  background: white; border-radius: 14px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer; border: 1px solid #eee;
}
.thumb-wrap { position: relative; width: 100%; background: #222; }
.thumb-wrap::before { content: ""; display: block; padding-top: 56.25%; } /* 16:9 */
.video-card video, .video-card .thumb-placeholder {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; background: #222;
}
.thumb-placeholder { display: flex; align-items: center; justify-content: center; color: #888; font-size: 13px; }
.delete-video-btn {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.55); color: white; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.delete-video-btn:hover { background: rgba(213,50,47,0.85); }
.edit-video-btn {
  position: absolute; top: 6px; left: 6px; z-index: 2;
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: rgba(0,0,0,0.55); color: white; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.edit-video-btn:hover { background: rgba(47,111,237,0.85); }
.video-card-body { padding: 10px 12px; }
.video-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.status-badge {
  display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600;
}
.status-processing { background: #fff3cd; color: #997404; }
.status-needs_finish { background: #ffe4d1; color: #b3541e; }
.status-done { background: #d7f5dd; color: #1f7a3a; }

.empty-hint { color: #999; padding: 40px 16px; text-align: center; font-size: 14px; }

.fab {
  position: fixed; right: 22px; bottom: 26px; width: 62px; height: 62px; border-radius: 50%;
  background: #2f6fed; color: white; font-size: 28px; border: none; box-shadow: 0 6px 16px rgba(47,111,237,0.4);
  cursor: pointer;
}
.logout-link { font-size: 13px; color: #888; cursor: pointer; background: none; border: none; }

/* ---- アップロード順番確認モーダル ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
/* 確認ダイアログは、ゴミ箱など他のモーダルの上からでも必ず開けるよう最前面に固定する */
#confirm-modal { z-index: 500; }
.modal-card {
  background: white; border-radius: 14px; padding: 22px; width: 100%; max-width: 480px;
  max-height: 80vh; overflow-y: auto;
}
.modal-card h3 { margin: 0 0 6px; }
.modal-card p { font-size: 14px; line-height: 1.7; color: #333; margin: 0 0 4px; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: #1c1c1e; color: white; padding: 13px 22px; border-radius: 10px;
  font-size: 13.5px; z-index: 100; max-width: 90vw; text-align: center;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
}
.upload-order-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0f0f0;
}
.upload-order-row .order-num {
  width: 24px; height: 24px; border-radius: 50%; background: #2f6fed; color: white;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.upload-order-row .thumb {
  width: 56px; height: 32px; border-radius: 6px; background: #222; object-fit: cover; flex-shrink: 0;
}
.upload-order-row .fname { flex: 1; font-size: 13px; word-break: break-all; }
.upload-order-row .reorder-btns { display: flex; gap: 4px; flex-shrink: 0; }

.context-menu {
  position: fixed; z-index: 300; background: white; border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18); padding: 6px; min-width: 160px;
}
.context-menu button {
  display: block; width: 100%; text-align: left; border: none; background: none;
  padding: 10px 12px; font-size: 13.5px; border-radius: 6px; cursor: pointer;
}
.context-menu button:hover { background: #f0f2f6; }

.trash-row {
  display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #f0f0f0;
}
.trash-row .info { flex: 1; min-width: 0; }
.trash-row .fname { font-size: 13.5px; font-weight: 600; word-break: break-all; }
.trash-row .deleted-at { font-size: 11.5px; color: #888; margin-top: 2px; }
.trash-row .actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---- 編集画面(パソコン向け・横動画前提) ---- */
#edit-screen { padding: 20px; max-width: 1100px; margin: 0 auto; width: 100%; }
.edit-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.back-link { background: none; border: none; color: #2f6fed; font-size: 14px; cursor: pointer; }

.video-pane {
  position: relative; background: black; border-radius: 12px; overflow: hidden;
  width: 100%; max-width: 860px; margin: 0 auto 18px;
}
.video-pane::before { content: ""; display: block; padding-top: 56.25%; } /* 16:9 */
.video-pane video {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: block; object-fit: contain;
}

/* 完成後に焼き込まれる見た目をそのまま編集中にプレビューする(実際に反映されているか分かるように) */
.overlay-caption {
  position: absolute; left: 50%; bottom: 6%; transform: translateX(-50%);
  background: rgba(0,0,0,0.62); color: #fff; font-size: 15px; font-weight: 500;
  padding: 8px 18px; border-radius: 8px; max-width: 90%; text-align: center; pointer-events: none;
}
.overlay-icon {
  position: absolute; top: 4%; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 14px; font-weight: 700; padding: 6px 14px; border-radius: 6px; pointer-events: none;
}
.overlay-icon.warning { background: #e2711d; }
.overlay-icon.danger { background: #d1382b; }
.overlay-highlight {
  position: absolute; border: 4px solid #ff2d20; border-radius: 2px; pointer-events: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.3);
}

.trim-panel { max-width: 860px; margin-left: auto; margin-right: auto; }

.edit-grid { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 800px) {
  .edit-grid { grid-template-columns: 1fr 1fr; }
}

.panel { background: white; border-radius: 12px; padding: 18px; margin-bottom: 18px; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.panel small.hint { color: #888; display: block; margin-bottom: 10px; }

.trim-controls { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.trim-controls label { font-size: 13px; color: #555; }
.trim-controls input[type=number] { width: 80px; padding: 6px 8px; border: 1px solid #ddd; border-radius: 6px; }

textarea#caption-input {
  width: 100%; min-height: 110px; padding: 10px; border: 1px solid #ddd; border-radius: 8px;
  font-size: 14px; font-family: inherit; resize: vertical;
}

.timeline {
  position: relative; height: 46px; background: #eef0f4; border-radius: 8px; margin-top: 10px; cursor: pointer;
}
.timeline .marker {
  position: absolute; top: 0; bottom: 0; width: 3px; background: #2f6fed;
}
.timeline .marker::after {
  content: attr(data-idx); position: absolute; top: -20px; left: -6px; font-size: 11px; color: #2f6fed; font-weight: 600;
}

.caption-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid #f0f0f0; font-size: 13px;
  flex-wrap: wrap;
}
.caption-row .idx { width: 20px; color: #999; }
.caption-row .txt { flex: 1 1 140px; min-width: 100px; }
.caption-row .time-tag { color: #2f6fed; font-variant-numeric: tabular-nums; }
.caption-row audio { flex: 1 1 100%; width: 100%; }
.small-btn {
  border: 1px solid #ddd; background: white; padding: 6px 12px; border-radius: 8px; font-size: 12px; cursor: pointer;
}
.small-btn:hover { background: #f4f6fb; }

.btn-row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.finalize-btn {
  padding: 12px 22px; border: none; border-radius: 10px; background: #1f8a4c; color: white; font-weight: 600; cursor: pointer;
}
audio { height: 32px; }
