:root {
  /* 端末のライト・ダーク設定にかかわらず、いつも黒い背景で表示する */
  --bg: #0b0a0d;
  --card: #1a171e;
  --ink: #f3eff6;
  --sub: #a59fae;
  --line: #322c38;
  --accent: #ff4f8b;
  --accent2: #833ab4;
  --grad: linear-gradient(120deg, #f58529 0%, #dd2a7b 45%, #8134af 100%);
  --soft: #34202c;
  --warn: #3a3020;
  --warn-line: #6b5826;
  --danger: #ff6b6b;
  --radius: 16px;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--card);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .02em; }

main { max-width: 560px; margin: 0 auto; padding: 16px; }
.boot { text-align: center; color: var(--sub); padding: 80px 0; }

.hero { padding: 12px 4px 20px; }
.hero h1 { font-size: 28px; line-height: 1.35; margin: 8px 0 10px; }
.hero p { color: var(--sub); margin: 0 0 16px; }
.flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.flow li { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.flow b { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 14px; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 16px; margin-bottom: 14px;
}
h2 { font-size: 17px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h2 small { font-weight: 400; color: var(--sub); font-size: 13px; }
.page-title { font-size: 20px; margin: 4px 0 6px; }
.num { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--grad); color: #fff; font-size: 13px; }
.label { font-size: 13px; font-weight: 700; color: var(--sub); margin: 14px 0 8px; }
.hint { font-size: 13px; color: var(--sub); margin: 6px 0; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row-between h2 { margin: 8px 0; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: 13px; font-weight: 700; color: var(--sub); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
  padding: 12px; font-size: 16px; outline: none; appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--sub) 50%), linear-gradient(135deg, var(--sub) 50%, transparent 50%); background-position: calc(100% - 18px) 52%, calc(100% - 13px) 52%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
textarea { resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0 12px; font-size: 15px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

button, .button {
  border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; cursor: pointer;
  touch-action: manipulation; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--grad); color: #fff; }
.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.danger { color: var(--danger); }
.danger-btn { background: var(--danger); color: #fff; }
.link { background: none; border: 0; color: var(--accent); padding: 10px 4px; font-weight: 600; }
.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.block { display: flex; width: 100%; margin: 8px 0; }
.big { padding: 16px; font-size: 17px; border-radius: 14px; }

.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.tabs button { background: transparent; color: var(--sub); padding: 10px; }
.tabs button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.notice { background: var(--soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; display: grid; gap: 8px; font-size: 14px; }
.notice.warn { background: var(--warn); border: 1px solid var(--warn-line); }
.notice button { justify-self: start; }

.picker {
  display: flex; align-items: center; gap: 12px; padding: 16px; border: 2px dashed var(--line); border-radius: 14px;
  cursor: pointer; font-weight: 700; position: relative; overflow: hidden;
}
.picker input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.picker small { display: block; font-weight: 400; color: var(--sub); font-size: 12px; }
.picker-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--grad); color: #fff; font-size: 26px; flex: none; }
.picker.slim { padding: 12px; margin-bottom: 12px; font-weight: 600; font-size: 14px; }

.assets { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.assets li { position: relative; aspect-ratio: 9 / 16; border-radius: 10px; overflow: hidden; background: #000; }
.assets img { width: 100%; height: 100%; object-fit: cover; display: block; }
.assets .badge { position: absolute; left: 6px; bottom: 6px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; padding: 2px 6px; border-radius: 6px; }
.assets .idx { position: absolute; left: 6px; top: 6px; background: rgba(0, 0, 0, .6); color: #fff; font-size: 11px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; }
.assets .remove { position: absolute; right: 4px; top: 4px; width: 28px; height: 28px; padding: 0; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 16px; }
.assets .loading { display: grid; place-items: center; color: #fff; font-size: 12px; height: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--bg); border: 1px solid var(--line); color: var(--ink); padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 14px; }
.chip.active { background: var(--ink); color: var(--card); border-color: var(--ink); }
.segment { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--bg); border-radius: 12px; padding: 4px; }
.segment button { background: transparent; color: var(--sub); padding: 10px 0; }
.segment button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

.scenes { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.scene { display: grid; grid-template-columns: 64px 1fr; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.scene .thumb { width: 64px; aspect-ratio: 9 / 16; border-radius: 8px; object-fit: cover; background: var(--bg); display: block; }
.scene .thumb.missing { display: grid; place-items: center; font-size: 11px; color: var(--sub); text-align: center; }
.scene .meta { font-size: 12px; color: var(--sub); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.scene input, .scene textarea { padding: 9px 10px; font-size: 15px; margin-bottom: 6px; }
.scene .tools { display: flex; gap: 6px; }
.scene .tools button { padding: 4px 10px; font-size: 12px; }

.key-status { padding: 12px; border-radius: 12px; background: var(--bg); margin-bottom: 12px; font-size: 14px; }
.key-status.ok { background: #1e3a24; background: color-mix(in srgb, #2e7d32 12%, var(--card)); }
.guide { background: var(--bg); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.guide ol { padding-left: 20px; margin: 8px 0; }
details { margin: 10px 0; }
summary { cursor: pointer; font-weight: 700; padding: 6px 0; }

.history { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.history li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.history .h-main { flex: 1; min-width: 0; cursor: pointer; }
.history .h-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history .h-date { font-size: 12px; color: var(--sub); }
.history .empty { justify-content: center; color: var(--sub); }

.render-card { padding: 12px; }
.stage { width: min(100%, 300px); margin: 0 auto 12px; aspect-ratio: 9 / 16; background: #000; border-radius: 12px; overflow: hidden; }
.stage canvas, .stage video { width: 100%; height: 100%; display: block; object-fit: contain; }
.progress-label { font-weight: 700; text-align: center; margin-bottom: 8px; }
.bar { height: 8px; border-radius: 99px; background: var(--bg); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .2s; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--card);
  background: color-mix(in srgb, var(--card) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabbar button { background: none; flex-direction: column; gap: 0; color: var(--sub); font-size: 12px; padding: 6px; }
.tabbar button span { font-size: 20px; line-height: 1.2; }
.tabbar button.active { color: var(--accent); }

.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(20, 12, 26, .55); display: grid; place-items: center; padding: 24px; }
.busy-box { background: var(--card); border-radius: 18px; padding: 24px; text-align: center; width: min(320px, 100%); }
.busy-box p { font-weight: 700; margin: 14px 0 4px; }
.busy-box small { color: var(--sub); }
.spinner { width: 44px; height: 44px; margin: 0 auto; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: var(--card); padding: 10px 16px; border-radius: 12px; font-size: 14px; max-width: calc(100% - 32px); box-shadow: var(--shadow);
}
.foot-links { text-align: center; font-size: 13px; color: var(--sub); }
.foot-links a { color: var(--sub); }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.doc h2 { margin-top: 18px; }
.doc ul { padding-left: 20px; }
a.brand-link { color: inherit; text-decoration: none; }
.media-pool { position: fixed; left: 0; top: 0; width: 2px; height: 2px; overflow: hidden; opacity: 0; pointer-events: none; z-index: -1; }
.media-pool video { width: 2px; height: 2px; }
.badge-pill { font-size: 11px; font-weight: 700; color: var(--sub); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }

/* 最後の PR シーン */
#endMode { grid-template-columns: 1fr 1fr; margin-bottom: 12px; }
#endSeconds { grid-template-columns: repeat(3, 1fr); margin-bottom: 8px; }
.end-layout { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.end-preview { width: 38%; max-width: 170px; aspect-ratio: 9 / 16; height: auto; border-radius: 12px; border: 1px solid var(--line); background: #000; flex: none; }
.end-side { flex: 1; min-width: 0; }
.tpl-list { display: grid; gap: 8px; }
.tpl-list button { background: var(--bg); border: 1px solid var(--line); color: var(--ink); padding: 10px 12px; border-radius: 12px; font-weight: 600; font-size: 14px; text-align: left; }
.tpl-list button.active { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
#endIconRow { margin-bottom: 4px; }
#endIconRow .picker { margin-bottom: 0; }
.grow { flex: 1; min-width: 0; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; margin: 0; }
.vol { color: var(--ink); margin-left: 6px; }
#endSoundOpts { align-items: flex-end; }
#endSoundOpts .field { margin-bottom: 4px; }
#endSoundOpts button { margin-bottom: 6px; }

/* 使う範囲を選ぶ */
.crop-box { background: var(--card); border-radius: 18px; padding: 16px; width: min(560px, 100%); max-height: 100%; overflow: auto; }
.crop-box h2 { margin: 0 0 4px; }
.crop-src { display: block; max-width: 100%; max-height: 42vh; margin: 8px auto 12px; border-radius: 10px; touch-action: none; cursor: grab; background: #000; }
.crop-row { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; }
.crop-out { width: 34%; max-width: 150px; aspect-ratio: 9 / 16; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #000; flex: none; }
.crop-controls { flex: 1; min-width: 0; }
.scene .thumb-btn { padding: 0; border: 0; background: none; position: relative; display: block; width: 64px; }
.scene .thumb-btn canvas { width: 64px; aspect-ratio: 9 / 16; height: auto; border-radius: 8px; display: block; background: var(--bg); }
.scene .thumb-btn span { position: absolute; left: 4px; right: 4px; bottom: 4px; font-size: 10px; font-weight: 700; background: rgba(0,0,0,.65); color: #fff; border-radius: 6px; padding: 2px 0; text-align: center; }
#cropSheet { padding: 10px; }
input[type=range]:focus { box-shadow: none; border: 0; }
#cropWhich { grid-template-columns: 1fr 1fr; margin-bottom: 10px; }
#cropWhich button[data-which=end].active { color: #ff8fb6; }
.text-size { margin-top: 12px; }
#sizeTarget { grid-template-columns: repeat(3, 1fr); margin-bottom: 4px; }
#sizeWhich { grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
#sizeWhich button[data-which=to].active { color: #ff8fb6; }
.field > .range-row, .range-row { display: flex; align-items: center; gap: 10px; }
.range-row .vol { min-width: 44px; text-align: right; }

/* Google でログイン */
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; background: #fff; color: #1f1f1f; border-radius: 12px; padding: 13px 16px; font-weight: 700; font-size: 16px; text-decoration: none; }
.google-btn:active { opacity: .85; }
.or { display: flex; align-items: center; gap: 10px; color: var(--sub); font-size: 12px; margin: 14px 0 12px; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }

/* トップの「使い方」 */
.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.how-btn { flex: none; display: grid; justify-items: center; gap: 4px; padding: 14px 18px; min-width: 112px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); color: var(--ink); text-decoration: none; position: relative; }
.how-btn::before { content: ''; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; background: var(--grad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.how-btn svg { color: var(--accent); }
.how-btn b { font-size: 16px; }
.how-btn small { font-size: 11px; color: var(--sub); }
.how-btn:active { opacity: .85; }
#textStyles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
#textStyles button { text-align: center; padding: 9px 4px; font-size: 13px; }
#textStyles [data-style=comic] { font-family: "Mochiy Pop One", sans-serif; font-weight: 400; }
#textStyles [data-style=neon] { font-family: "Zen Maru Gothic", sans-serif; font-weight: 900; color: #ffd9f6; text-shadow: 0 0 6px #ff3fd2; }
#textStyles [data-style=colorful] { font-family: "Dela Gothic One", sans-serif; font-weight: 400; color: #ffb400; }
#textStyles [data-style=elegant] { font-family: "Shippori Mincho", serif; font-weight: 600; color: #e2c06a; letter-spacing: .12em; }
#textStyles [data-style=gym] { font-family: "Dela Gothic One", sans-serif; font-weight: 400; color: #ffd400; font-style: italic; background: repeating-linear-gradient(-45deg, #1b1b1b 0 10px, #26231a 10px 20px); }
#textStyles [data-style=dog] { font-family: "Zen Maru Gothic", sans-serif; font-weight: 900; color: #ffcd96; }
#textStyles [data-style=cat] { font-family: "Zen Maru Gothic", sans-serif; font-weight: 900; color: #ffc4d6; }
#textStyles [data-style=bird] { font-family: "Zen Maru Gothic", sans-serif; font-weight: 900; color: #b2ecd6; }
#textStyles [data-style=speed] { font-family: "Dela Gothic One", sans-serif; font-weight: 400; color: #fff; font-style: italic; text-shadow: -3px 0 0 #e1251b; }
#textStyles [data-style=autumn] { font-family: "Shippori Mincho", serif; font-weight: 600; color: #f0a63a; }
#textStyles [data-style=winter] { font-family: "Zen Maru Gothic", sans-serif; font-weight: 900; color: #e8f6ff; text-shadow: 0 0 6px #6cc3ff; }
#textStyles [data-style=xmas] { font-family: "Shippori Mincho", serif; font-weight: 600; color: #ffe39a; text-shadow: 0 0 1px #e1251b, 1px 1px 0 #7d0f1c; }
#textStyles [data-style=xmas_pop] { font-family: "Mochiy Pop One", sans-serif; font-weight: 400; color: #ff5a6a; }
#textStyles [data-style=xmas_light] { font-family: "Zen Maru Gothic", sans-serif; font-weight: 900; color: #fff3c4; text-shadow: 0 0 6px #ffb84d; }
#textStyles [data-style=brush] { font-family: "Yuji Syuku", serif; font-weight: 400; font-size: 15px; }

/* 言語の切り替え */
.top { gap: 12px; }
.lang-pick { margin-left: auto; display: flex; align-items: center; gap: 4px; color: var(--sub); }
.lang-pick select { width: auto; padding: 6px 26px 6px 8px; font-size: 13px; border-radius: 10px; background-color: var(--bg); background-position: calc(100% - 13px) 52%, calc(100% - 8px) 52%; }
.out-lang { margin-top: 14px; }

/* 写真・動画を重ねる */
#insetSheet { padding: 10px; }
.inset-pick { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; margin-bottom: 4px; }
.inset-pick button, .inset-pick label { flex: none; width: 64px; height: 64px; border-radius: 10px; padding: 0; border: 2px solid transparent; background: var(--bg); position: relative; overflow: hidden; }
.inset-pick img { width: 100%; height: 100%; object-fit: cover; display: block; }
.inset-pick button.active { border-color: var(--accent); }
.inset-pick .badge { position: absolute; left: 3px; bottom: 3px; font-size: 10px; font-weight: 700; background: rgba(0,0,0,.65); color: #fff; border-radius: 5px; padding: 1px 4px; }
.inset-pick label { display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--sub); text-align: center; line-height: 1.3; border: 2px dashed var(--line); cursor: pointer; }
.inset-pick label input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.inset-out { touch-action: none; cursor: grab; }
#insetShape, #insetAnim { grid-template-columns: repeat(3, 1fr); margin-bottom: 10px; }
.scene .tools button.on { color: var(--accent); border-color: var(--accent); }

/* レイヤー */
.layer-tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 6px 0 14px; padding: 0 2px; }
.layer-tabs button { flex: none; background: var(--bg); color: var(--sub); border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; padding: 9px 16px; font-size: 14px; margin-bottom: -1px; }
.layer-tabs button.active { background: var(--card); color: var(--ink); font-weight: 700; border-color: var(--line); box-shadow: inset 0 3px 0 var(--accent); position: relative; }
.layer-tabs button.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--card); }
.layer-tabs button.add { color: var(--accent); background: transparent; border-style: dashed; font-size: 17px; padding: 6px 16px; }
.layer-clips { list-style: none; margin: 0 0 12px; padding: 0; }
.layer-clips li { display: grid; grid-template-columns: 64px 1fr; gap: 10px; border-top: 1px solid var(--line); padding: 12px 0; }
.layer-clips li:first-child { border-top: 0; }
.layer-clips canvas { width: 64px; height: 64px; border-radius: 8px; background: var(--bg); display: block; }
.layer-clips .meta { font-size: 12px; color: var(--sub); display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 4px; }
.layer-clips .tools { display: flex; gap: 6px; }
.layer-clips .tools button { padding: 4px 10px; font-size: 12px; }
.layer-clips label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--sub); }
.layer-clips label b { min-width: 56px; color: var(--ink); font-weight: 700; }
.layer-clips input[type=range] { flex: 1; }
#layerPanel .wide { width: 100%; margin-top: 8px; }

.card.dimmed { opacity: .35; pointer-events: none; filter: grayscale(.4); }
.voice-row { display: flex; gap: 8px; }
.voice-row select { flex: 1; min-width: 0; }
.voice-row button { flex: none; padding: 0 14px; white-space: nowrap; }
.scene .meta .time { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 700; }
.layer-clips .time { font-variant-numeric: tabular-nums; }


/* AI の設定を戻す・場面を足す */
.ai-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: var(--soft); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }
.ai-bar button { flex: none; }
#addScene { margin-top: 12px; }
#addSceneSheet { padding: 10px; }
.scene .start-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--sub); margin-bottom: 6px; }
.scene .start-row input { flex: 1; }
.scene .start-row b { min-width: 52px; color: var(--ink); font-variant-numeric: tabular-nums; }

/* 履歴から開いたときの、選び直す素材の案内 */
.need-media { margin-bottom: 14px; }
.need-media b { display: block; margin-bottom: 4px; }
.need-media p { margin: 0 0 10px; font-size: 13px; }
.need-list { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.need-list li { display: flex; align-items: center; gap: 6px; background: rgba(0,0,0,.25); border-radius: 10px; padding: 4px 10px 4px 4px; font-size: 13px; }
.need-list img, .need-list .ph { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex: none; background: rgba(255,255,255,.08); }
.need-list b { margin: 0; }
/* 選び直すボタンを、ボタンらしく目立たせる */
.need-media .picker { background: var(--grad); border: 0; color: #fff; justify-content: center; text-align: center; font-weight: 800; font-size: 16px; padding: 16px; margin-bottom: 0; }
.need-media .picker span::before { content: "＋ "; }

/* トップの「無料の Gemini API でも使えます！」 */
.hero-title { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; }
.hero-title h1 { flex: 0 1 auto; }
.free-badge { flex: none; text-align: center; background: var(--grad); color: #fff; font-weight: 800; font-size: 15px; line-height: 1.35; padding: 10px 14px; border-radius: 18px; transform: rotate(-4deg); box-shadow: 0 6px 18px rgba(221, 42, 123, .35); margin-bottom: 8px; }
/* スマホでも、見出しの右にバッジを並べたまま（PC と同じ並び）。画面の幅に合わせて文字を小さくする */
@media (max-width: 520px) {
  .hero-title { flex-wrap: nowrap; gap: 8px; }
  .hero-title h1 { min-width: 0; font-size: clamp(17px, 5.3vw, 26px); }
  .free-badge { font-size: clamp(10px, 3vw, 13px); padding: 7px 9px; border-radius: 12px; transform: rotate(-4deg); margin-bottom: 4px; }
}

/* トップの「API キーが必要です」 */
.hero .need-key { margin: 22px 0 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 14px; color: var(--sub); }
.hero .need-key b { color: var(--ink); }

#useLastMedia { margin-top: 10px; }

.media-note { margin: 10px 2px 0; font-size: 12px; }

/* 生成の画面：カバー画像 */
.cover-box { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; text-align: left; }
.cover-box img { width: 84px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 8px; flex: none; background: #000; }
.cover-box > div { flex: 1; min-width: 0; }
.cover-box .cover-title { margin: 0 0 2px; font-weight: 700; }
.cover-box .hint { margin: 0 0 8px; }
.cover-box .button, .cover-box button { margin-bottom: 4px; }
.cover-box .link { display: inline-block; font-size: .85em; }

/* 設定画面：使い方へのリンク */
.manual-link { display: flex; align-items: center; gap: 12px; padding: 14px 16px; margin-bottom: 14px; border-radius: var(--radius); background: var(--card); color: var(--ink); text-decoration: none; position: relative; }
.manual-link::before { content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; background: var(--grad); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; pointer-events: none; }
.manual-link svg { color: var(--accent); flex: none; }
.manual-link span { flex: 1; min-width: 0; display: grid; gap: 2px; }
.manual-link b { font-size: 16px; }
.manual-link small { font-size: 12px; color: var(--sub); }
.manual-link i { font-style: normal; font-size: 24px; color: var(--sub); }
.manual-link:active { opacity: .85; }

/* 幅の狭いスマホでも、トップページの並び（アプリ名・手順・使い方ボタン・タブ）を PC と同じに保つ */
@media (max-width: 400px) {
  .brand { white-space: nowrap; font-size: clamp(14px, 4.2vw, 17px); }
  .flow li { font-size: clamp(12px, 3.7vw, 15px); gap: 8px; }
  .flow b { width: 24px; height: 24px; font-size: 12px; flex: none; }
  .how-btn { min-width: 0; padding: 12px 12px; }
  .tabs button { white-space: nowrap; padding: 10px 4px; font-size: clamp(12px, 3.8vw, 15px); }
  .top { gap: 6px; }
  .lang-pick { min-width: 0; flex-shrink: 1; }
  .lang-pick svg { display: none; }
  .lang-pick select { min-width: 0; max-width: 34vw; }
}

/* 広告枠（中身は広告サービスを決めてから入れる。今は場所だけ） */
.ad-slot { position: relative; display: grid; place-items: center; margin: 0 auto 14px; border: 1px dashed var(--line); border-radius: 12px; background: rgba(255, 255, 255, .03); color: var(--sub); overflow: hidden; }
.ad-slot[hidden] { display: none; }
.ad-label { position: absolute; top: 4px; left: 8px; font-size: 10px; letter-spacing: .05em; opacity: .8; }
.ad-ph { font-size: 12px; opacity: .6; }
.ad-banner { width: 100%; max-width: 728px; min-height: 100px; }
.ad-rect { width: 300px; max-width: 100%; height: 250px; margin: 0; background: var(--card); }
#busy { grid-auto-flow: row; align-content: center; gap: 16px; }

/* 広告：夫婦（めおと）エージェント */
.ad-filled { border: 0; background: none; display: block; }
.ad-filled .ad-label { top: 6px; left: auto; right: 8px; padding: 1px 6px; border-radius: 6px; background: rgba(0, 0, 0, .35); color: #fff; font-size: 10px; z-index: 2; }
.ad-meoto { position: relative; display: flex; align-items: center; min-height: 100px; padding: 10px 0 10px 14px; border-radius: 14px; overflow: hidden; text-decoration: none; color: #3a2a1c;
  background: linear-gradient(110deg, #fffaf2 0%, #ffeedb 55%, #ffd9b0 100%); box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.ad-meoto:active { opacity: .9; }
.ad-meoto-text { flex: 1; min-width: 0; display: grid; gap: 3px; position: relative; z-index: 1; padding-right: 118px; }
.ad-meoto-text small { font-size: 11px; font-weight: 700; color: #c2611a; letter-spacing: .02em; }
.ad-meoto-text b { font-size: 15.5px; line-height: 1.3; font-weight: 900; color: #2c1d10; }
.ad-meoto-text > span { font-size: 11px; font-weight: 700; color: #6b5442; }
.ad-meoto-cta { display: none; font-style: normal; }
.ad-meoto-couple { position: absolute; right: -4px; bottom: 0; height: 100%; width: auto; max-height: 130px; }
@media (min-width: 480px) {
  .ad-meoto { padding: 14px 0 14px 20px; }
  .ad-meoto .sp { display: none; }
  .ad-meoto-text { padding-right: 150px; gap: 5px; }
  .ad-meoto-text b { font-size: 20px; }
  .ad-meoto-text small, .ad-meoto-text > span { font-size: 12px; }
  .ad-meoto-cta { display: inline-block; margin-left: 8px; padding: 4px 12px; border-radius: 999px; background: #e8751f; color: #fff; font-weight: 800; font-size: 12px; box-shadow: 0 2px 8px rgba(232, 117, 31, .4); }
}

.ad-meoto[hidden] { display: none; }
/* B・C：写真を右に敷いて、左側をぼかして文字とつなぐ */
.ad-meoto-photo { position: absolute; right: 0; top: 0; height: 100%; width: 44%; object-fit: cover; -webkit-mask-image: linear-gradient(to right, transparent, #000 38%); mask-image: linear-gradient(to right, transparent, #000 38%); }
.ad-meoto-b .ad-meoto-text, .ad-meoto-c .ad-meoto-text { padding-right: 36%; }
.ad-meoto-b { background: linear-gradient(110deg, #f5f9ff 0%, #e4eefc 100%); }
.ad-meoto-b .ad-meoto-text small { color: #2a62c9; }
.ad-meoto-b .ad-meoto-text b { color: #13284f; }
.ad-meoto-b .ad-meoto-text > span { color: #4b5d7d; }
.ad-meoto-b .ad-meoto-cta { background: #2a62c9; box-shadow: 0 2px 8px rgba(42, 98, 201, .4); }
.ad-meoto-c { background: linear-gradient(110deg, #f7fcf3 0%, #e3f2d8 100%); }
.ad-meoto-c .ad-meoto-text small { color: #3f8a2a; }
.ad-meoto-c .ad-meoto-text b { color: #1e3a14; }
.ad-meoto-c .ad-meoto-text > span { color: #4f6446; }
.ad-meoto-c .ad-meoto-cta { background: #3f8a2a; box-shadow: 0 2px 8px rgba(63, 138, 42, .4); }
@media (min-width: 480px) {
  .ad-meoto-photo { width: 40%; }
  .ad-meoto-b .ad-meoto-text, .ad-meoto-c .ad-meoto-text { padding-right: 34%; }
}
.ad-meoto { width: 100%; }
.ad-meoto-c .ad-meoto-photo { width: 54%; -webkit-mask-image: linear-gradient(to right, transparent, #000 22%); mask-image: linear-gradient(to right, transparent, #000 22%); }
.ad-meoto-c .ad-meoto-text { padding-right: 47%; }
.ad-meoto-c .ad-meoto-text b { font-size: 14px; }
@media (min-width: 480px) {
  .ad-meoto-c .ad-meoto-photo { width: 46%; }
  .ad-meoto-c .ad-meoto-text { padding-right: 40%; }
  .ad-meoto-c .ad-meoto-text b { font-size: 19px; }
}
.ad-meoto-c .ad-meoto-photo { width: 58%; object-position: 70% 30%; -webkit-mask-image: linear-gradient(to right, transparent, #000 30%); mask-image: linear-gradient(to right, transparent, #000 30%); }
@media (min-width: 480px) { .ad-meoto-c .ad-meoto-photo { width: 50%; } }
.ad-meoto .xs { display: none; }
@media (max-width: 380px) { .ad-meoto .xs { display: inline; } .ad-meoto-c .ad-meoto-text { padding-right: 52%; } }
@media (max-width: 380px) { .ad-meoto-c .ad-meoto-text > span { font-size: 10.5px; white-space: nowrap; letter-spacing: -.02em; } }
.ad-meoto-c .ad-meoto-text b { font-size: 15.5px; }
@media (min-width: 480px) { .ad-meoto-c .ad-meoto-text b { font-size: 20px; } }
/* C：写真は縦いっぱい・横は元の比率のまま右に寄せる（男性の顔にぼかしがかからないよう、ぼかしは左端だけ） */
.ad-meoto-c .ad-meoto-photo { width: auto; max-width: 56%; object-fit: cover; object-position: 100% 30%; -webkit-mask-image: linear-gradient(to right, transparent, #000 7%); mask-image: linear-gradient(to right, transparent, #000 7%); }
.ad-meoto-c .ad-meoto-text { padding-right: 54%; }
.ad-meoto-c .ad-meoto-text small { font-size: 10.5px; white-space: nowrap; letter-spacing: -.02em; }
.ad-meoto-c .ad-meoto-text > span { font-size: 10.5px; white-space: nowrap; letter-spacing: -.02em; }
@media (min-width: 480px) {
  .ad-meoto-c .ad-meoto-photo { max-width: 46%; }
  .ad-meoto-c .ad-meoto-text { padding-right: 44%; }
  .ad-meoto-c .ad-meoto-text small, .ad-meoto-c .ad-meoto-text > span { font-size: 12px; letter-spacing: 0; }
}
@media (max-width: 380px) { .ad-meoto-c .ad-meoto-text > span, .ad-meoto-c .ad-meoto-text small { font-size: 9.8px; } }

/* ローディング中の広告（300×250）：夫婦（めおと）エージェント */
.ad-rect.ad-filled { background: none; border: 0; border-radius: 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); }
.ad-rm { display: grid; grid-template-rows: 138px 1fr; width: 100%; height: 100%; border-radius: 14px; overflow: hidden; text-decoration: none; color: #3a2a1c; background: #fffaf2; }
.ad-rm[hidden] { display: none; }
.ad-rm-pic { position: relative; overflow: hidden; display: block; }
.ad-rm-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ad-rm-body { display: grid; align-content: center; gap: 4px; padding: 8px 14px 10px; text-align: left; }
.ad-rm-body small { font-size: 10.5px; font-weight: 700; letter-spacing: .02em; }
.ad-rm-body b { font-size: 17px; line-height: 1.28; font-weight: 900; }
.ad-rm-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 2px; }
.ad-rm-row > span { font-size: 10px; font-weight: 700; opacity: .85; line-height: 1.3; }
.ad-rm-row i { flex: none; font-style: normal; font-size: 11px; font-weight: 800; color: #fff; padding: 5px 10px; border-radius: 999px; }
.ad-rm-a { background: linear-gradient(160deg, #fffaf2 0%, #ffeedb 100%); }
.ad-rm-a .ad-rm-pic { background: linear-gradient(110deg, #ffeedb, #ffd2a1); }
.ad-rm-a .ad-rm-pic img { object-fit: contain; object-position: 50% 100%; }
.ad-rm-a small { color: #c2611a; } .ad-rm-a b { color: #2c1d10; } .ad-rm-a .ad-rm-row > span { color: #6b5442; } .ad-rm-a i { background: #e8751f; }
.ad-rm-b { background: linear-gradient(160deg, #f5f9ff 0%, #e4eefc 100%); }
.ad-rm-b .ad-rm-pic img { object-position: 60% 40%; }
.ad-rm-b small { color: #2a62c9; } .ad-rm-b b { color: #13284f; } .ad-rm-b .ad-rm-row > span { color: #4b5d7d; } .ad-rm-b i { background: #2a62c9; }
.ad-rm-c { background: linear-gradient(160deg, #f7fcf3 0%, #e3f2d8 100%); }
.ad-rm-c .ad-rm-pic img { object-position: 50% 35%; }
.ad-rm-c small { color: #3f8a2a; } .ad-rm-c b { color: #1e3a14; } .ad-rm-c .ad-rm-row > span { color: #4f6446; } .ad-rm-c i { background: #3f8a2a; }

/* タイトルの後ろの「Powered by MEOTO AGENT」（狭い画面ではタイトルの下に） */
.brand-name { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.powered { font-size: 11px; font-weight: 600; letter-spacing: .03em; color: var(--sub); white-space: nowrap; }
@media (max-width: 520px) {
  .brand-name { flex-direction: column; align-items: flex-start; gap: 0; line-height: 1.2; }
  .powered { font-size: 9px; }
}
#textStyles [data-style=xmas_pop], #textStyles [data-style=xmas_light] { font-size: 10.5px; white-space: nowrap; letter-spacing: -.04em; padding-left: 2px; padding-right: 2px; overflow: hidden; }
