:root {
  --accent: #a21caf; --accent2: #d946ef; --bg: #faf5ff; --card: #ffffff;
  --text: #2e1065; --muted: #71717a; --border: #e4e4e7; --ok: #16a34a; --danger: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Kaku Gothic ProN",
    "Noto Sans JP", Meiryo, sans-serif;
  background: var(--bg); color: var(--text);
}
/* ヘッダーは来たログと同じ流儀: 単色・はっきりした色使い（グラデーション廃止） */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--accent);
  color: #fff; padding: env(safe-area-inset-top) 0 0;
}
.header-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.app-header h1 { margin: 0; font-size: 1.25rem; }
.logout-btn {
  background: rgba(255, 255, 255, 0.15); border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff; border-radius: 999px; padding: 6px 14px; font-size: 0.8rem; cursor: pointer;
}
/* タブも来たログと同型: 白ピルが有効タブ */
.tabs { display: flex; gap: 6px; padding: 0 8px 8px; }
.tab {
  flex: 1; border: none; background: transparent; color: rgba(255, 255, 255, 0.75);
  padding: 10px 8px; font-size: 0.95rem; font-weight: 600; border-radius: 10px;
  cursor: pointer; transition: background 0.15s ease, color 0.15s ease;
}
.tab.is-active { color: var(--accent); background: #fff; }

main { max-width: 640px; margin: 0 auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.is-active { display: block; }
/* タブ切替のスライドアニメーション（来たログと同一） */
@keyframes slide-in-right {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slide-in-left {
  from { transform: translateX(-24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.view.slide-from-right { animation: slide-in-right 0.22s ease; }
.view.slide-from-left { animation: slide-in-left 0.22s ease; }

.card { background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 2px rgba(46, 16, 101, 0.06); }
.card h2 { margin: 0 0 12px; font-size: 1.05rem; }
.muted { color: var(--muted); }
.empty { color: var(--muted); font-size: 0.9rem; }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.req { color: var(--danger); font-size: 0.72rem; margin-left: 4px; }
input, textarea, select {
  width: 100%; padding: 12px; font-size: 1rem; border: 1px solid var(--border);
  border-radius: 10px; font-family: inherit; color: var(--text); background: #fff;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%;
  padding: 14px; font-size: 1rem; font-weight: 700; border: none; border-radius: 12px; cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #6d28d9; }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: 0.9rem; cursor: pointer; margin: 0 6px 6px 0;
  text-decoration: none;
}
.chip-danger { color: var(--danger); border-color: #fecaca; }

/* 設定タブのグループ見出し・折りたたみ（§4-1オンデマンド開示・§12陳列棚の解消） */
.settings-group-label { margin: 4px 2px 8px; font-size: 0.8rem; font-weight: 700; color: var(--muted); letter-spacing: 0.02em; }
details.settings-group { margin-bottom: 16px; }
/* 閉じているときは中身を確実に隠す（一部ブラウザはネイティブの折りたたみを尊重しないため明示） */
details.settings-group:not([open]) > *:not(summary) { display: none; }
details.settings-group > summary {
  list-style: none; cursor: pointer; background: var(--card); border-radius: 14px;
  padding: 16px; font-weight: 700; font-size: 1rem; box-shadow: 0 1px 2px rgba(46, 16, 101, 0.06);
  display: flex; align-items: center; justify-content: space-between; min-height: 44px;
}
details.settings-group > summary::-webkit-details-marker { display: none; }
details.settings-group > summary::after { content: "▼ 開く"; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
details.settings-group[open] > summary { border-radius: 14px 14px 0 0; margin-bottom: 0; }
details.settings-group[open] > summary::after { content: "▲ 閉じる"; }
details.settings-group[open] > summary + .card,
details.settings-group[open] .card:first-of-type { border-top-left-radius: 0; border-top-right-radius: 0; }

/* このサービスについて（信頼・§16-2） */
#about-card .about-list p { margin: 0 0 12px; font-size: 0.95rem; line-height: 1.7; }
#about-card .about-list p:last-child { margin-bottom: 0; }
#about-card .about-list strong { color: var(--accent); }

/* 全画面フッター（プライバシー/規約導線・§16-2） */
.app-footer {
  text-align: center; padding: 20px 0 8px; color: var(--muted); font-size: 0.85rem;
}
.app-footer a { color: var(--muted); text-decoration: underline; }

/* ゲスト利用中バナー（本登録への導線。§16: 何が起きるかを先に伝える） */
#guest-banner {
  background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  border-radius: 12px; padding: 12px 14px; margin-bottom: 14px;
  font-size: 0.95rem; line-height: 1.6;
}
#guest-banner a { color: #92400e; font-weight: 700; }

.message { margin: 8px 0 0; font-size: 0.9rem; min-height: 1.2em; }
.message.ok { color: var(--ok); }
.message.error { color: var(--danger); }

.account-item, .post-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.account-item:last-child, .post-item:last-child { border-bottom: none; }
.post-item { flex-direction: column; align-items: stretch; gap: 8px; }
.post-head { display: flex; justify-content: space-between; align-items: center; }
.post-image { max-width: 100%; border-radius: 10px; margin: 6px 0; }
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.75rem;
  background: var(--bg); color: var(--accent); font-weight: 700;
}
.platform-picker { display: flex; gap: 10px; margin-bottom: 14px; }
.platform-picker label {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 0.9rem;
  background: #fff; transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.platform-picker input { width: auto; }
/* 選ばれているカードをひと目で分かるように（枠・背景・文字色でハイライト） */
.platform-picker label:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, #fff);
  color: var(--accent); font-weight: 700;
}

.media-item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.media-item .media-actions { flex-wrap: wrap; justify-content: flex-end; }
.media-item:last-child { border-bottom: none; }
.media-item img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.media-item .media-order { font-weight: 700; color: var(--accent); flex-shrink: 0; width: 1.5em; }
.media-item .media-actions { margin-left: auto; display: flex; gap: 4px; flex-shrink: 0; }
.media-item .media-actions button {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  padding: 6px 10px; cursor: pointer; font-size: 0.85rem;
  min-height: 44px; min-width: 44px; /* §11 タップ領域 */
}
.media-item .media-actions button:disabled { opacity: 0.35; cursor: default; }

/* スライドショーのストーリーボード。サムネイルは実際の縦型(9:16)構図で見せ、
   字幕はサムネイル上にライブで重ねる＝「動画にしたときの見え方」をその場で確認できる */
.slide-card {
  display: flex; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border);
}
.slide-card:last-child { border-bottom: none; }
.slide-thumb-wrap {
  position: relative; width: 84px; aspect-ratio: 9 / 16; flex-shrink: 0;
  border-radius: 8px; overflow: hidden; background: #000;
}
.slide-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.slide-telop-overlay {
  position: absolute; left: 4%; right: 4%; text-align: center;
  color: #fff; font-size: 0.55rem; font-weight: 700; line-height: 1.3;
  background: rgba(0, 0, 0, 0.45); border-radius: 3px; padding: 2px 3px;
  word-break: break-all; pointer-events: none;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
}
.slide-telop-overlay.pos-bottom { bottom: 5%; }
.slide-telop-overlay.pos-center { top: 50%; transform: translateY(-50%); }
.slide-telop-overlay.pos-top { top: 5%; }
.slide-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.slide-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.slide-duration-label { display: flex; align-items: center; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.slide-duration-label input { width: 60px; padding: 8px; text-align: center; }
.slide-head .media-actions { margin-left: auto; display: flex; gap: 6px; }
.slide-head .media-actions button {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  min-width: 44px; min-height: 44px; cursor: pointer; font-size: 1rem; color: var(--text);
}
.slide-head .media-actions button:disabled { opacity: 0.35; cursor: default; }
.slide-main .slideshow-telop-text { padding: 10px 12px; }
.slide-main .slideshow-telop-pos { width: auto; padding: 8px 12px; font-size: 0.9rem; min-height: 44px; }
.slide-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.slide-foot .chip { margin: 0; font-size: 0.85rem; padding: 0 12px; }

/* 「音を付ける」などの折りたたみ小セクション */
details.sub-details { margin: 10px 0 4px; border: 1px solid var(--border); border-radius: 12px; }
details.sub-details > summary {
  list-style: none; cursor: pointer; padding: 14px; font-weight: 600; font-size: 0.95rem;
  min-height: 44px; display: flex; align-items: center; justify-content: space-between;
}
details.sub-details > summary::-webkit-details-marker { display: none; }
details.sub-details > summary::after { content: "▼"; font-size: 0.8rem; color: var(--muted); }
details.sub-details[open] > summary::after { content: "▲"; }
details.sub-details:not([open]) > *:not(summary) { display: none; }
.sub-details-body { padding: 0 14px 14px; }
.slide-item .slide-telop { display: flex; gap: 6px; }
.slide-item .slide-telop input { flex: 1; }
.slide-item .slide-telop select { width: auto; flex-shrink: 0; }

.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.tag-chips:empty { display: none; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg); color: var(--accent); font-weight: 600;
  border-radius: 999px; padding: 4px 10px; font-size: 0.85rem;
}
.tag-chip button {
  border: none; background: none; color: var(--muted); cursor: pointer;
  font-size: 1rem; line-height: 1; padding: 0;
}

.preview-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.preview-strip img, .preview-strip video { height: 180px; border-radius: 10px; flex-shrink: 0; }
.hub-strip { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0; }
.hub-strip img, .hub-strip video { height: 110px; border-radius: 8px; flex-shrink: 0; }
#preview-caption-text, #preview-tags { white-space: pre-wrap; }
/* リール/TikTok/ショートは縦長(9:16)の再生枠が前提。横長・正方形の動画をそのまま
   投稿すると実際には黒帯（レターボックス）付きで表示されるため、プレビューの
   時点からその見え方どおりに表示する（object-fit:containで黒帯を再現） */
video.post-image, .preview-strip video, .hub-strip video {
  aspect-ratio: 9 / 16;
  width: auto;
  object-fit: contain;
  background: #000;
}
video.post-image { height: 320px; max-width: 100%; }

/* 表紙レイヤーエディタ */
#editor-canvas-wrap { display: flex; justify-content: center; }
#editor-canvas {
  position: relative; width: 100%; max-width: 420px;
  background-color: #0f172a; background-size: cover; background-position: center;
  border-radius: 10px; overflow: hidden; touch-action: none; user-select: none;
}
.editor-layer {
  position: absolute; cursor: grab; line-height: 1.4; white-space: pre-wrap;
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
}
.editor-layer.is-selected { outline: 2px dashed var(--accent2); outline-offset: 2px; }
.editor-layer.has-scrim { background: rgba(0, 0, 0, 0.45); border-radius: 0.25em; padding: 0.35em 0.5em; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 999px; border: 2px solid var(--border); cursor: pointer;
}
.color-swatch.is-active { border-color: var(--accent); }
#layer-panel { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.chip.is-on { background: var(--accent); color: #fff; border-color: var(--accent); }

.tagline { margin: 2px 0 0; font-size: 0.72rem; color: rgba(255, 255, 255, 0.85); }

/* 初回ガイドツアー（コーチマーク） */
#coach-highlight {
  position: fixed; z-index: 90; pointer-events: none;
  border: 3px solid var(--accent2); border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.55);
  transition: all 0.25s ease;
}
#coach-tooltip {
  position: fixed; z-index: 91; background: #fff; border-radius: 14px;
  padding: 16px; max-width: 320px; width: calc(100% - 32px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
#coach-tooltip p { margin: 0 0 12px; font-size: 0.95rem; line-height: 1.7; }

/* 投稿ハブ：グループ（1コンテンツ→SNS別の配信チェックリスト） */
.hub-group { padding: 12px 0; border-bottom: 1px solid var(--border); }
.hub-group:last-child { border-bottom: none; }
.hub-platform-row {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px; border: 1px solid var(--border); border-radius: 10px; margin-top: 8px;
}
.hub-platform-row.is-posted { background: #f0fdf4; border-color: #bbf7d0; }
.hub-platform-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hub-platform-head .status-done { color: var(--ok); font-weight: 700; font-size: 0.85rem; }
.hub-caption { color: var(--muted); font-size: 0.88rem; white-space: pre-wrap; margin: 0; }
#hub-summary { font-size: 0.95rem; line-height: 1.7; }
#hub-summary strong { color: var(--accent); font-size: 1.2rem; }

/* 写真の調整（明るさ・切り抜き） */
#adjust-canvas-wrap { display: flex; justify-content: center; }
#adjust-canvas { max-width: 100%; max-height: 420px; border-radius: 10px; background: #000; display: block; }

/* キーボード操作のフォーカスを常に見えるように（a11y） */
button:focus-visible, a:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent2);
  outline-offset: 2px;
}

/* --- 標準共通シェル: 右上の人アカウントメニュー ------------------------------- */
.header-row { position: relative; }
.header-actions { display: flex; gap: 6px; flex: none; }
.account-btn {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.15);
  color: #fff; font-weight: 700; cursor: pointer; flex: none;
}
.account-btn:hover { background: rgba(255, 255, 255, 0.25); }
.account-menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  background: #fff; color: #1f2937; border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.3); padding: 10px; min-width: 200px;
  display: flex; flex-direction: column; gap: 4px;
}
.account-menu-email { margin: 0 0 4px; padding: 0 8px; font-size: 0.8rem; color: #6b7280; }
.account-menu-link {
  display: block; padding: 8px; border-radius: 8px; border: none; background: none;
  color: #1f2937; text-align: left; font-size: 0.9rem; text-decoration: none; cursor: pointer;
}
.account-menu-link:hover { background: #f3f4f6; }

/* --- フォーム部品標準: ネイティブ部品をブラウザ標準のままにせずアプリ色に --------- */
input[type="radio"], input[type="checkbox"] { accent-color: var(--accent); }
input[type="file"] {
  width: 100%; padding: 10px; box-sizing: border-box;
  border: 1px dashed var(--border); border-radius: 10px;
  background: var(--bg); color: var(--muted); font-size: 0.88rem; cursor: pointer;
}
input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 9px 14px;
  border: 1px solid var(--accent); border-radius: 999px;
  background: var(--card, #fff); color: var(--accent);
  font-weight: 700; font-size: 0.88rem; cursor: pointer; font-family: inherit;
}
input[type="file"]::file-selector-button:hover {
  background: color-mix(in srgb, var(--accent) 8%, #fff);
}

/* --- タップ領域標準（§11: 44px以上）------------------------------------- */
/* ヘッダーの丸ボタン（？・人）とタブは指で確実に押せるサイズにする */
.help-btn, .btn-help, .header-icon-btn, .account-btn, .icon-btn {
  min-width: 44px; min-height: 44px;
}
.help-btn, .btn-help, .header-icon-btn, .account-btn {
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
}
.tab { min-height: 44px; }
.coach-controls button, #coach-next, #coach-back, #coach-skip { min-height: 44px; min-width: 44px; }

/* --- 共通チュートリアル（tour.js が使う。全アプリ同一の見た目）------------- */
#ls-tour-highlight {
  position: fixed; z-index: 10001; border-radius: 12px;
  box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.6);
  transition: left .25s ease, top .25s ease, width .25s ease, height .25s ease;
  pointer-events: none;
}
#ls-tour-tooltip {
  position: fixed; z-index: 10002; width: 280px; max-width: calc(100vw - 24px);
  background: #fff; color: #1f2937; border-radius: 14px; padding: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
}
#ls-tour-tooltip[hidden], #ls-tour-highlight[hidden] { display: none !important; }
.ls-tour-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
#ls-tour-step { font-size: .72rem; font-weight: 700; color: #6b7280; letter-spacing: .02em; }
#ls-tour-skip {
  background: none; border: none; color: #6b7280; font-size: .95rem; line-height: 1;
  cursor: pointer; min-width: 44px; min-height: 44px;
}
#ls-tour-tooltip p { margin: 0 0 12px; font-size: .93rem; line-height: 1.6; color: #1f2937; }
.ls-tour-controls { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
#ls-tour-back, #ls-tour-next {
  min-height: 44px; padding: 10px 18px; border-radius: 10px; font-size: .9rem;
  font-weight: 700; cursor: pointer; font-family: inherit;
}
#ls-tour-back { background: #fff; border: 1px solid #e5e7eb; color: #4b5563; }
#ls-tour-back:disabled { visibility: hidden; }
#ls-tour-next { border: none; background: var(--accent, #7c3aed); color: #fff; }

/* ヘッダーのサービスシンボル。色ベタのヘッダーに白の透過SVGを重ねる。
   高さは見出しの文字に追従させる（em指定）ので、文字サイズを変えても崩れない。 */
.app-logo {
  height: 1.05em; width: auto; flex: none;
  vertical-align: -0.15em; margin-right: .4em;
}

/* 使い方の案内の「何歩目か」。他のログシリーズと同じ見た目 */
.coach-step-label {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* ---- ヘッダーのサービス名（全アプリ共通）------------------------------------
   押すとそのサービスのホームへ戻る。log-series 表記はフッターだけに置く。 */
.app-home {
  display: inline-flex; align-items: center; gap: 8px;
  color: inherit; text-decoration: none;
}
.app-home:hover { opacity: .85; }
.series-mark { flex: none; }

/* フッターの log-series も同じ見え方に揃える（色は文字色まかせ） */
.footer-home {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 10px auto 0; color: inherit; text-decoration: none;
  opacity: .7; font-size: .82rem; font-weight: 700;
}
.footer-home:hover, .footer-home:focus-visible { opacity: 1; }
