/* ============================================================
   サムネ工房 ver1 — style.css
   落ち着いた実務ツール風。prefers-color-scheme で両対応。
   ============================================================ */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #eceef1;
  --border: #d7dbe0;
  --text: #1b2430;
  --muted: #6b7280;
  --accent: #2f6f9f;
  --accent-weak: #dbe8f2;
  --primary: #2f6f9f;
  --primary-text: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --panel: #1b2430;
    --panel-2: #232e3c;
    --border: #333f4f;
    --text: #e6e9ee;
    --muted: #97a1ae;
    --accent: #5aa0d6;
    --accent-weak: #22364a;
    --primary: #3f7fb5;
    --primary-text: #ffffff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, "Segoe UI", "Yu Gothic UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

/* ---------- ヘッダー ---------- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-icon { border-radius: 6px; display: block; }
.brand h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.ver {
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}
.privacy-badge {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  background: var(--accent-weak);
  border-radius: 6px;
  padding: 4px 10px;
}

/* ---------- レイアウト ---------- */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  padding: 16px 20px;
  align-items: start;
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
}
.panel h3 {
  margin: 16px 0 8px;
  font-size: 13px;
  font-weight: 700;
}

/* ---------- 入力 ---------- */
.ctl {
  display: block;
  margin-bottom: 14px;
}
.ctl > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--muted);
}
.ctl-inline {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ctl-inline > span { margin: 0; flex: 1; }

#title {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  font-family: system-ui, "Yu Gothic UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
#subtitle {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
#title:focus, #subtitle:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------- ドロップゾーン ---------- */
.dropzone {
  position: relative;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  padding: 14px 12px;
  text-align: center;
  background: var(--panel-2);
  cursor: pointer;
}
.dropzone.dragover { border-color: var(--accent); background: var(--accent-weak); }
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.drop-hint { margin: 0; font-size: 12px; color: var(--muted); }
#bg-name { margin: 6px 0 0; word-break: break-all; }

/* ---------- 強調色スウォッチ ---------- */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 2px solid var(--border);
  cursor: pointer;
  padding: 0;
}
.swatch.active { border-color: var(--text); box-shadow: 0 0 0 2px var(--accent); }

/* ---------- セグメント（文字色） ---------- */
.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 4px;
}
.seg {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: none;
  border-right: 1px solid var(--border);
  padding: 7px 16px;
  cursor: pointer;
}
.seg:last-child { border-right: none; }
.seg.active { background: var(--accent); color: var(--primary-text); }

/* ---------- 入力側の色ピッカー ---------- */
input[type="color"] {
  width: 52px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  cursor: pointer;
}

/* ---------- 仕上げ（スライダー・チェック） ---------- */
.range {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 2px 0 0;
}
#overlay-val {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 700;
}
.ctl-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.ctl-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}
.ctl-check > span {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}

/* ---------- 3案カード ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
@media (max-width: 640px) {
  .cards { grid-template-columns: 1fr; }
}
.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--panel-2);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
}
.card-title { font-size: 13px; font-weight: 700; }
.card-tag { font-size: 11px; color: var(--muted); }
.card canvas.main {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #000;
}
.card-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.mini-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.mini-wrap canvas.mini {
  width: 84px;
  height: 47px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: #000;
}
.mini-label { font-size: 10px; color: var(--muted); line-height: 1.2; max-width: 6em; }
.card-foot .grow { flex: 1; }

/* ---------- ボタン ---------- */
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
button {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:focus-visible,
.swatch:focus-visible,
.seg:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary {
  background: var(--primary);
  color: var(--primary-text);
  border-color: var(--primary);
}
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.small { padding: 5px 10px; font-size: 12px; }

.status {
  margin-top: 10px;
  min-height: 1.2em;
  font-size: 12px;
  color: var(--muted);
}

/* ---------- 汎用 ---------- */
.muted { color: var(--muted); }
.small { font-size: 12px; }

.app-footer {
  padding: 12px 20px 24px;
  text-align: center;
}

/* ============================================================
   第2弾: 配色シャッフル／YouTube確認モック
   ============================================================ */

/* ---------- プレビュー上のツールボタン列 ---------- */
.preview-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.tool { font-size: 13px; }
.tool-yt {
  background: var(--accent-weak);
  border-color: var(--accent);
}
.tool-yt:hover { filter: brightness(1.04); }

/* ---------- モーダル（YouTube確認） ---------- */
body.modal-open { overflow: hidden; }

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 16px;
  background: rgba(0, 0, 0, 0.55);
  overflow: auto;
}
/* hidden 属性を尊重（display:flex が [hidden] の display:none を上書きしないように） */
.modal-overlay[hidden] { display: none; }

.modal {
  width: min(1060px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.4);
  padding: 16px 18px 18px;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.icon-btn {
  flex: none;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--muted);
}
.modal-note { margin: 6px 0 12px; }

.yt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.yt-toolbar .segmented { margin-bottom: 0; }

/* ---------- モック本体（自前の明暗テーマを内包） ---------- */
.yt-stage {
  flex: 1 1 auto;
  min-height: 200px;
  overflow: auto;
  border-radius: 10px;
  padding: 16px;
}
.yt-mock {
  /* ダーク（既定） */
  --m-bg: #0f0f0f;
  --m-text: #f1f1f1;
  --m-sub: #aaaaaa;
  --m-avatar: #323232;
  --m-border: #272727;
  --m-dur-bg: rgba(0, 0, 0, 0.82);
  --m-dur-text: #ffffff;
  --m-you: #ff5a5f;
  background: var(--m-bg);
  color: var(--m-text);
}
.yt-mock.yt-light {
  --m-bg: #ffffff;
  --m-text: #0f0f0f;
  --m-sub: #606060;
  --m-avatar: #d9d9d9;
  --m-border: #e5e5e5;
  --m-dur-bg: rgba(0, 0, 0, 0.82);
  --m-dur-text: #ffffff;
  --m-you: #e5322d;
}

/* ---- レイアウト: PCホーム（グリッド） ---- */
.yt-home {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px 12px;
}
@media (max-width: 900px) { .yt-home { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 620px) { .yt-home { grid-template-columns: repeat(2, 1fr); } }

/* ---- レイアウト: スマホホーム（縦積み大） ---- */
.yt-mobile {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 420px;
  margin: 0 auto;
}

/* ---- レイアウト: 関連動画（サイドバー小・横並び） ---- */
.yt-related {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 440px;
  margin: 0 auto;
}

/* ---- ホーム/スマホ用カード ---- */
.yt-card { min-width: 0; }
.yt-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
}
.yt-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.yt-row {
  display: flex;
  gap: 10px;
  margin-top: 9px;
}
.yt-avatar {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--m-avatar);
}
.yt-meta { min-width: 0; }
.yt-t {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--m-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.yt-c,
.yt-m {
  font-size: 12px;
  color: var(--m-sub);
  line-height: 1.35;
}
.yt-c { margin-top: 3px; }

/* ---- 関連動画アイテム（小サムネ横並び） ---- */
.yt-rel {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.yt-rel-thumb {
  position: relative;
  flex: none;
  width: 168px;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}
.yt-rel-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.yt-rel-meta { min-width: 0; padding-top: 1px; }
.yt-rel-meta .yt-t { font-size: 12px; }
.yt-rel-meta .yt-c,
.yt-rel-meta .yt-m { font-size: 11px; }
@media (max-width: 480px) {
  .yt-rel-thumb { width: 132px; }
}

/* ---- サムネ上のバッジ（所要時間・自分マーカー） ---- */
.yt-dur {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 1px 4px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  background: var(--m-dur-bg);
  color: var(--m-dur-text);
}
.yt-you-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  background: var(--m-you);
  color: #ffffff;
}

/* ---- 自分の案を強調（周囲のダミーの中で見つけやすく） ---- */
.yt-card.is-you .yt-thumb,
.yt-rel.is-you .yt-rel-thumb {
  outline: 3px solid var(--m-you);
  outline-offset: 2px;
}
.yt-card.is-you .yt-t,
.yt-rel.is-you .yt-t { color: var(--m-you); }

/* ---------- モーダルのモバイル調整 ---------- */
@media (max-width: 640px) {
  .modal-overlay { padding: 12px 8px; }
  .modal { padding: 12px 12px 14px; max-height: calc(100vh - 24px); }
  .yt-stage { padding: 12px; }
}
