/* 公開版(public.html / help.html)の見た目 */
:root {
  --bg: #0f1117;
  --bg-2: #151821;
  --panel: #181b25;
  --card: #1e2230;
  --card-2: #262b3b;
  --line: #2e3446;
  --line-2: #3b4258;
  --text: #eceef5;
  --text-2: #b6bccd;
  --muted: #8189a0;
  --pink: #ff5fa2;
  --violet: #8b6cff;
  --grad: linear-gradient(135deg, var(--pink), var(--violet));
  --ok: #5fd39a;
  --warn: #ff7b7b;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}
body[data-edition="public"] { display: flex; flex-direction: column; overflow: hidden; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
a { color: inherit; }

/* ---------- ロゴ ---------- */
.logo {
  display: inline-block; width: 28px; height: 28px; border-radius: 9px; background: var(--grad); position: relative;
  box-shadow: 0 4px 14px rgba(255, 95, 162, .35);
}
.logo::before, .logo::after {
  content: ""; position: absolute; top: 11px; width: 6px; height: 6px; border-radius: 50%; background: #fff;
}
.logo::before { left: 7px; }
.logo::after { right: 7px; }
.logo.big { width: 64px; height: 64px; border-radius: 20px; }
.logo.big::before, .logo.big::after { top: 24px; width: 13px; height: 13px; }
.logo.big::before { left: 16px; }
.logo.big::after { right: 16px; }

/* ---------- 上の帯 ---------- */
#topbar {
  flex: none; height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 16px;
  background: rgba(21, 24, 33, .92); border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: .02em; }
.brand-sub { color: var(--muted); font-size: 12px; white-space: nowrap; }
.actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- ボタン ---------- */
.btn, .file {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 9px;
  background: var(--card-2); color: var(--text); border: 1px solid var(--line-2);
  font: 600 13px/1 var(--font); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s, box-shadow .15s;
}
.btn:hover, .file:hover { border-color: #565f7c; background: #2d3346; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .file:focus-within, summary:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--card); color: var(--text); }
.btn.primary {
  background: var(--grad); border: 0; color: #fff; padding: 0 16px;
  box-shadow: 0 6px 18px rgba(139, 108, 255, .35);
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 8px 22px rgba(255, 95, 162, .4); }
.btn.small { height: 30px; padding: 0 10px; font-size: 12px; font-weight: 500; }
.btn[hidden] { display: none; }

.split { display: inline-flex; }
.split .btn { border-radius: 0; margin-left: -1px; }
.split .btn:first-child { border-radius: 9px 0 0 9px; margin-left: 0; }
.split .btn:last-child { border-radius: 0 9px 9px 0; }
.split .btn:hover { position: relative; z-index: 1; }

/* ---------- 切り替え(編集 / プレビュー) ---------- */
.seg { display: inline-flex; padding: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 11px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block; padding: 6px 18px; border-radius: 8px; color: var(--text-2); font-weight: 600;
  transition: background .15s, color .15s;
}
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: var(--card-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-2), 0 2px 8px rgba(0,0,0,.3); }
.seg input:focus-visible + span { outline: 2px solid var(--violet); }
.mode { margin-left: 8px; }

/* ---------- 本体 ---------- */
#body { flex: 1; display: flex; min-height: 0; }

#panel {
  width: 320px; flex: none; overflow-y: auto; padding: 14px 12px 20px;
  background: var(--panel); border-right: 1px solid var(--line);
  scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}
body.panel-hidden #panel { display: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.card > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; font-weight: 700; font-size: 13.5px; border-radius: var(--radius); user-select: none;
}
.card > summary::-webkit-details-marker { display: none; }
.card > summary::after {
  content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px); transition: transform .2s;
}
.card[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.card > summary:hover { background: rgba(255, 255, 255, .02); }
.num {
  width: 22px; height: 22px; border-radius: 7px; display: inline-grid; place-items: center; flex: none;
  background: var(--grad); color: #fff; font-size: 12px; font-weight: 700;
}
.num.ico { background: var(--card-2); color: var(--text-2); }
.card-body { padding: 2px 14px 14px; }

.hint { margin: 0 0 10px; padding: 8px 10px; border-radius: 8px; background: rgba(139, 108, 255, .08); color: var(--text-2); font-size: 12px; border: 1px solid rgba(139, 108, 255, .18); }
.muted { color: var(--muted); font-size: 12px; }
#panel p { margin: 4px 0 8px; }
#lashStatus { color: var(--ok); }
#lashStatus.warn { color: var(--warn); }
#lashStatus:empty { display: none; }

.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.row > label { color: var(--text-2); }
.sub { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }

/* ファイルを開く */
.file input { display: none; }
.file.drop {
  display: flex; justify-content: flex-start; gap: 12px; height: auto; width: 100%; padding: 14px;
  border: 1.5px dashed var(--line-2); background: var(--bg-2); border-radius: 10px; text-align: left;
}
.file.drop:hover { border-color: var(--pink); background: rgba(255, 95, 162, .05); }
.file.drop svg { width: 28px; height: 28px; color: var(--pink); }
.file.drop b { display: block; font-size: 13.5px; }
.file.drop small { display: block; color: var(--muted); font-weight: 400; margin-top: 3px; }
.file.small { height: 30px; font-size: 12px; font-weight: 500; }

/* チェック */
.check { display: flex; align-items: center; gap: 8px; margin: 10px 0; cursor: pointer; color: var(--text); }
.check input {
  appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line-2);
  position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0;
}
.check input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #c9cedc; transition: transform .15s, background .15s;
}
.check input:checked { background: var(--violet); border-color: transparent; }
.check input:checked::after { transform: translateX(14px); background: #fff; }
.check input:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }

/* スライダー */
.slider { display: grid; grid-template-columns: 1fr 44px; gap: 2px 10px; align-items: center; margin: 10px 0; }
.slider label { grid-column: 1 / 3; color: var(--text-2); font-size: 12px; }
.slider output {
  text-align: right; color: var(--text); font-variant-numeric: tabular-nums; font-size: 12px;
  background: var(--bg-2); border-radius: 6px; padding: 1px 6px;
}
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; margin: 0; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 999px; background: var(--line-2); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 999px; background: var(--line-2); }
input[type=range]::-moz-range-progress { height: 4px; border-radius: 999px; background: var(--grad); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: #fff; border: 3px solid var(--violet); box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 3px solid var(--violet); }
input[type=range]:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: 4px; }

/* 母音の選択 */
.chips { display: flex; gap: 6px; margin: 4px 0 10px; }
.chips label { flex: 1; cursor: pointer; position: relative; }
.chips input { position: absolute; opacity: 0; pointer-events: none; }
.chips span {
  display: block; text-align: center; padding: 5px 0; border-radius: 8px; font-weight: 700;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text-2); transition: all .15s;
}
.chips label:hover span { border-color: var(--line-2); color: var(--text); }
.chips input:checked + span { background: var(--grad); border-color: transparent; color: #fff; }
.chips input:focus-visible + span { outline: 2px solid var(--violet); outline-offset: 2px; }

select {
  height: 30px; padding: 0 28px 0 10px; border-radius: 8px; background: var(--card-2); color: var(--text);
  border: 1px solid var(--line-2); font: inherit; appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 13px, calc(100% - 9px) 13px; background-size: 5px 5px; background-repeat: no-repeat;
}

.foot { color: var(--muted); font-size: 11.5px; text-align: center; margin: 14px 4px 0 !important; }

/* ---------- 絵の表示 ---------- */
#stage { position: relative; flex: 1; overflow: hidden; min-width: 0; }
#stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { touch-action: none; }

.bg-checker {
  background-color: #2a2e3a;
  background-image:
    linear-gradient(45deg, #333847 25%, transparent 25%, transparent 75%, #333847 75%),
    linear-gradient(45deg, #333847 25%, transparent 25%, transparent 75%, #333847 75%);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
}
.bg-green { background: #00ff00; }
.bg-black { background: #000; }
.bg-white { background: #fff; }

#dropHint { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; padding: 16px; }
#dropHint[hidden] { display: none; }
.empty {
  text-align: center; padding: 40px 48px; border-radius: 20px; max-width: 440px;
  background: rgba(15, 17, 23, .72); border: 1.5px dashed var(--line-2); backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
}
.empty-title { font-size: 18px; font-weight: 700; margin: 18px 0 4px; }
.empty-sub { color: var(--text-2); margin: 0 0 16px; }
.empty-link { pointer-events: auto; color: var(--pink); font-weight: 600; text-decoration: none; }
.empty-link:hover { text-decoration: underline; }
#stage.dragover .empty { border-color: var(--pink); background: rgba(255, 95, 162, .1); }
#stage.dragover { outline: none; }

/* ハンドルの色の説明 */
#legend {
  position: absolute; left: 14px; bottom: 14px; max-width: 340px;
  background: rgba(15, 17, 23, .86); border: 1px solid var(--line); border-radius: 10px; backdrop-filter: blur(6px);
  font-size: 12px; color: var(--text-2); box-shadow: var(--shadow);
}
#legend summary { cursor: pointer; padding: 7px 12px; font-weight: 600; color: var(--text); list-style: none; }
#legend summary::-webkit-details-marker { display: none; }
#legend summary::before { content: "●"; margin-right: 6px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
#legend ul { list-style: none; margin: 0; padding: 0 12px 4px; }
#legend li { display: flex; gap: 8px; align-items: baseline; margin: 4px 0; }
#legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 0 1.5px rgba(0,0,0,.6); transform: translateY(1px); }
#legend p { margin: 6px 12px 10px; color: var(--muted); }
#dropHint:not([hidden]) ~ #legend { display: none; }

/* 保存・書き出しの結果 */
#toasts { position: absolute; right: 14px; bottom: 14px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; max-width: min(460px, calc(100% - 28px)); }
#toasts p {
  margin: 0; padding: 9px 14px; border-radius: 10px; font-size: 12.5px;
  background: rgba(30, 34, 48, .95); border: 1px solid var(--line-2); box-shadow: var(--shadow);
  animation: toast-in .2s ease-out;
}
#toasts p:empty { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }

/* ---------- 狭い画面 ---------- */
@media (max-width: 980px) {
  .brand-sub { display: none; }
  .actions .btn span { display: none; }
  .actions .btn.primary span { display: inline; }
  .btn.ghost span { display: none; }
}
@media (max-width: 720px) {
  body[data-edition="public"] { overflow: auto; }
  #topbar { height: auto; flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .mode { margin-left: 0; order: 3; }
  #body { flex-direction: column; }
  #panel { width: 100%; border-right: 0; border-bottom: 1px solid var(--line); max-height: none; }
  #stage { min-height: 70vh; }
}

/* ---------- 使い方ページ ---------- */
body.help { overflow: auto; }
.help-top { position: sticky; top: 0; z-index: 5; }
.help-wrap { max-width: 860px; margin: 0 auto; padding: 40px 16px 80px; }
.hero { text-align: center; padding: 24px 0 36px; }
.hero h1 { font-size: 30px; margin: 18px 0 10px; letter-spacing: .02em; }
.hero h1 em { font-style: normal; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { color: var(--text-2); font-size: 15px; margin: 0 auto; max-width: 780px; line-height: 1.9; }
/* 文節の途中で折り返さない */
.lead span { display: inline-block; }
.flow { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 26px 0 0; }
.flow span { padding: 8px 14px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-weight: 600; font-size: 13px; }
.flow b { color: var(--muted); font-weight: 400; }

.toc { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 0 0 32px; }
.toc a { text-decoration: none; color: var(--text-2); padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); font-size: 12.5px; }
.toc a:hover { color: var(--text); border-color: var(--line-2); }

.help-wrap section { margin: 0 0 22px; padding: 26px 28px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; scroll-margin-top: 72px; }
.help-wrap h2 { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; font-size: 19px; }
.help-wrap h2 .num { width: 28px; height: 28px; font-size: 14px; border-radius: 9px; }
.help-wrap h3 { font-size: 14.5px; margin: 20px 0 8px; }
.help-wrap p, .help-wrap li { color: var(--text-2); font-size: 14px; line-height: 1.85; }
.help-wrap p { margin: 6px 0; }
.help-wrap b { color: var(--text); }
.help-wrap ol, .help-wrap ul { padding-left: 1.4em; margin: 6px 0; }
.help-wrap li { margin: 4px 0; }
.help-wrap code, .help-wrap kbd {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px;
  background: var(--bg-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; color: var(--text);
}
.help-wrap a { color: var(--pink); }
.need { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin: 10px 0 0; }
.need div { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.need b { display: block; margin-bottom: 4px; }
.need span { color: var(--text-2); font-size: 13px; line-height: 1.7; }
.note { margin: 12px 0 4px; padding: 12px 14px; border-radius: 10px; background: rgba(255, 196, 77, .08); border: 1px solid rgba(255, 196, 77, .25); }
.note p, .note li { color: #e9d9b2; font-size: 13px; }
.legend-list { list-style: none; padding: 0 !important; }
.legend-list li { display: flex; gap: 10px; align-items: baseline; }
.legend-list i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 0 1.5px rgba(0,0,0,.6); }
.help-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 36px; }
.help-foot p { color: var(--muted); font-size: 12px; }
@media (max-width: 600px) {
  .help-wrap section { padding: 20px 18px; }
  .hero h1 { font-size: 24px; }
}

/* ハンドルの色の説明は編集モードのときだけ出す */
body:has(input[name=mode][value=preview]:checked) #legend { display: none; }

/* 使い方: ハンドルの図解 */
.figure { margin: 26px 0 30px; }
.shot { margin: 0 0 14px; }
.shot svg { display: block; width: 100%; height: auto; border-radius: 12px; border: 1px solid var(--line-2); background: #2a2e3a; box-shadow: var(--shadow); }
.shot figcaption { color: var(--muted); font-size: 12.5px; margin-top: 8px; text-align: center; }
.ann line { stroke: #fff; stroke-width: 2; stroke-dasharray: 4 3; filter: drop-shadow(0 0 1.5px rgba(0,0,0,.9)); }
.ann .tgt { fill: none; stroke: #fff; stroke-width: 2.5; filter: drop-shadow(0 0 2px rgba(0,0,0,.9)); }
.ann .badge circle { fill: #e0186c; stroke: #fff; stroke-width: 3; }
.ann .badge .shadow { fill: rgba(0,0,0,.45); stroke: none; }
.ann .badge text { fill: #fff; font: 700 19px Arial, "Segoe UI", sans-serif; text-anchor: middle; }
.callouts { list-style: none; padding: 0 !important; margin: 0 !important; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 8px; }
.callouts li { display: flex; gap: 12px; align-items: flex-start; margin: 0 !important; padding: 10px 12px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); }
.callouts .n { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--pink); color: #fff; font-weight: 700; font-size: 12.5px; margin-top: 1px; }
.callouts b { font-size: 13.5px; }
.callouts p { margin: 2px 0 0 !important; font-size: 13px !important; line-height: 1.7 !important; }
.callouts i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); margin-right: 7px; box-shadow: 0 0 0 1.5px rgba(0,0,0,.6), 0 0 0 2.5px rgba(255,255,255,.15); vertical-align: 0; }
.callouts i.none { display: none; }
