/* 文字数集計さん — スタイル。edi-tool 共通デザイントークン（edi-tool/.github DESIGN.md 2026-11-05 版）に従う。 */
:root {
  --bg: #f5f5f7;
  --surface: #fff;
  --surface-2: #f0f0f3;
  --border: #e5e5ea;          /* 装飾の区切り線。情報を持たせない */
  --control-border: #8a8a93;  /* 入力欄・ボタンの輪郭（白地 3.42:1・背景上 3.14:1） */
  --text: #0a0a0a;
  --text-sub: #52525b;
  --accent: #ff6a00;          /* 塗り。コピーボタンだけに使う。上に載せる文字は #0a0a0a */
  --accent-dark: #e85f00;
  --accent-soft: #f0f0f3;
  --accent-text: #c2410c;
  --accent-ink: #c2410c;
  --focus: #c2410c;
  --danger: #c62828;
  --danger-soft: #fdf0ef;
  --ok: #2e7d32;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0b0c; --surface: #161618; --surface-2: #222225;
    --border: #2a2a2e; --control-border: #71717a;
    --text: #f4f4f5; --text-sub: #a1a1aa;
    --accent-soft: #222225; --accent-text: #ff8a3d; --accent-ink: #ff8a3d; --focus: #ff8a3d;
    --danger: #ff8a80; --danger-soft: #3a2120; --ok: #81c784;
  }
}
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

* { box-sizing: border-box; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, Roboto, sans-serif;
  font-size: 1rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.page { max-width: 1200px; margin: 0 auto; padding: 0 1rem 1rem; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ヘッダー */
.site-header { padding-top: 0.75rem; }
h1 { font-size: clamp(1.25rem, 4vw, 1.6rem); margin: 0; line-height: 1.3; }
.lead { margin: 0.25rem 0 0.75rem; color: var(--text-sub); font-size: 0.875rem; }
h2, h3 { margin: 0; }
.notice { background: var(--accent-soft); border: 2px solid var(--accent); border-radius: 12px; padding: 0.5rem 0.75rem; }

/* 全体レイアウト（スマホ: 結果バー → 入力 → 上限・詳しい集計） */
.layout { display: flex; flex-direction: column; gap: 1rem; }
.results { display: contents; }
.summary { order: 0; }
.editor { order: 1; min-width: 0; }
.side { order: 2; min-width: 0; display: flex; flex-direction: column; gap: 1rem; }

/* 結果バー: スマホでは入力欄の上に固定（下部固定はキーボードに隠れるため上部） */
.summary {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0;
}
.main-nums { display: grid; grid-template-columns: 1.25fr 1fr 1fr; gap: 0.5rem; margin: 0; }
.num { margin: 0; min-width: 0; }
.num dt { font-size: 0.8125rem; color: var(--text-sub); line-height: 1.3; }
.num dd {
  margin: 0; font-size: 1.25rem; font-weight: 700; line-height: 1.2;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.num-main dt { color: var(--text); font-weight: 700; }
.num-main dd { font-size: clamp(1.75rem, 9vw, 2.5rem); }
.sub-nums {
  display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin: 0.25rem 0 0;
  font-size: 0.875rem; color: var(--text-sub);
}
.sub-nums b { color: var(--text); font-variant-numeric: tabular-nums; }
.selection { font-weight: 700; color: var(--text); border: 1.5px solid var(--control-border); border-radius: 999px; padding: 0 0.625rem; }

/* 入力 */
.field-label { display: block; font-size: 0.875rem; font-weight: 700; margin: 0 0 0.25rem; }
textarea {
  display: block; width: 100%;
  height: clamp(12rem, 45svh, 28rem);
  padding: 0.75rem; resize: vertical;
  font: inherit; font-size: 1rem; line-height: 1.7; color: var(--text);
  background: var(--surface);
  border: 2px solid var(--control-border); border-radius: 12px;
}
textarea.dragging { border-style: dashed; border-color: var(--focus); background: var(--accent-soft); }

.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.btn {
  min-height: 44px; min-width: 44px; padding: 0 1rem;
  font: inherit; font-size: 1rem; font-weight: 700; color: var(--text);
  background: var(--surface); border: 2px solid var(--control-border); border-radius: 12px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { min-height: 48px; background: var(--accent); border-color: var(--accent-dark); color: #0a0a0a; }
.btn-primary:hover { border-color: var(--accent-dark); background: var(--accent-dark); }

.file-status { margin: 0.5rem 0 0; font-size: 0.875rem; }
.file-status:empty { display: none; }
.file-status[data-state="error"] {
  background: var(--danger-soft); color: var(--danger); border: 2px solid var(--danger);
  border-radius: 12px; padding: 0.5rem 0.75rem; font-weight: 700;
}
.file-status[data-state="ok"] { color: var(--text-sub); }
.hint { margin: 0.5rem 0 0; font-size: 0.875rem; color: var(--text-sub); }

/* 上限 */
.limit-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
input[type="text"], select {
  min-height: 44px; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--surface); border: 2px solid var(--control-border); border-radius: 12px; padding: 0 0.75rem;
}
#limit { width: 8rem; font-variant-numeric: tabular-nums; }
select { max-width: 100%; }
.limit-status {
  margin: 0.5rem 0 0; padding: 0.375rem 0.75rem; border-radius: 12px;
  border: 1.5px solid var(--border); font-size: 0.9375rem; font-variant-numeric: tabular-nums;
}
.limit-status[data-state="none"] { border-color: transparent; padding-left: 0; color: var(--text-sub); font-size: 0.875rem; }
.limit-status[data-state="under"] { border-color: var(--control-border); font-weight: 700; }
.limit-status[data-state="over"] {
  background: var(--danger-soft); color: var(--danger); border: 2px solid var(--danger); font-weight: 700;
}

/* 詳しい集計 */
.details { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.details > summary {
  min-height: 44px; display: flex; align-items: center; padding: 0 1rem; cursor: pointer; font-weight: 700;
}
.details-body { padding: 0 1rem 1rem; }
.details h3 { font-size: 0.875rem; color: var(--text-sub); margin: 1rem 0 0.25rem; }
.kv { margin: 0; }
.kv > div { display: flex; justify-content: space-between; gap: 1rem; padding: 0.25rem 0; border-bottom: 1px solid var(--border); }
.kv dt { color: var(--text); font-size: 0.9375rem; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.fine { font-size: 0.8125rem; color: var(--text-sub); margin: 1rem 0 0; }

/* フッター */
.site-footer { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); font-size: 0.875rem; }
.site-footer p { margin: 0 0 0.5rem; }
.site-footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent-ink); font-weight: 700; }
.site-footer .fine { margin-top: 0; }

/* トースト（影は浮いている物だけ） */
.toast {
  position: fixed; left: 50%; bottom: 1rem; transform: translateX(-50%); z-index: 20;
  display: flex; align-items: center; gap: 0.75rem; max-width: calc(100vw - 2rem);
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 0.5rem 0.75rem;
  font-size: 0.9375rem; box-shadow: 0 4px 16px rgb(0 0 0 / 0.25);
}
.toast[hidden] { display: none; }
.toast-action {
  min-height: 44px; min-width: 44px; padding: 0 0.75rem; font: inherit; font-weight: 700; cursor: pointer;
  color: var(--bg); background: transparent; border: 2px solid currentColor; border-radius: 12px;
}
.toast-action[hidden] { display: none; }
.toast .toast-action:focus-visible { outline-color: var(--bg); }

/* PC: 左に入力欄、右に結果パネル（sticky） */
@media (min-width: 900px) {
  .page { padding: 0 1.5rem 1.5rem; }
  .layout { display: grid; grid-template-columns: minmax(0, 1fr) 24rem; gap: 1.5rem; align-items: start; }
  .editor { order: 0; }
  .results {
    display: flex; flex-direction: column; gap: 1rem;
    position: sticky; top: 1rem; max-height: calc(100svh - 2rem); overflow-y: auto;
  }
  .summary {
    position: static; order: 0; background: var(--surface);
    border: 1px solid var(--border); border-radius: 16px; padding: 1rem;
  }
  .side { order: 0; }
  .main-nums { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
  .num-main { grid-column: 1 / -1; }
  .num dd { font-size: 1.5rem; }
  .num.num-main dd { font-size: clamp(2.5rem, 4.5vw, 3.5rem); }
  .sub-nums { font-size: 0.9375rem; }
  textarea { height: clamp(18rem, calc(100svh - 18rem), 44rem); }
}

/* ===== edi-tool 共通: 上部バーと見出し（edi-tool/.github DESIGN.md 2026-11-06「4. 部品」） ===== */
.et-bar { align-self: stretch; box-sizing: border-box; margin: var(--et-bar-margin, 0 0 16px); padding: var(--et-bar-padding, 0); background: var(--surface, #fff); border-bottom: 1px solid var(--border); }
.et-bar-inner { box-sizing: border-box; max-width: var(--et-bar-max, 1200px); margin: 0 auto; padding: 6px 8px; min-height: 56px; display: flex; align-items: center; gap: 2px; font-size: 0.9375rem; line-height: 1.4; text-align: left; letter-spacing: normal; }
.et-home { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 8px; border-radius: 8px; color: var(--text); font-weight: 800; text-decoration: none; transition: background-color 120ms cubic-bezier(.2, .8, .2, 1); }
.et-home:hover { background: var(--surface-2, #f0f0f3); color: var(--text); text-decoration: none; }
.et-mark { flex: none; width: 14px; height: 14px; border-radius: 4px; background: var(--accent); }
.et-sep { flex: none; width: 16px; height: 16px; color: var(--text-sub); }
.et-current { min-width: 0; padding: 0 8px; font-weight: 700; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media print { .et-bar { display: none; } }
:root { --et-bar-max: 1200px; --et-bar-margin: 0; }
.site-header { padding-top: 1.25rem; }
h1 { font-size: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem); font-weight: 800; letter-spacing: -0.02em; }
.lead { font-size: 0.9375rem; }

/* ===== edi-tool 共通: 線のアイコン（DESIGN.md「5. アイコン」。記号の文字の代わりに使う） ===== */
.et-i, [data-icon]:not([data-icon=""])::before { content: ""; display: inline-block; flex: none; width: 1.15em; height: 1.15em; vertical-align: -0.2em; background-color: currentColor; -webkit-mask: var(--et-i) center / contain no-repeat; mask: var(--et-i) center / contain no-repeat; }
[data-icon]:not([data-icon=""])::before { margin-right: 0.35em; }
[data-icon="check"], .et-i-check { --et-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E"); }
[data-icon="ok"], .et-i-ok { --et-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpolyline points='8 12 11 15 16 9'/%3E%3C/svg%3E"); }
[data-icon="warn"], .et-i-warn { --et-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M10.3 3.9 1.8 18a2 2 0 0 0 1.7 3h17a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E"); }
[data-icon="info"], .et-i-info { --et-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cline x1='12' y1='11' x2='12' y2='16'/%3E%3Cline x1='12' y1='8' x2='12.01' y2='8'/%3E%3C/svg%3E"); }
[data-icon="lock"], .et-i-lock { --et-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='11' width='16' height='10' rx='2'/%3E%3Cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3E%3C/svg%3E"); }
[data-icon="arrow-down"], .et-i-arrow-down { --et-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='12' y1='5' x2='12' y2='19'/%3E%3Cpolyline points='19 12 12 19 5 12'/%3E%3C/svg%3E"); }
[data-icon="arrow-right"], .et-i-arrow-right { --et-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='5' y1='12' x2='19' y2='12'/%3E%3Cpolyline points='12 5 19 12 12 19'/%3E%3C/svg%3E"); }
[data-icon="chevron-down"], .et-i-chevron-down { --et-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }
[data-icon="chevron-left"], .et-i-chevron-left { --et-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 18 9 12 15 6'/%3E%3C/svg%3E"); }
[data-icon="x"], .et-i-x { --et-i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E"); }
.et-i { margin-inline-end: 0.35em; } .et-i.et-i-end { margin-inline: 0.35em 0; } .et-i.et-i-solo { margin: 0; }
footer a[href="https://edi-tool.github.io/"] { display: inline-flex; align-items: center; min-height: 44px; }
:root { --et-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E"); }
.et-live { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* edi-tool 共通: ツールの説明（検索で見つけてもらうための本文。閉じた開閉パネルに入れる） */
.et-about { width: min(40rem, calc(100% - 2rem)); margin: 2.5rem auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; color: var(--text); font-size: 0.9375rem; line-height: 1.8; text-align: left; }
.et-about > summary { list-style: none; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 1rem; border-radius: 16px; cursor: pointer; font-weight: 700; color: var(--text-sub); }
.et-about > summary::-webkit-details-marker { display: none; }
.et-about > summary:hover { color: var(--text); }
.et-about > summary:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.et-about > summary .et-i { flex: none; transition: transform 200ms ease; }
.et-about[open] > summary .et-i { transform: rotate(180deg); }
@media (prefers-reduced-motion: reduce) { .et-about > summary .et-i { transition: none; } }
.et-about-body { padding: 0 1rem 1rem; }
.et-about h2 { font-size: 1rem; font-weight: 700; line-height: 1.5; margin: 1.25rem 0 0.25rem; color: var(--text); }
.et-about-body > h2:first-child { margin-top: 0.25rem; }
.et-about p, .et-about ol, .et-about dl { margin: 0.25rem 0 0.75rem; color: var(--text-sub); }
.et-about ol { list-style: decimal; padding-left: 1.5em; }
.et-about li { margin: 0.125rem 0; }
.et-about dt { font-weight: 700; margin-top: 0.75rem; color: var(--text); }
.et-about dd { margin: 0.125rem 0 0; }
