/* userkit 共通スタイル — 配色のメインは pair-canvas に合わせる。どのツールもこの変数と部品を使う */
:root {
  /* 面と線(メインの色を薄めた物) */
  --bg: #f6f6fa;
  --surface: #ffffff;
  --soft: #f3f1ff;          /* メイン色 6% 相当(白の上) */
  --soft-2: #e9e6ff;        /* メイン色 12% 相当 */
  --line: #e6e3f2;          /* 区切りの細い線 */
  --line-strong: #cdc6fd;   /* 入力欄・ボタンの線 */
  /* 文字 */
  --text: #26232f;
  --muted: #67617a;
  --heading: #4c3ce0;
  /* 色 */
  --primary: #6d5dfc;
  --primary-dark: #5b51c9;
  --primary-ink: #ffffff;
  --danger: #c4425a;
  --ok: #3f8f64;
  --tint: var(--primary);   /* ツールの目印の色(Kit.tintOf)。要素ごとに上書きする */
  /* 形 */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(60, 50, 140, .05), 0 6px 18px rgba(60, 50, 140, .06);
  --shadow-float: 0 16px 40px rgba(40, 20, 70, .18);
  --font: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --kitbar-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 400 15px/1.7 var(--font); letter-spacing: .01em;
}
h1, h2, h3, p { margin: 0; }
/* 見出しと短い説明は、日本語の文節の切れ目で折り返す(対応していないブラウザではふつうに折り返す) */
h1, h2, h3, .lead { word-break: auto-phrase; text-wrap: pretty; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(109, 93, 252, .45); outline-offset: 2px; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 共通バー ---------- */
.kitbar {
  position: sticky; top: 0; z-index: 50; height: var(--kitbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.kit-brand { display: inline-flex; align-items: center; gap: 8px; flex: none; }
.kit-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: var(--primary); color: #fff; }
.kit-word { font: 700 20px/1 var(--font); letter-spacing: -.01em; color: var(--text); }
.kit-word b { color: var(--primary); font-weight: 700; }
/* いまのツール。左の細い線で区切り、目印の色の点を付ける */
.kit-tool { display: inline-flex; align-items: baseline; gap: 8px; min-width: 0; padding-left: 12px; border-left: 1px solid var(--line); }
.kit-tool b { font: 700 15px/1 var(--font); color: var(--text); white-space: nowrap; }
.kit-tool b::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--tint); vertical-align: 1px; }
.kit-tool small { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kit-spacer { flex: 1; }
.kit-link { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border-radius: 10px; font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.kit-link:hover { background: var(--soft); color: var(--text); }
.kit-menu { position: relative; }
.kit-menu summary {
  list-style: none; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); font-size: 13px; font-weight: 700; cursor: pointer;
}
.kit-menu summary::-webkit-details-marker { display: none; }
.kit-menu summary:hover, .kit-menu[open] summary { background: var(--soft); }
.kit-menu-list {
  position: absolute; right: 0; top: calc(100% + 8px); width: 320px; max-height: calc(100vh - var(--kitbar-h) - 24px); overflow-y: auto; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-float);
  display: flex; flex-direction: column; gap: 4px;
}
.kit-menu-grp { display: flex; flex-direction: column; gap: 2px; }
.kit-menu-grp + .kit-menu-grp { padding-top: 4px; border-top: 1px solid var(--line); }
.kit-menu-label { display: flex; align-items: center; gap: 8px; padding: 6px 12px 2px; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.kit-menu-label::before { content: ""; width: 3px; height: 12px; border-radius: 2px; background: var(--tint); }
.kit-menu-list a { display: flex; align-items: center; gap: 12px; padding: 7px 10px; border-radius: 10px; }
.kit-menu-list a:hover { background: var(--soft); }
.kit-menu-list a.current { background: var(--soft); box-shadow: inset 3px 0 0 var(--tint); }
.kit-menu-ic { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: color-mix(in srgb, var(--tint) 11%, #fff); color: var(--tint); }
.kit-menu-list span { display: flex; flex-direction: column; line-height: 1.35; }
.kit-menu-list b { font: 700 14.5px/1.3 var(--font); }
.kit-menu-list small { font-size: 12px; color: var(--muted); }
.kit-menu-foot { display: flex; gap: 4px; margin-top: 2px; padding-top: 6px; border-top: 1px solid var(--line); }
.kit-menu-foot a { flex: 1; justify-content: center; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.kit-menu-foot a:hover { color: var(--text); }

.kit-footer { display: flex; flex-direction: column; gap: 4px; margin-top: 28px; padding: 24px 20px 40px; border-top: 1px solid var(--line); text-align: center; font-size: 12px; color: var(--muted); }
.kit-footer-nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 20px; margin-bottom: 6px; font-size: 13px; font-weight: 700; color: var(--text); }
.kit-footer-nav a { display: inline-flex; align-items: center; gap: 4px; }
.kit-footer a:hover { color: var(--primary-dark); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- ページ見出し ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { font-size: 24px; line-height: 1.35; font-weight: 700; color: var(--heading); }
.lead { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 18px; }
.crumbs a { text-decoration: underline; text-underline-offset: 3px; }
.crumbs strong { color: var(--text); }

/* ---------- 更新履歴のツールの名前(トップの「最近の更新」と changelog/)。色の点・名前・id ---------- */
.ch-who { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; line-height: 1.5; }
.ch-who b { font-size: 13.5px; font-weight: 700; color: color-mix(in srgb, var(--tint) 80%, #1d1a26); }
.ch-who b::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: var(--tint); vertical-align: 2px; }
.ch-who small { font-size: 11.5px; color: var(--muted); }
a.ch-who:hover b { text-decoration: underline; text-underline-offset: 3px; }
.ch-who.all b { color: var(--text); }
.ch-who.all b::before { background: none; box-shadow: inset 0 0 0 1.5px var(--muted); }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 0 18px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 700; font-size: 14px; line-height: 1; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 8px 18px -12px rgba(109, 93, 252, .85); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline { background: var(--surface); border-color: var(--line-strong); color: var(--primary-dark); }
.btn-outline:hover:not(:disabled) { background: var(--soft); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--soft); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a8344a; }
.btn-danger-o { color: var(--danger); border-color: #ecc3cc; }
.btn-danger-o:hover { background: #fdf0f3; }
.btn-sm { min-height: 36px; padding: 0 13px; font-size: 13px; }
.btn-icon { min-height: 34px; width: 34px; padding: 0; border-radius: 9px; }
.btn-icon.danger:hover { color: var(--danger); background: #fdf0f3; }
.btn-icon.is-off { opacity: .28; pointer-events: none; }
.btn.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }

/* セグメント(切り替えボタン群) */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--soft); border: 1px solid var(--line); }
.seg button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--primary-dark); box-shadow: 0 1px 3px rgba(60, 50, 140, .18); }

/* ---------- パネル / フォーム ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 700; display: flex; gap: 8px; align-items: baseline; }
.field label small { font-weight: 400; color: var(--muted); font-size: 11.5px; }
.req { font-size: 10.5px; font-weight: 700; color: var(--primary-dark); background: var(--soft); border-radius: 5px; padding: 1px 6px; }
input[type=text], input[type=search], input[type=number], select, textarea {
  width: 100%; min-height: 44px; padding: 9px 14px; background: rgba(109, 93, 252, .06); border: 1.5px solid transparent; border-radius: 12px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input[type=text]:focus, input[type=search]:focus, input[type=number]:focus, select:focus, textarea:focus { background: var(--surface); }
textarea { resize: vertical; line-height: 1.7; }
input::placeholder, textarea::placeholder { color: #a6a0b4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109, 93, 252, .18); }
select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b6478' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
input[type=range] { accent-color: var(--primary); }
input[type=checkbox] { accent-color: var(--primary); width: 17px; height: 17px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.span-2 { grid-column: 1 / -1; }
.field-error { color: var(--danger); font-size: 13px; font-weight: 700; min-height: 1.2em; }
.hint { font-size: 12px; color: var(--muted); }
.notice { background: var(--soft); border: 1px solid var(--line-strong); border-left: 4px solid var(--primary); border-radius: 10px; padding: 12px 16px; font-size: 13.5px; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 48px 20px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty h3 { font-size: 16px; }
.empty p { color: var(--muted); font-size: 13.5px; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--soft); color: var(--primary); }
.empty.small { padding: 30px 20px; }

/* ---------- ダイアログ ---------- */
dialog.modal {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 16px;
  background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(40, 20, 70, .35); overflow: hidden;
}
dialog.modal.wide { width: min(720px, calc(100vw - 24px)); }
dialog.modal[open] { display: flex; flex-direction: column; }
dialog.modal::backdrop { background: rgba(30, 28, 50, .5); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; }
.modal-body { padding: 18px 22px 0; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.modal-lead { font-size: 12.5px; color: var(--muted); }
.modal-foot { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 14px 0 18px; margin-top: auto; background: linear-gradient(to bottom, rgba(255,255,255,0), var(--surface) 30%); }
.confirm-msg { padding: 6px 0 4px; }
.longpress { padding-bottom: 22px; align-items: center; }
.longpress img { max-width: 100%; max-height: 70vh; border-radius: 10px; border: 1px solid var(--line); }
.pick-list { display: flex; flex-direction: column; gap: 6px; padding-bottom: 18px; }
.pick-list button { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; }
.pick-list button:hover { background: var(--soft); border-color: var(--line-strong); }
.pick-list small { color: var(--muted); font-size: 12px; }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 100; max-width: calc(100vw - 32px);
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  background: var(--text); color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 13.5px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(40, 20, 70, .3); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

@media (max-width: 760px) {
  :root { --kitbar-h: 52px; }
  .kitbar { padding: 0 12px; gap: 8px; }
  .kit-word { font-size: 18px; }
  .kit-mark { width: 26px; height: 26px; }
  .kit-tool { padding-left: 9px; }
  .kit-tool small, .kit-link { display: none; }
  .kit-menu summary span { display: none; }
  .kit-menu summary { padding: 0 10px; }
  .kit-menu-list { position: fixed; left: 12px; right: 12px; top: calc(var(--kitbar-h) + 6px); width: auto; }
  .grid-2 { grid-template-columns: 1fr; }
  .modal-body { padding: 16px 16px 0; }
  .modal-head { padding: 14px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
