:root {
  /* やわらかいクリーム × コーラルピンクの「かわいい」配色 */
  --bg: #fdf5ef;
  --surface: #fffdfa;
  --surface-2: #f9ebe4;
  --ink: #3b2d29;
  --ink-2: #6e5c55;
  --ink-3: #a8958c;
  --line: #f1e0d7;
  --accent: #f0706b;
  --accent-2: #e0564f;
  --accent-soft: #ffe7e2;
  --on-accent-soft: #7a2a26;
  --on-accent: #fff;
  --wave: #f0d4cb;
  --female: #d9577f;
  --female-soft: #fde3ec;
  --male: #4a86d4;
  --male-soft: #e2edfb;
  --custom: #9272dc;
  --custom-soft: #efe8fd;
  --ok: #3a9a6a;
  --err: #d9453b;
  --err-soft: #fde4e0;
  --shadow: 0 2px 0 rgba(240, 112, 107, .06), 0 6px 20px rgba(120, 60, 40, .06);
  --radius: 22px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1d1719;
    --surface: #271f22;
    --surface-2: #33292c;
    --ink: #fbeee9;
    --ink-2: #d6c1ba;
    --ink-3: #9c8780;
    --line: #3f3236;
    --accent: #ff8f89;
    --accent-2: #ffaaa5;
    --accent-soft: #4a2729;
    --on-accent-soft: #ffd9d4;
    --on-accent: #3d1110;
    --wave: #56433f;
    --female: #ff9dbd;
    --female-soft: #4a2432;
    --male: #9cc1f5;
    --male-soft: #22304a;
    --custom: #c7b2ff;
    --custom-soft: #362c4d;
    --ok: #6fd3a0;
    --err: #ff8e84;
    --err-soft: #4a211d;
    --shadow: 0 2px 0 rgba(0, 0, 0, .2), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
svg { display: block; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px 10px;
  max-width: 1280px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  border-radius: 12px; font-weight: 900; font-size: 22px;
}
.brand > div { min-width: 0; }
.brand h1 { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 19px; font-weight: 900; letter-spacing: .04em; line-height: 1.2; }
.brand p { margin: 0; font-size: 11.5px; color: var(--ink-3); white-space: nowrap; }
.top-actions { display: flex; gap: 8px; flex: none; }
.ghost-btn, .key-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; font-size: 13px; white-space: nowrap;
}
.ghost-btn svg { width: 15px; height: 15px; }
.count-pill { background: var(--surface-2); border-radius: 999px; padding: 0 7px; font-size: 11.5px; min-width: 20px; text-align: center; }
.key-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--err); }
.key-btn.ok .dot { background: var(--ok); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 4px;
  max-width: 1280px; margin: 0 auto; padding: 0 16px;
  border-bottom: 1px solid var(--line);
}
.tab {
  border: 0; background: none; padding: 10px 14px 12px;
  font-weight: 700; color: var(--ink-3); position: relative;
}
.tab.active { color: var(--ink); }
.tab.active::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px;
  height: 3px; border-radius: 3px 3px 0 0; background: var(--accent);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Layout ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
.layout { display: grid; gap: 16px; }
.controls { display: grid; gap: 12px; min-width: 0; }
.results { min-width: 0; }
@media (min-width: 1000px) {
  .layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; gap: 24px; }
  .results { position: sticky; top: 16px; max-height: calc(100vh - 120px); overflow: auto; padding-right: 4px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
  transition: border-color .2s, box-shadow .2s;
}
.card.is-multi { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.multi-badge {
  display: none; margin-left: auto;
  font-size: 11px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: 2px 8px; border-radius: 999px;
}
.card.is-multi .multi-badge { display: inline-block; }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.step-head .count { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.num {
  width: 24px; height: 24px; flex: none; display: grid; place-items: center;
  border-radius: 50%; background: var(--ink); color: var(--bg);
  font-size: 12.5px; font-weight: 700;
}
.hint { margin: 10px 0 0; font-size: 13px; color: var(--ink-2); }
.sub-label { font-size: 12.5px; font-weight: 700; color: var(--ink-2); margin: 12px 0 6px; }

.callout {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 14px 16px;
}
.callout strong { display: block; font-size: 14.5px; }
.callout p { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-2); }

/* ---------- Controls ---------- */
.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 4px;
}
.segmented button {
  border: 0; background: none; border-radius: 9px; padding: 9px 8px;
  font-weight: 700; color: var(--ink-2); font-size: 14px;
}
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; line-height: 1.3;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background .15s, border-color .15s, color .15s;
}
.chips.small .chip { padding: 4px 10px; font-size: 12.5px; }
.chip:hover { border-color: var(--ink-3); }
.chip.active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip.sel { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.chip .x { opacity: .7; font-size: 14px; line-height: 1; margin-right: -2px; }
.chip.tag { background: var(--surface-2); border-color: transparent; }
.chip.tag code { background: none; padding: 0; color: var(--ink-3); font-size: 11px; }
#sampleChips { margin-bottom: 10px; }

textarea, input:not([type=checkbox]), select {
  width: 100%;
  border: 1px solid var(--line); background: var(--bg);
  border-radius: 12px; padding: 10px 12px;
  font-size: 16px; /* iOS zoom 防止 */
  line-height: 1.6;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 96px; }
textarea:focus, input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.inline-form { display: flex; gap: 8px; margin-top: 10px; }
.inline-form input { min-width: 0; }

.primary, .secondary {
  border: 0; border-radius: 12px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap;
}
.primary { background: var(--accent); color: var(--on-accent); padding: 12px 22px; font-size: 15px; }
.primary:hover { background: var(--accent-2); }
.primary:disabled { opacity: .55; cursor: default; }
.secondary { background: var(--surface-2); color: var(--ink); padding: 10px 14px; }
.primary.sm, .secondary.sm { padding: 8px 14px; font-size: 13.5px; border-radius: 10px; }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 13px; font-weight: 700; padding: 4px 2px; white-space: nowrap; }
.link-btn.danger { color: var(--err); }
.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center;
  border: 0; background: none; border-radius: 10px; color: var(--ink-2);
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.on { color: #e0a100; }

/* ---------- Voices ---------- */
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
#catFilter { flex: 1 1 auto; min-width: 0; }
.filter-row + .filter-row { margin-bottom: 12px; }
.filter-row #recommendBtn { margin-left: auto; }
.gender-seg { flex: 1; max-width: 280px; padding: 3px; border-radius: 10px; }
.gender-seg button { padding: 6px 4px; font-size: 13.5px; border-radius: 8px; white-space: nowrap; }
.gender-seg button.active[data-g="f"] { color: var(--female); }
.gender-seg button.active[data-g="m"] { color: var(--male); }
.fav-toggle { height: 36px; font-weight: 700; }
.fav-toggle svg { width: 15px; height: 15px; color: var(--ink-3); }
.fav-toggle.on { background: color-mix(in srgb, #e0a100 16%, var(--surface)); border-color: #e0a100; color: var(--ink); }
.fav-toggle.on svg { color: #e0a100; fill: currentColor; }
.voice-grid {
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
}
@media (max-width: 400px) { .voice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.voice-card {
  position: relative; text-align: left;
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 14px; padding: 10px 44px 10px 12px;
  min-height: 84px;
  transition: border-color .15s, background .15s, transform .1s;
  user-select: none; -webkit-user-select: none;
}
.voice-card:active { transform: scale(.98); }
.voice-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.vc-name { font-weight: 700; font-size: 14.5px; line-height: 1.25; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-kana { font-size: 11px; color: var(--ink-3); line-height: 1.3; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-meta { display: flex; align-items: center; gap: 5px; margin-top: 6px; flex-wrap: wrap; }
.vc-trait { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.g-pill { font-size: 10.5px; padding: 1px 6px; border-radius: 6px; font-weight: 700; }
.g-pill.f { color: var(--female); background: var(--female-soft); }
.g-pill.m { color: var(--male); background: var(--male-soft); }
.g-pill.c { color: var(--custom); background: var(--custom-soft); }
.vc-play {
  position: absolute; right: 8px; bottom: 8px;
  width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: var(--surface-2); color: var(--ink);
  display: grid; place-items: center;
}
.vc-play svg { width: 13px; height: 13px; }
.voice-card.selected .vc-play { background: var(--surface); }
.vc-order {
  position: absolute; top: -7px; left: -7px;
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font-size: 12px; font-weight: 700; display: none; place-items: center;
}
.voice-card.selected .vc-order { display: grid; }
.vc-fav {
  position: absolute; right: 8px; top: 6px;
  width: 30px; height: 26px; border: 0; background: none; border-radius: 8px;
  display: grid; place-items: center; color: var(--ink-3);
}
.vc-fav svg { width: 16px; height: 16px; }
.vc-fav:hover { color: var(--ink); }
.vc-fav.on { color: #e0a100; }
.vc-fav.on svg { fill: currentColor; }
.vc-remove { position: absolute; right: 38px; top: 6px; height: 26px; border: 0; background: none; color: var(--ink-3); font-size: 15px; line-height: 1; padding: 0 4px; }
.voice-card.custom { padding-right: 64px; }
.fav-empty { grid-column: 1 / -1; margin: 0; padding: 16px; text-align: center; font-size: 13px; color: var(--ink-3); border: 1.5px dashed var(--line); border-radius: 14px; }


.play-state .i-pause, .play-state.playing .i-play { display: none; }
.play-state.playing .i-pause { display: block; }
.play-state.busy .i-play, .play-state.busy .i-pause { display: none; }
.play-state.busy::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { rotate: 360deg; } }

.custom-voice { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.custom-voice summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.custom-voice p { font-size: 12.5px; margin: 8px 0 0; }
@media (max-width: 520px) {
  .custom-voice .inline-form { flex-wrap: wrap; }
  .custom-voice .inline-form button { width: 100%; }
}

/* ---------- Styles ---------- */
.style-patterns { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px dashed var(--line); }
.pattern {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 10px; padding: 6px 10px; font-size: 13px; font-weight: 700; color: var(--ink-2);
}
.pattern.active { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.pattern .pnum {
  width: 20px; height: 20px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-2); font-size: 11.5px;
}
.pattern.active .pnum { background: var(--accent); color: var(--on-accent); }
.pattern .plabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pattern .x { color: var(--ink-3); font-size: 15px; line-height: 1; padding: 0 2px; }
.pattern.add { border-style: dashed; color: var(--accent); font-weight: 700; }
.style-preview {
  margin: 10px 0 0; padding: 8px 12px; border-radius: 10px;
  background: var(--surface-2); font-size: 13px; color: var(--ink-2);
}
.style-preview b { color: var(--ink); }

/* ---------- 選択中の声 ---------- */
.selected-bar {
  display: flex; align-items: flex-start; gap: 8px;
  background: var(--accent-soft); border-radius: 12px; padding: 10px 12px;
}
.sel-label { flex: none; font-size: 12.5px; font-weight: 700; color: var(--accent); line-height: 28px; }
.selected-bar .chips { flex: 1; min-width: 0; }
.chip.picked { background: var(--surface); border-color: var(--accent); font-weight: 700; }
.chip.picked .n {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-size: 11px;
}
.voice-hint { margin: 8px 0 12px; font-size: 12.5px; }
.summary .sum-line { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Models ---------- */
.model-list { display: grid; gap: 8px; }
.model-item {
  display: flex; align-items: center; gap: 12px; text-align: left;
  border: 1.5px solid var(--line); background: var(--surface);
  border-radius: 14px; padding: 10px 14px;
}
.model-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.model-check {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  border: 2px solid var(--ink-3); display: grid; place-items: center;
}
.is-multi .model-check { border-radius: 6px; }
.model-item.selected .model-check { border-color: var(--accent); background: var(--accent); }
.model-item.selected .model-check::after { content: ""; width: 6px; height: 10px; border: solid var(--on-accent); border-width: 0 2px 2px 0; rotate: 45deg; translate: 0 -1px; }
.model-name { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.model-desc { font-size: 12px; color: var(--ink-3); }
.model-id { font-size: 11px; color: var(--ink-3); font-family: ui-monospace, Menlo, monospace; }
.new-badge { font-size: 10.5px; background: var(--accent); color: var(--on-accent); padding: 1px 6px; border-radius: 6px; }

/* ---------- Results ---------- */
.results-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; }
.results-head h2 { margin: 0; font-size: 17px; margin-right: auto; }
.toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.result-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.group-items { display: grid; gap: 8px; }
.empty {
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 36px 16px; text-align: center; color: var(--ink-3); font-size: 13.5px;
}
.empty p { margin: 12px 0 0; }
.empty-wave { display: flex; justify-content: center; align-items: center; gap: 4px; height: 36px; }
.empty-wave i { width: 5px; border-radius: 3px; background: var(--wave); animation: bob 1.6s ease-in-out infinite; }
.empty-wave i:nth-child(1) { height: 10px; animation-delay: 0s; }
.empty-wave i:nth-child(2) { height: 22px; animation-delay: .1s; }
.empty-wave i:nth-child(3) { height: 32px; animation-delay: .2s; }
.empty-wave i:nth-child(4) { height: 18px; animation-delay: .3s; }
.empty-wave i:nth-child(5) { height: 28px; animation-delay: .4s; }
.empty-wave i:nth-child(6) { height: 14px; animation-delay: .5s; }
.empty-wave i:nth-child(7) { height: 8px; animation-delay: .6s; }
@keyframes bob { 50% { scale: 1 .5; } }

.group { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; animation: rise .3s ease-out; }
@keyframes rise { from { opacity: 0; translate: 0 8px; } }
.group-head { display: flex; align-items: flex-end; gap: 10px; padding: 0 2px; }
.group-head > div { min-width: 0; flex: 1; }
.group-title { font-weight: 700; font-size: 14px; }
.group-sub { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-sm {
  display: inline-flex; align-items: center; gap: 5px; flex: none;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 12px; font-size: 12.5px; font-weight: 700;
}
.btn-sm svg { width: 11px; height: 11px; }

.result {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px;
  box-shadow: var(--shadow);
  transition: border-color .2s;
}
.result.playing { border-color: var(--accent); }
.play-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0;
  background: var(--ink); color: var(--bg);
  display: grid; place-items: center;
}
.play-btn svg { width: 16px; height: 16px; }
.result.playing .play-btn { background: var(--accent); color: var(--on-accent); }
.result.loading .play-btn, .result.error .play-btn { background: var(--surface-2); color: var(--ink-3); cursor: default; }
.r-body { flex: 1; min-width: 0; }
.r-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.r-title { font-weight: 700; font-size: 15px; }
.r-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.r-tag { font-size: 11px; background: var(--surface-2); color: var(--ink-2); padding: 1px 7px; border-radius: 6px; }
.r-wave { position: relative; height: 40px; margin: 6px 0 2px; }
.r-wave canvas { width: 100%; height: 100%; cursor: pointer; }
.r-status {
  position: absolute; inset: 0; display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--ink-3);
}
.result.loading .r-status::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--accent); border-right-color: transparent; animation: spin .7s linear infinite;
}
.result.loading .r-wave { background: linear-gradient(90deg, transparent, var(--surface-2), transparent) 0 0 / 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.result.done .r-status { display: none; }
.result.error .r-status { color: var(--err); font-size: 12.5px; line-height: 1.4; align-items: flex-start; flex-direction: column; gap: 4px; position: static; }
.result.error .r-wave { height: auto; }
.result.error canvas { display: none; }
.r-foot { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--ink-3); }
.r-time, .r-gen { font-variant-numeric: tabular-nums; white-space: nowrap; }
.r-actions { margin-left: auto; display: flex; gap: 2px; margin-right: -6px; }
.result:not(.done) .r-actions { visibility: hidden; }
.result.error .r-foot { display: none; }

/* ---------- Make tab ---------- */
.fields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.field { display: grid; gap: 4px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.filename { display: flex; align-items: center; gap: 6px; }
.filename input { min-width: 0; font-family: ui-monospace, Menlo, monospace; }
.filename span { color: var(--ink-3); font-size: 14px; }
.dl-label { display: none; }
.result.big .play-btn { width: 52px; height: 52px; }
.result.big .r-wave { height: 52px; }
.result.big [data-act=dl] {
  width: auto; height: 36px; padding: 0 14px; margin-left: 4px; gap: 6px;
  display: inline-flex; align-items: center;
  background: var(--accent); color: var(--on-accent);
  font-size: 13.5px; font-weight: 700;
}
.result.big [data-act=dl]:hover { background: var(--accent-2); color: var(--on-accent); }
.result.big .dl-label { display: inline; white-space: nowrap; }
.result.big .r-foot { flex-wrap: wrap; row-gap: 8px; }
@media (max-width: 520px) {
  .result.big .r-actions { width: 100%; margin: 0; }
  .result.big [data-act=dl] { flex: 1; justify-content: center; height: 40px; }
}

/* ---------- Dialog tab ---------- */
.speakers { display: grid; gap: 10px; }
.speaker { display: grid; grid-template-columns: auto minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; align-items: center; }
.speaker-tag { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-weight: 900; font-size: 13px; }
.speaker-tag.a { background: var(--female-soft); color: var(--female); }
.speaker-tag.b { background: var(--male-soft); color: var(--male); }
select.full { width: 100%; }

/* ---------- Action bar ---------- */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
}
.tab-panel:not(.active) .action-bar { display: none; }
.summary { font-size: 13px; color: var(--ink-2); line-height: 1.4; min-width: 0; }
.summary b { color: var(--ink); font-size: 15px; }
@media (min-width: 1000px) {
  .action-bar { left: 50%; right: auto; translate: -50% 0; bottom: 16px; width: min(640px, calc(100% - 32px)); border: 1px solid var(--line); border-radius: 18px; padding: 10px 10px 10px 18px; box-shadow: 0 8px 32px rgba(0,0,0,.12); }
}

.foot { max-width: 1280px; margin: 8px auto 0; padding: 0 16px 24px; font-size: 12px; color: var(--ink-3); }
.notice-line { margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); line-height: 1.6; }
.notice-line b { color: var(--ink); }
.about + .about { margin-top: 8px; }
.version { margin: 0 0 8px; font-size: 11px; color: var(--ink-3); }
.about summary { cursor: pointer; font-weight: 700; color: var(--ink-2); }
.about ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.7; }
.about b { color: var(--ink-2); }

/* ---------- Modal ---------- */
.modal {
  border: 0; padding: 0; border-radius: 20px;
  background: var(--surface); color: var(--ink);
  width: min(440px, calc(100% - 32px));
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal.wide { width: min(720px, calc(100% - 32px)); }
.modal::backdrop { background: rgba(20, 15, 10, .45); backdrop-filter: blur(2px); }
.modal-body { padding: 18px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.modal-actions .primary:only-child { margin-left: auto; }
.steps-list { margin: 0; padding-left: 20px; font-size: 13.5px; color: var(--ink-2); }
.steps-list a { color: var(--accent); font-weight: 700; }
.key-input { display: flex; gap: 8px; }
.key-input input { font-family: ui-monospace, Menlo, monospace; min-width: 0; }
pre#codeBox {
  margin: 0; background: var(--bg); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; font-size: 12px; line-height: 1.55; overflow: auto; max-height: 50vh;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; white-space: pre;
}
.saved-item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.saved-item:last-child { border-bottom: 0; }
.saved-item .s-main { flex: 1; min-width: 0; }
.saved-item .s-title { font-weight: 700; font-size: 14px; }
.saved-item .s-sub { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 料金ページ ---------- */
a.brand { color: inherit; text-decoration: none; }
a.ghost-btn { color: inherit; text-decoration: none; }
.modal a, .about a { color: var(--accent); font-weight: 700; }
body.doc-page { padding-bottom: 32px; }
.doc { max-width: 760px; display: grid; gap: 16px; }
.doc-title { margin: 8px 0 0; font-size: 24px; font-weight: 900; }
.doc-lead { margin: 0; color: var(--ink-2); font-size: 15px; line-height: 1.8; }
.doc-lead b { color: var(--ink); }
.point-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.point { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.point-num { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; margin-bottom: 6px; }
.point strong { display: block; font-size: 15.5px; }
.point p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); line-height: 1.6; }
.doc-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.doc-card h3 { margin: 0 0 10px; font-size: 17px; }
.doc-card > p { margin: 0 0 10px; }
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.price-table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; }
.price-table th, .price-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.price-table thead th { font-size: 12px; color: var(--ink-3); font-weight: 700; }
.price-table tbody th { font-weight: 700; }
.price-table tbody tr:last-child > * { border-bottom: 0; }
.price-table td b { color: var(--accent); font-size: 15px; }
.price-table .warn { color: var(--err); font-weight: 700; }
.price-table.small { font-size: 12.5px; }
.doc-list { margin: 12px 0 0; padding-left: 20px; font-size: 14px; line-height: 1.8; color: var(--ink-2); }
.doc-list b { color: var(--ink); }
.doc-list a { color: var(--accent); font-weight: 700; }
.doc-details { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 12px; }
.doc-details summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--ink-2); }
.doc-details p { margin: 8px 0; }
.estimate { list-style: none; margin: 0 0 10px; padding: 0; }
.estimate li { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.estimate li:last-child { border-bottom: 0; }
.estimate b { color: var(--accent); white-space: nowrap; font-size: 15px; }
.doc-steps { margin: 0; padding-left: 22px; font-size: 14px; line-height: 1.8; }
.doc-steps li + li { margin-top: 6px; }
.doc-steps a, .doc-foot a { color: var(--accent); font-weight: 700; }
.plan-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 8px 0 4px; }
.plan { border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.plan.recommended { border-color: var(--accent); background: var(--accent-soft); }
.plan strong { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.plan p { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
.faq { margin: 0; }
.faq dt { font-weight: 700; font-size: 14.5px; margin-top: 14px; }
.faq dt:first-child { margin-top: 0; }
.faq dt::before { content: "Q. "; color: var(--accent); }
.faq dd { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); line-height: 1.7; }
.doc-foot { margin: 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.8; }
.back-btn { justify-self: start; text-decoration: none; }

/* ---------- キャスティング ---------- */
.modal-actions-right { display: flex; gap: 8px; margin-left: auto; }
.cast-config { display: flex; flex-wrap: wrap; gap: 6px; }
.cast-config .r-tag { font-size: 12.5px; padding: 3px 9px; }
.cast-config .r-tag.main { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
#castDialog .field textarea { min-height: 84px; }
.make-btn {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  height: 30px; padding: 0 10px; margin: 0 2px;
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  font-size: 12.5px; font-weight: 700; color: var(--ink);
}
.make-btn svg { width: 13px; height: 13px; }
.make-btn:hover { border-color: var(--accent); color: var(--accent); }
.cast-item { padding: 12px 0; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.cast-item:last-child { border-bottom: 0; }
.cast-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cast-name { font-weight: 700; font-size: 15px; }
.cast-sub { font-size: 12px; color: var(--ink-3); }
.cast-memo { margin: 0; font-size: 13px; color: var(--ink-2); background: var(--surface-2); border-radius: 10px; padding: 8px 10px; white-space: pre-wrap; line-height: 1.6; }
.cast-actions { display: flex; align-items: center; gap: 6px; }
.cast-actions .sm { padding: 7px 12px; }
.cast-actions .icon-btn { width: 32px; height: 32px; flex: none; }
.cast-actions .spacer { flex: 1; }
.cast-pick { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px dashed var(--line); }
.cast-pick .sub-label { margin-top: 0; }
.cast-pick .hint { margin: 0; }
.cast-note { margin: 10px 0 0; font-size: 13px; color: var(--ink-2); background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; white-space: pre-wrap; line-height: 1.6; }
.cast-note b { color: var(--ink); }

/* ---------- APIキーの取り方 ---------- */
.howto { margin: 0; padding: 0; list-style: none; counter-reset: step; display: grid; gap: 14px; }
.howto li { counter-increment: step; position: relative; padding-left: 40px; }
.howto li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 14px;
}
.howto strong { display: block; font-size: 15px; line-height: 28px; }
.howto p { margin: 2px 0 0; font-size: 14px; color: var(--ink-2); line-height: 1.7; }
.howto .open-link { margin-top: 8px; text-decoration: none; white-space: normal; text-align: center; }
.faq dd a { color: var(--accent); font-weight: 700; }
.callout p a { color: var(--accent); font-weight: 700; white-space: nowrap; }

/* ---------- 声をデザイン ---------- */
.my-voices { background: var(--custom-soft); border-radius: 18px; padding: 12px; margin-bottom: 16px; }
.my-voices-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.my-voices-title { font-weight: 700; font-size: 14px; color: var(--custom); }
.my-voices .voice-grid:not(:empty) { margin-top: 10px; }
.my-voices .voice-card { background: var(--surface); }
@media (max-width: 520px) { .my-voices .voice-grid { grid-template-columns: 1fr; } }
.my-voices .voice-card.selected { background: var(--accent-soft); }
.ds-step { display: grid; gap: 8px; }
.ds-step-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.ds-step-title .num { width: 22px; height: 22px; font-size: 12px; }
.ds-tip { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.ds-create { width: 100%; padding: 14px; font-size: 16px; }
.ds-result.ds-error { background: var(--err-soft); color: var(--err); }
.ds-result.ds-error .ds-info span { opacity: 1; font-size: 12.5px; }
.ds-spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--accent); border-right-color: transparent; animation: spin .7s linear infinite; flex: none; }
.ds-foot { display: grid; gap: 4px; justify-items: start; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--ink-3); }
.ds-foot .link-btn { font-size: 12.5px; }
.my-empty { margin: 8px 0 0; font-size: 12.5px; color: var(--ink-2); }
.preset-label { font-weight: 700; font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }
.design-entry { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.design-entry p { margin: 0; }
.vc-desc { display: block; margin-top: 4px; font-size: 11.5px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-result { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--accent-soft); color: var(--on-accent-soft); border-radius: 16px; padding: 12px 14px; }
.ds-result .ds-info { flex: 1; min-width: 160px; }
.ds-result .ds-info b { display: block; font-size: 15px; }
.ds-result .ds-info span { font-size: 11.5px; opacity: .8; word-break: break-all; }
.ds-result .ds-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ds-result .play-btn { background: var(--accent); color: var(--on-accent); }
#designDialog .custom-voice { margin-top: 0; }
#designDialog .custom-voice .secondary { margin-top: 8px; }
#designDialog .modal-actions .muted { flex: 1; min-width: 0; }

/* ---------- 引き継ぎ ---------- */
.code-seg button { padding: 8px 4px; font-size: 13px; }
.code-seg .dev { display: none; }
.code-seg.show-dev .dev { display: block; }
.muted-link { color: var(--ink-3); font-weight: 500; font-size: 12.5px; }
.code-desc { margin: 0; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; }
pre#codeBox.wrap { white-space: pre-wrap; word-break: break-all; }
.link-banner { align-items: flex-start; }
.link-banner > div { min-width: 0; }
.link-banner p { white-space: pre-wrap; }
.link-banner .banner-actions { display: flex; gap: 6px; align-items: center; flex: none; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); translate: -50% 12px;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .2s, translate .2s;
  z-index: 50; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; translate: -50% 0; }

/* ---------- かわいい仕上げ ---------- */
.brand-mark { border-radius: 50% 50% 50% 14px; box-shadow: 0 3px 0 var(--accent-2); }
.brand h1 { letter-spacing: .06em; }
.ghost-btn, .key-btn { border-width: 1.5px; }
.tab.active::after { height: 4px; border-radius: 4px; left: 16px; right: 16px; }
.num { background: var(--accent); color: var(--on-accent); }
.card { border-color: transparent; }
.card.is-multi { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); }
.multi-badge { border-radius: 999px; }
.segmented { border-radius: 999px; }
.segmented button { border-radius: 999px; }
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
textarea, input:not([type=checkbox]), select { border-radius: 16px; }
.primary, .secondary { border-radius: 999px; }
.primary { box-shadow: 0 3px 0 var(--accent-2); transition: transform .1s, box-shadow .1s, background .15s; }
.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-2); }
.voice-card, .model-item { border-radius: 18px; transition: border-color .15s, background .15s, transform .15s; }
.voice-card:hover { transform: translateY(-2px); }
.voice-card.selected { animation: pop .25s ease-out; }
.vc-order { box-shadow: 0 2px 0 var(--accent-2); }
@keyframes pop { 40% { scale: 1.04; } }
.result { border-radius: 20px; border-color: transparent; }
.result.playing { border-color: var(--accent); }
.play-btn { background: var(--accent-soft); color: var(--accent); }
.result.playing .play-btn, .result.done .play-btn:hover { background: var(--accent); color: var(--on-accent); }
.empty { border-radius: var(--radius); border-color: var(--wave); }
.empty-wave i { background: var(--accent); opacity: .45; }
.empty-wave i:nth-child(even) { background: var(--male); }
.modal { border-radius: 26px; }
.pattern, .fav-toggle { border-radius: 999px; }
.callout { border-width: 0; }
#toast { border-radius: 999px; }
.design-btn { font-weight: 700; }

@media (max-width: 520px) {
  .hide-sm { display: none; }
  .r-gen { display: none; }
  .topbar { gap: 8px; }
  .brand { gap: 6px; }
  .brand-mark { width: 32px; height: 32px; font-size: 18px; border-radius: 10px; }
  .brand h1 { font-size: 16px; letter-spacing: .02em; }
  .top-actions { gap: 5px; }
  .ghost-btn { padding: 0 9px; font-size: 12.5px; gap: 4px; }
  .key-btn { padding: 0 9px; font-size: 12px; gap: 5px; }
  .price-table th, .price-table td { padding: 8px 5px; font-size: 13px; }
  .price-table .new-badge { display: none; }
  .brand p { display: none; }
  .speaker { grid-template-columns: auto minmax(0, 1fr); }
  .speaker select { grid-column: 1 / -1; }
}
