/* ToneTone の配色（アプリの tt_theme.dart と同じ値）。運用の道具なので落ち着いた面にする。 */
:root {
  --grape: #7a4dff;
  --ink: #241436;
  --muted: #7b6f93;
  --line: #e9e2f4;
  --surface: #ffffff;
  --ground: #f7f4fb;
  --ok: #1f8a5b;
  --ok-bg: #e7f6ee;
  --warn: #b4531a;
  --warn-bg: #fff1e6;
  --danger: #c2334a;
  --focus: #45d0ff;
  color-scheme: light;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: 'M PLUS Rounded 1c', 'Hiragino Maru Gothic ProN', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 20px;
  background: var(--ink);
  color: #fff;
}
.logo {
  margin: 0;
  font-family: 'Baloo 2', sans-serif;
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
}
.logo small { font-size: 12px; letter-spacing: 0.12em; margin-left: 6px; color: #c9b8ff; }
.env {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ffd23f;
  color: var(--ink);
}
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 13px; color: #e8e0ff; }

.wrap { max-width: 1120px; margin: 0 auto; padding-inline: 20px; padding-block: 20px 60px; }

.gate {
  margin-top: 40px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  text-align: center;
}
.gate #signin { display: flex; justify-content: center; margin-top: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  font: inherit;
  font-weight: 800;
  border: 0;
  background: none;
  padding: 10px 14px;
  color: var(--muted);
  border-bottom: 3px solid transparent;
  cursor: pointer;
}
.tab[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--grape); }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.hint { margin: 0; color: var(--muted); font-size: 13px; max-width: 70ch; }

.btn {
  font: inherit;
  font-weight: 800;
  font-size: 13px;
  border-radius: 10px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn.primary { background: var(--grape); border-color: var(--grape); color: #fff; }
.btn.ghost { background: transparent; color: inherit; border-color: rgba(255, 255, 255, 0.3); }
dialog .btn.ghost { border-color: var(--line); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn:focus-visible, .tab:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; letter-spacing: 0.08em; color: var(--muted); font-weight: 800; background: #fbf9fe; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 28px; }
.actions { text-align: right; }

.name { display: flex; align-items: center; gap: 10px; }
.name .emoji { font-size: 22px; width: 32px; text-align: center; }
.name strong { display: block; }
.name small { color: var(--muted); display: block; max-width: 36ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: #f3effa; padding: 1px 6px; border-radius: 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
code.detail { display: inline-block; max-width: 48ch; white-space: pre-wrap; word-break: break-all; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.missing { background: var(--warn-bg); color: var(--warn); }

.state { font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.state.on { background: var(--ok-bg); color: var(--ok); }
.state.off { background: #efecf3; color: var(--muted); }

dialog {
  width: min(94vw, 720px);
  border: 0;
  border-radius: 18px;
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(36, 20, 54, 0.25);
}
dialog::backdrop { background: rgba(36, 20, 54, 0.45); }
dialog form { padding: 20px 22px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dialog-head h2 { margin: 0; font-size: 18px; }
.icon { font: inherit; font-size: 22px; background: none; border: 0; color: var(--muted); cursor: pointer; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 4px; }
.field em { font-style: normal; font-weight: 700; color: #a197b5; margin-left: 4px; }
.field input:not([type='checkbox']), .field textarea {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}
.field input:disabled { background: #f3effa; color: var(--muted); }
.field.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); align-self: end; padding-bottom: 10px; }
.field.check input { width: 18px; height: 18px; }

.files { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); gap: 12px; margin-top: 14px; }
.file-box { border: 1px dashed #d8cdee; border-radius: 12px; padding: 12px; }
.file-box h3 { margin: 0 0 8px; font-size: 13px; }
.file-box h3 em { display: block; font-style: normal; font-weight: 700; font-size: 11px; color: var(--muted); }
.file-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.file-row input { font-size: 12px; max-width: 100%; }
.file-box audio { width: 100%; margin-top: 8px; }
.muted { color: var(--muted); font-size: 12px; margin: 6px 0 0; word-break: break-all; }
.error { color: var(--danger); font-weight: 800; margin: 12px 0 0; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  max-width: min(92vw, 560px);
  background: var(--ink);
  color: #fff;
  padding: 11px 16px;
  border-radius: 12px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(36, 20, 54, 0.25);
}
[hidden] { display: none !important; }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto; } }
.muted.warn { color: var(--warn); font-weight: 800; }

.grant { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; max-width: 720px; }
.grant-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.grant-row .grow { flex: 1 1 260px; }
.grant-row .btn { margin-bottom: 4px; }
.found { margin: 4px 0 12px; padding: 8px 12px; border-radius: 10px; background: var(--ok-bg); color: var(--ok); font-weight: 800; }

/* ---------------------------------------------------------------- サムネイル */

.thumb-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.thumb { width: 96px; height: 96px; border-radius: 18px; overflow: hidden; background: #f3effa; display: grid; place-items: center; flex: none; }
.thumb-img { display: block; object-fit: cover; border-radius: 10px; background: #f3effa; }
.thumb-img.sm { width: 40px; height: 40px; }
.thumb-img.lg { width: 96px; height: 96px; border-radius: 18px; }
.emoji.sm { font-size: 22px; width: 40px; text-align: center; }
.emoji.lg { font-size: 44px; }

/* ---------------------------------------------------------------- 編集ダイアログ（整理後） */

dialog#editor { width: min(94vw, 640px); max-height: min(92vh, 860px); }
dialog#editor form { padding: 0; display: flex; flex-direction: column; max-height: inherit; }
.dialog-scroll { overflow-y: auto; padding: 20px 22px 8px; }
.dialog-head { align-items: flex-start; }
.meta { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; }

.sec { padding: 14px 0; border-top: 1px solid var(--line); }
.dialog-head + .sec, .dialog-head + .sec[hidden] + .sec { border-top: 0; }
.sec-title { margin: 0 0 10px; font-size: 11px; letter-spacing: 0.1em; color: var(--muted); font-weight: 800; }
.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.hint.bad { color: var(--danger); font-weight: 800; }
.warn-line { margin: 6px 0 0; font-size: 12px; font-weight: 800; color: var(--warn); background: var(--warn-bg); padding: 6px 10px; border-radius: 8px; }

.look { display: grid; grid-template-columns: 132px 1fr; gap: 16px; align-items: start; }
@media (max-width: 520px) { .look { grid-template-columns: 1fr; } }
.look-art { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.look-art .hint { margin: 0; font-size: 11px; }
.look-text { display: flex; flex-direction: column; gap: 10px; }
.look-text .field { margin: 0; }

.thumb {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 22px;
  border: 1px dashed #cdbfee;
  background: #f6f2fd;
  padding: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.thumb:hover { border-color: var(--grape); }
.thumb:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.thumb .thumb-img.lg { width: 120px; height: 120px; border-radius: 0; }
.thumb .emoji.lg { font-size: 52px; }
.thumb-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 10px;
  font-weight: 800;
  background: var(--ink);
  color: #fff;
  padding: 2px 6px;
  border-radius: 999px;
}
.mini { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 800; color: var(--muted); }
.mini input { width: 44px; text-align: center; font-size: 16px; padding: 4px; border-radius: 8px; border: 1px solid var(--line); }

.sound-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sound-meta { flex: 1 1 180px; min-width: 0; display: flex; flex-direction: column; }
.sound-meta strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sound-meta span { font-size: 12px; font-variant-numeric: tabular-nums; }
.sec audio { width: 100%; margin-top: 8px; }

.price-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.price-row .field { margin: 0; }
.price-row input { font-variant-numeric: tabular-nums; }

.dialog-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 22px;
  border-top: 1px solid var(--line);
  background: #fbf9fe;
  border-radius: 0 0 18px 18px;
}
.bar-buttons { display: flex; gap: 8px; }
.sell { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.sell input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch {
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #d9d2e6;
  position: relative;
  transition: background 0.15s;
  flex: none;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(36, 20, 54, 0.3);
  transition: transform 0.15s;
}
.sell input:checked + .switch { background: var(--ok); }
.sell input:checked + .switch::after { transform: translateX(18px); }
.sell input:focus-visible + .switch { outline: 3px solid var(--focus); outline-offset: 2px; }
.sell-text { display: flex; flex-direction: column; font-weight: 800; font-size: 14px; line-height: 1.2; }
.sell-text small { font-size: 11px; color: var(--muted); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }
.actions .btn, .state { white-space: nowrap; }

/* ---------------------------------------------------------------- 推しラボ */
.lab { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; margin: 12px 0 20px; align-items: start; }
.lab-side { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.lab-side textarea { font-size: 12.5px; line-height: 1.55; }
.lab-side select, .lab-side textarea, .lab-side input { width: 100%; }
.field select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); font: inherit; font-size: 14px; background: #fff; color: var(--ink); }
.lab-main { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; min-height: 520px; }
.lab-chat { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; max-height: 62vh; }
.lab-msg { max-width: 78%; padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; line-height: 1.6; }
.lab-msg.user { align-self: flex-end; background: var(--grape); color: #fff; border-bottom-right-radius: 4px; }
.lab-msg.assistant { align-self: flex-start; background: #f3effa; border-bottom-left-radius: 4px; }
.lab-who { font-size: 11px; font-weight: 800; color: var(--muted); margin-bottom: 2px; }
.lab-metrics { margin-top: 6px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.lab-stars button { border: 0; background: none; cursor: pointer; font-size: 15px; color: #c9bfe0; padding: 0 1px; }
.lab-stars button.on { color: #f5a623; }
.lab-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.lab-form textarea { flex: 1; resize: vertical; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); font: inherit; }
.lab-logs-title { display: flex; align-items: center; gap: 10px; }
.lab-logs td { font-size: 12px; vertical-align: top; }
.lab-logs td.talk { max-width: 420px; }
.lab-logs td.talk small { display: block; color: var(--muted); }
@media (max-width: 860px) { .lab { grid-template-columns: 1fr; } .lab-msg { max-width: 92%; } }

.lab-system { margin: 4px 0 12px; font-size: 12px; }
.lab-system summary { cursor: pointer; color: var(--grape); font-weight: 800; }
.lab-system pre { white-space: pre-wrap; background: #f7f4fb; border: 1px solid var(--line); border-radius: 10px; padding: 10px; max-height: 320px; overflow: auto; font-family: inherit; line-height: 1.55; }
.lab-again { padding: 2px 10px; font-size: 11.5px; }

/* ---------------------------------------------------------------- 推し（oshis.js） */
.oshi-sub { display: flex; align-items: center; gap: 12px; margin: 28px 0 6px; }
.oshi-avatar { display: grid; place-items: center; flex: none; border-radius: 10px; color: #fff; font-weight: 800; overflow: hidden; }
.oshi-avatar.sm { width: 40px; height: 40px; font-size: 18px; }
.oshi-avatar.lg { width: 96px; height: 96px; font-size: 40px; border-radius: 18px; }
.chip.off { background: #efecf3; color: var(--muted); text-decoration: line-through; }
dialog#oshi-editor { width: min(96vw, 900px); max-height: min(94vh, 980px); padding: 0; }
dialog#oshi-editor > .dialog-scroll { max-height: inherit; padding-bottom: 20px; }
dialog#oshi-editor .thumb { position: relative; border: 0; cursor: pointer; padding: 0; }
dialog#oshi-editor select, dialog#oshi-editor .compact input:not([type='checkbox']) {
  font: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px; background: #fff; width: 100%;
}
dialog#oshi-editor .compact { min-width: 720px; }
dialog#oshi-editor .compact td { padding: 6px 8px; }
dialog#oshi-editor tr.inactive td { opacity: 0.55; }
.sec-title small { font-weight: 700; color: var(--muted); font-size: 12px; margin-left: 6px; }
.persona-text { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.55; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin: 10px 0 6px; resize: vertical; }
.common-rules pre, .versions pre { white-space: pre-wrap; font-size: 12px; background: #f8f5fd; border-radius: 10px; padding: 10px 12px; margin: 6px 0; }
.common-rules summary, .versions summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.versions { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 6px; }
.versions li { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.versions li details { flex: 1; min-width: 0; }
.versions summary { color: var(--ink); }
h4.sub { margin: 16px 0 4px; font-size: 13px; }
.updates { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 2px; }
.token { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.token code.detail { max-width: 100%; }
.token-form { margin: 8px 0 12px; max-width: none; }
dialog#oshi-editor .field input[type='color'] { height: 44px; padding: 4px; cursor: pointer; }
#tab-oshis td.nowrap { white-space: nowrap; }
#tab-oshis td small.sub { display: block; color: var(--muted); font-size: 11px; }
/* 本番の印（dev と見分けやすいように色を変える） */
.env.prod { background: #ff5a5f; color: #fff; }
