/* DS #2 ツール デザインサンプル — #1 JSON Converter のトークンと部品を引用して拡張 */
:root {
  --bg: #f7f7f8; --surface: #ffffff; --surface-2: #f1f2f4; --border: #e3e5e8; --border-strong: #a3a8b4;
  --text: #17181c; --muted: #6b7080; --faint: #9ca3af;
  --accent: #4f46e5; --accent-fg: #ffffff; --accent-weak: #eef0fe; --accent-weak-fg: #4338ca;
  --err: #dc2626; --err-bg: #fef2f2; --warn: #b45309; --warn-bg: #fffbeb; --info: #2563eb; --info-bg: #eff6ff;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --pill-shadow: 0 1px 2px rgba(16,24,40,.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0e11; --surface: #15171c; --surface-2: #1c1f26; --border: #2a2e37; --border-strong: #4a505d;
    --text: #e7e9ee; --muted: #8b91a1; --faint: #6b7280;
    --accent: #818cf8; --accent-fg: #0d0e11; --accent-weak: #22244a; --accent-weak-fg: #c7d2fe;
    --err: #f87171; --err-bg: #2a1416; --warn: #fbbf24; --warn-bg: #2a2110; --info: #93c5fd; --info-bg: #142033;
    --shadow: none; --pill-shadow: 0 1px 2px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0e11; --surface: #15171c; --surface-2: #1c1f26; --border: #2a2e37; --border-strong: #4a505d;
  --text: #e7e9ee; --muted: #8b91a1; --faint: #6b7280;
  --accent: #818cf8; --accent-fg: #0d0e11; --accent-weak: #22244a; --accent-weak-fg: #c7d2fe;
  --err: #f87171; --err-bg: #2a1416; --warn: #fbbf24; --warn-bg: #2a2110; --info: #93c5fd; --info-bg: #142033;
  --shadow: none; --pill-shadow: 0 1px 2px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, "Noto Sans JP", system-ui, sans-serif; }
svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
code, .mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
code { font-size: 12px; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); color: var(--text); white-space: nowrap; }

/* header (#1 と同じ) */
header { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.logo-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; font: 600 13px "JetBrains Mono", monospace; }
.spacer { flex: 1; }
.hint { font-size: 12px; color: var(--muted); }

.toc { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.toc a { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 12px; font-weight: 500; }
.toc a:hover { background: var(--surface-2); }
.toc a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.toc .n { font-family: "JetBrains Mono", monospace; color: var(--muted); }

main { max-width: 1120px; margin: 0 auto; padding: 24px 20px 64px; display: flex; flex-direction: column; gap: 32px; }
.intro h1 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.intro p { margin: 0; color: var(--muted); }
.intro a { color: var(--accent); }

section.block { display: flex; flex-direction: column; gap: 12px; }
section.block > h2 { margin: 0; font-size: 16px; font-weight: 600; display: flex; align-items: baseline; gap: 10px; }
section.block > h2 .n { font: 500 13px "JetBrains Mono", monospace; color: var(--muted); }
section.block > p, .note { margin: 0; color: var(--muted); font-size: 13px; }

/* pane (#1 と同じ) */
.pane { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.pane-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pane-body { padding: 14px; }
.scroll { overflow-x: auto; }

/* table */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 12px 14px; text-align: left; vertical-align: middle; border-top: 1px solid var(--border); }
.tbl thead th { border-top: 0; font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; }
.tbl tbody th { font-weight: 600; font-size: 13px; white-space: nowrap; }
.tbl tbody th .sub { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.tbl tr.group th { background: var(--surface-2); font-size: 12px; color: var(--muted); padding-top: 6px; padding-bottom: 6px; }
.tbl .meta { display: block; margin-top: 6px; font: 11px/1.4 "JetBrains Mono", monospace; color: var(--faint); }
.tbl .na { color: var(--faint); font-size: 12px; }
.tbl ul { margin: 0; padding-left: 1.1em; }
.tbl li + li { margin-top: 2px; }
.tbl-colors { min-width: 760px; }
.tbl-type { min-width: 900px; }
.tbl-el { min-width: 820px; }
.tbl-el td { width: 26%; }
.tbl-icons { min-width: 720px; }
.tbl-tone { min-width: 760px; }
.tbl-tone td:nth-child(2) { width: 30%; color: var(--muted); font-size: 13px; }

/* color swatches — テーマ切り替えに関係なく固定値で並べる */
.sw { display: flex; align-items: center; gap: 10px; }
.chip { flex: none; width: 56px; height: 32px; border-radius: 7px; border: 1px solid rgba(127,127,127,.35); display: grid; place-items: center; font: 600 12px Inter, "Noto Sans JP", sans-serif; }
.hex { font: 12px "JetBrains Mono", monospace; }
.hex small { display: block; font: 11px Inter, "Noto Sans JP", sans-serif; color: var(--muted); }

/* typography samples */
.t-text { font: 400 14px/1.5 Inter, "Noto Sans JP", sans-serif; }
.t-sub { font: 600 12px/1.5 Inter, "Noto Sans JP", sans-serif; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.t-label { font: 400 13px/1.5 Inter, "Noto Sans JP", sans-serif; color: var(--muted); }
.t-num { font: 400 13px/1.6 "JetBrains Mono", monospace; font-variant-numeric: tabular-nums; }
.t-en { font: 400 14px/1.5 Inter, sans-serif; }
.t-ja { font: 400 14px/1.5 "Noto Sans JP", sans-serif; }
.t-code { font: 400 13px/1.6 "JetBrains Mono", monospace; }
.t-btn-en { font: 500 13px/1 Inter, sans-serif; }
.t-btn-ja { font: 500 13px/1 "Noto Sans JP", sans-serif; }

/* form controls */
button, select, input, textarea { font: inherit; color: inherit; }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; font-size: 13px; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); filter: none; }
.btn.primary:disabled:hover { background: var(--accent); }

.in { height: 32px; width: 200px; padding: 0 10px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 14px; }
.in.num { width: 96px; font: 13px "JetBrains Mono", monospace; font-variant-numeric: tabular-nums; text-align: right; }
textarea.in { height: auto; width: 220px; padding: 8px 10px; resize: vertical; line-height: 1.5; display: block; }
.in::placeholder { color: var(--faint); }
.in:hover { border-color: var(--muted); }
.btn:focus-visible, .in:focus-visible, select:focus-visible, .cb:focus-visible, input[type=range]:focus-visible,
.switch input:focus-visible + span, .seg input:focus-visible + span, .tip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.in:disabled, select:disabled { background: var(--surface-2); border-color: var(--border); color: var(--faint); cursor: not-allowed; }
.in:invalid, select:invalid { border-color: var(--err); background-color: var(--err-bg); }
.in:invalid:focus-visible, select:invalid:focus-visible { outline-color: var(--err); }

input[type=range] { width: 160px; accent-color: var(--accent); margin: 0; cursor: pointer; }
input[type=range]:disabled { cursor: not-allowed; opacity: .45; }

.cb { appearance: none; width: 16px; height: 16px; margin: 0; border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface); display: inline-grid; place-content: center; cursor: pointer; vertical-align: middle; }
.cb:hover { border-color: var(--muted); }
.cb:checked { background: var(--accent); border-color: var(--accent); }
.cb:checked::after { content: ""; width: 9px; height: 5px; border-left: 2px solid var(--accent-fg); border-bottom: 2px solid var(--accent-fg); transform: translateY(-1px) rotate(-45deg); }
.cb:invalid { border-color: var(--err); background: var(--err-bg); }
.cb:disabled { opacity: .45; cursor: not-allowed; }
.cbl { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; user-select: none; }
.cbl:has(.cb:disabled) { color: var(--faint); cursor: not-allowed; }

select { height: 32px; padding: 0 28px 0 10px; border-radius: 7px; border: 1px solid var(--border-strong); background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b91a1' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 8px center / 14px; appearance: none; cursor: pointer; font-size: 13px; color: var(--text); }
select[size] { height: auto; padding: 4px; background-image: none; width: 180px; }
select[size] option { padding: 4px 8px; border-radius: 4px; }
select[size] option:checked { background: var(--accent-weak); color: var(--accent-weak-fg); }
option:disabled { color: var(--faint); }

/* switch (#1 と同じ) */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--muted); user-select: none; position: relative; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 30px; height: 18px; border-radius: 9px; background: var(--border-strong); position: relative; transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(12px); }
.switch:has(input:checked) { color: var(--text); }
.switch:has(input:disabled) { opacity: .45; cursor: not-allowed; }

/* segmented 2-choice */
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--muted); }
.seg label:hover span { color: var(--text); }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--pill-shadow); }
.seg:has(input:disabled) { opacity: .45; }
.seg:has(input:disabled) label { cursor: not-allowed; }

/* icon toggle (aria-pressed) */
.btn[aria-pressed="true"] { background: var(--accent-weak); border-color: transparent; color: var(--accent-weak-fg); }

/* tooltip — #1 のトーストと同じ反転配色 */
.tip { position: relative; }
.tip::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 4px); padding: 4px 8px; border-radius: 6px; background: var(--text); color: var(--bg); font: 500 12px/1.4 Inter, "Noto Sans JP", sans-serif; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .12s, transform .12s; transition-delay: 0s; z-index: 5; }
.tip[data-pos="bottom"]::after { bottom: auto; top: calc(100% + 8px); transform: translate(-50%, -4px); }
.tip:hover::after, .tip:focus-visible::after { opacity: 1; transform: translate(-50%, 0); transition-delay: .4s; }
.tip:focus-visible::after { transition-delay: 0s; }
.tip-cell { position: relative; padding: 40px 0 4px; display: inline-flex; flex-direction: column; align-items: center; }
.tip-cell.bottom { padding: 4px 0 40px; }
.bubble { position: absolute; left: 50%; top: 0; transform: translateX(-50%); padding: 4px 8px; border-radius: 6px; background: var(--text); color: var(--bg); font: 500 12px/1.4 Inter, "Noto Sans JP", sans-serif; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tip-cell.bottom .bubble { top: auto; bottom: 0; }
.bubble kbd { font: 11px "JetBrains Mono", monospace; padding: 0 4px; border-radius: 3px; border: 1px solid color-mix(in srgb, var(--bg) 40%, transparent); }
.bubble.wrap { white-space: normal; width: 220px; }
.tip-cell.wide { padding-top: 64px; }

/* dynamic messages — #1 の status 行を拡張 */
.msg { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 6px 12px; border-radius: 7px; font-size: 12px; line-height: 1.5; }
.msg.err { color: var(--err); background: var(--err-bg); }
.msg.warn { color: var(--warn); background: var(--warn-bg); }
.msg.info { color: var(--info); background: var(--info-bg); }

/* collapsible heading */
details.fold { border: 1px solid var(--border); border-radius: 7px; background: var(--surface); width: 240px; }
details.fold > summary { display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 10px; font-size: 13px; font-weight: 600; cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary svg { color: var(--muted); transition: transform .15s; transform: rotate(-90deg); }
details.fold[open] > summary svg { transform: none; }
details.fold > summary:hover { background: var(--surface-2); }
details.fold > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 7px; }
details.fold > summary .cnt { margin-left: auto; font-weight: 400; font-size: 12px; color: var(--muted); }
details.fold > div { padding: 4px 10px 10px 34px; font-size: 13px; color: var(--muted); }

.icon-pair { display: flex; align-items: center; gap: 12px; }
.icon-pair svg.lg { width: 24px; height: 24px; }
.policy { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.policy div { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-size: 13px; }
.policy b { display: block; margin-bottom: 2px; }
.policy span { color: var(--muted); }
q { quotes: "「" "」"; }

footer { max-width: 1120px; margin: 0 auto; padding: 0 20px 40px; font-size: 12px; color: var(--muted); }

@media (max-width: 860px) {
  header, .toc { padding-left: 16px; padding-right: 16px; }
  main { padding: 20px 16px 48px; }
  .hint { display: none; }
}
/* 右端のボタンは右揃えで出す（はみ出し防止） */
.tip[data-align="end"]::after { left: auto; right: 0; transform: translate(0, -4px); }
.tip[data-align="end"]:hover::after, .tip[data-align="end"]:focus-visible::after { transform: none; }
.tbl td.mono { white-space: nowrap; font-size: 12px; }
