/* 自作トレカ9面の寸法合わせ（/toreka/）。日英共通。
   上に 01 測った長さ（縦・横）、刷る条件（既定で閉じる）、下に 02 補正の倍率と A4 のプレビュー・PDF を作るボタン。 */
[hidden] { display: none !important; }
.tk { --t-line: var(--hairline, #e5e7eb); --t-strong: var(--hairline-strong, #d1d5db); --t-acc: var(--accent, #b45309); --t-soft: var(--ink-soft, #4b5563);
  --t-ink: var(--ink, #1f2937); --t-bad: #b91c1c; --t-bad-wash: #fee2e2; --t-ok: #15803d; --t-ok-wash: #f0fdf4; --t-warn: #854d0e; --t-warn-wash: #fefce8;
  border: 1px solid var(--t-line); background: var(--panel, #fff); margin-bottom: 8px; }
.tk-h { display: flex; align-items: baseline; gap: 10px; margin: 0; font-size: 16px; font-weight: 700; color: var(--t-ink); }
.tk-h > span { font: 500 12px/1 var(--mono); color: var(--t-acc); letter-spacing: .06em; }

/* 01 測った長さ */
.tk-in { padding: 18px 20px 14px; border-bottom: 1px solid var(--t-line); }
.tk-meas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; margin-top: 12px; max-width: 600px; }
.tk-m { display: grid; gap: 4px; min-width: 0; }
.tk-m label { font-size: 13px; font-weight: 600; color: var(--t-soft); }
.tk-m small { font: 500 11px var(--mono); color: #6b7280; margin-left: 2px; }
.tk-step { display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px; align-items: stretch; border: 1px solid var(--t-strong); background: #fff; }
.tk-step button { border: 0; background: #f3f4f6; color: var(--t-ink); font-size: 20px; line-height: 1; cursor: pointer; min-height: 48px; padding: 0; }
.tk-step button:hover { background: #e5e7eb; }
.tk-step input { border: 0; min-width: 0; width: 100%; box-sizing: border-box; text-align: center; font: 600 24px/1.2 var(--mono); color: var(--t-ink); padding: 6px 4px; background: transparent; }
.tk-step input:focus { outline: 2px solid var(--t-acc); outline-offset: -2px; }
.tk-err { margin: 8px 0 0; color: var(--t-bad); font-size: 14px; }
.tk-test { margin: 6px 0 0; font-size: 14px; line-height: 1.7; color: var(--t-soft); }
.tk-dl { color: var(--t-ink); font-weight: 700; text-underline-offset: 3px; }
.tk-dl::before { content: '↓ '; color: var(--t-acc); }
.tk-loaded { margin: 8px 0 0; font-size: 13px; color: var(--t-ok); }

/* 刷る条件（既定で閉じる） */
.tk-cond { border-bottom: 1px solid var(--t-line); font-size: 14px; }
.tk-cond summary { list-style: none; cursor: pointer; padding: 8px 20px; min-height: 40px; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; color: var(--t-soft); }
.tk-cond summary::-webkit-details-marker { display: none; }
.tk-cond summary b { color: var(--t-ink); font-weight: 600; }
.tk-change { margin-left: auto; font-size: 13px; color: var(--t-ink); text-decoration: underline; text-underline-offset: 3px; }
.tk-cond[open] .tk-change { visibility: hidden; }
.tk-cond-body { padding: 0 20px 14px; }
.tk-cond:not([open]) > .tk-cond-body { display: none; }
.tk-scope { margin: 0 0 10px; font-size: 13px; color: var(--t-soft); line-height: 1.6; }
.tk-cond-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; max-width: 600px; }
.tk-cond-grid label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--t-soft); min-width: 0; }
.tk-cond-grid select { font: inherit; font-size: 14px; font-weight: 400; padding: 8px; min-height: 44px; border: 1px solid var(--t-strong); background: #fff; color: var(--t-ink); min-width: 0; width: 100%; }
.tk-warn { padding: 10px 20px; background: var(--t-warn-wash); border-bottom: 1px solid #fde68a; color: var(--t-warn); font-size: 14px; line-height: 1.6; }
.tk-warn p { margin: 0; }
.tk-warn p + p { margin-top: 4px; }

/* 02 結果 */
.tk-out { padding: 18px 20px 18px; min-width: 0; }
.tk-res { display: grid; grid-template-columns: minmax(0, 1fr) minmax(180px, 260px); gap: 18px 24px; margin-top: 12px; align-items: start; }
.tk-res-main { min-width: 0; }
.tk-pct { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tk-pct > div { display: grid; gap: 2px; min-width: 0; }
.tk-pct small { font-size: 13px; color: var(--t-soft); font-weight: 600; }
.tk-pct b { font: 700 32px/1.1 var(--mono); color: var(--t-ink); letter-spacing: -.01em; }
/* 定規: 80〜120mm を1mmごとの目盛りで描き、中央の長い線が 100mm。帯の右端が測った長さ */
.tk-rule { position: relative; display: block; height: 14px; margin: 4px 0 2px; max-width: 220px;
  background: linear-gradient(var(--t-ink), var(--t-ink)) 50% 0 / 2px 14px no-repeat,
    repeating-linear-gradient(90deg, #9ca3af 0 1px, transparent 1px 2.5%) 0 0 / 100% 6px no-repeat,
    repeating-linear-gradient(90deg, #6b7280 0 1px, transparent 1px 12.5%) 0 0 / 100% 10px no-repeat;
  border-top: 1px solid #6b7280; }
.tk-rule i { position: absolute; left: 0; bottom: 0; height: 4px; width: 50%; background: var(--t-acc); }
.tk-pct em { font-style: normal; font-size: 12px; color: var(--t-soft); min-height: 1.4em; line-height: 1.4; }
.tk-fit { margin: 12px 0 0; font-size: 14px; line-height: 1.6; }
.tk-fit::before { font-weight: 700; margin-right: 4px; }
.tk-fit.ok { color: #14532d; }
.tk-fit.ok::before { content: '✓'; color: var(--t-ok); }
.tk-fit.ng { color: #7f1d1d; font-weight: 600; }
.tk-fit.ng::before { content: '×'; color: var(--t-bad); }
.tk-fit:empty { display: none; }
.tk-art { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 14px; font-size: 14px; }
.tk-art-l { color: var(--t-soft); }
.tk-art b { overflow-wrap: anywhere; }
.tk-file { position: relative; display: inline-flex; align-items: center; min-height: 40px; padding: 0 12px; border: 1px solid var(--t-strong); background: #fff; color: var(--t-ink); cursor: pointer; font-size: 14px; }
.tk-file:hover, .tk-file:focus-within { border-color: var(--t-ink); }
.tk-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.tk-link { border: 0; background: none; padding: 6px 0; font: inherit; font-size: 14px; color: var(--t-ink); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; min-height: 36px; }
.tk-note { margin: 8px 0 0; padding: 8px 10px; background: var(--t-warn-wash); color: var(--t-warn); font-size: 13px; line-height: 1.6; }
.tk-note a { color: inherit; font-weight: 700; }
.tk-fit .tk-open-scale { display: inline; min-height: 0; padding: 0; font-weight: 700; color: var(--t-bad); }
.tk-btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border: 1px solid var(--t-ink); background: var(--t-ink); color: #fff;
  font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; transition: background-color .12s; }
.tk-btn:hover { background: #374151; }
.tk-btn:disabled { opacity: .45; cursor: not-allowed; }
.tk-btn.sub { background: #fff; color: var(--t-ink); border-color: var(--t-strong); }
.tk-btn.sub:hover { border-color: var(--t-ink); }
.tk-run { margin-top: 14px; min-width: 14em; background: var(--t-acc); border-color: var(--t-acc); font-size: 16px; }
.tk-run:hover { background: #92400e; }
.tk-prev-wrap { margin: 0; }
.tk-prev-wrap canvas { display: block; width: 100%; height: auto; aspect-ratio: 210 / 297; border: 1px solid var(--t-strong); box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05); background: #fff; }
.tk-prev-wrap figcaption { margin-top: 6px; font-size: 12px; color: var(--t-soft); line-height: 1.5; }

/* PDF を作った後 */
.tk-done { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--t-line); }
.tk-saved { margin: 0; font-weight: 700; color: var(--t-ok); overflow-wrap: anywhere; }
.tk-done-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.tk-status { margin: 6px 0 0; font-size: 13px; color: var(--t-soft); min-height: 1.4em; overflow-wrap: anywhere; }
.tk-check-h { margin: 12px 0 4px; font-size: 15px; }
.tk-check { margin: 0; padding-left: 1.4em; font-size: 14px; line-height: 1.7; }
.tk-small { margin: 6px 0 0; font-size: 12px; color: var(--t-soft); }
.tk-pop { animation: tk-pop .22s ease both; }
@keyframes tk-pop { from { opacity: .3; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tk-pop { animation: none; } .tk-btn { transition: none; } }

/* 下の見出しは日本語のふつうの見出しにする（サイト共通の英大文字・朱の短い線を、このページでは使わない） */
.tool-main > .section > h2 { font-family: inherit; font-size: 16px; font-weight: 700; letter-spacing: 0; text-transform: none; color: var(--ink, #1f2937); margin-bottom: 12px; }
.tool-main > .section > h2::before { content: none; }
.tool-main > .section > .section-note + .section-note { margin-top: 10px; }
/* 使い方: 3つの箱ではなく、定規の上を左から右へ進む流れ。各段に測る値の例を添える */
ol.tk-steps { border: 0; border-top: 2px solid var(--ink, #1f2937); gap: 0 20px; padding-top: 0; position: relative;
  background: repeating-linear-gradient(90deg, #9ca3af 0 1px, transparent 1px 10px) 0 0 / 100% 6px no-repeat; }
ol.tk-steps li { padding: 14px 0 0; }
ol.tk-steps li + li { border-left: 0; }
ol.tk-steps li::before { display: inline-block; margin: 0 6px 0 0; }
ol.tk-steps b { display: inline; }
.tk-ex { display: block; margin-top: 6px; font: 500 13px var(--mono); color: var(--ink, #1f2937); }

@media (max-width: 640px) {
  .tk-in, .tk-out { padding-left: 14px; padding-right: 14px; }
  .tk-cond summary, .tk-warn { padding-left: 14px; padding-right: 14px; }
  /* 条件は1行に収める（はみ出す分は … で切り、全部は「変える」を開いて見る） */
  .tk-cond summary { font-size: 13px; padding-left: 12px; padding-right: 12px; gap: 4px; flex-wrap: nowrap; white-space: nowrap; }
  .tk-cond summary b { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .tk-in { padding-top: 14px; }
  .tk-out { padding-top: 14px; }
  .tk-rule { display: none; }
  .tk-meas, .tk-res { margin-top: 8px; }
  .tk-cond-body { padding-left: 14px; padding-right: 14px; }
  .tk-meas { gap: 10px; }
  .tk-step { grid-template-columns: 34px minmax(0, 1fr) 34px; }
  .tk-step input { font-size: 20px !important; padding: 6px 0; }
  .tk-res { grid-template-columns: minmax(0, 1fr) 112px; gap: 12px; }
  /* 数字とプレビューだけ横に並べ、収まりの文・絵柄・ボタンは全幅で下に置く */
  .tk-res-main { display: contents; }
  .tk-pct { order: 0; align-self: center; }
  /* プレビューの説明は横の狭い欄で3行に折れるので、全幅で下へ回す */
  .tk-prev-wrap { display: contents; }
  .tk-prev-wrap canvas { order: 1; }
  .tk-prev-wrap figcaption { order: 3; grid-column: 1 / -1; margin-top: 0; }
  .tk-res-main > :not(.tk-pct) { order: 3; grid-column: 1 / -1; }
  /* ボタンとファイル名は数字・プレビューのすぐ下へ上げ、入力から保存までを最初の画面に収める（収まりの文・絵柄はその下） */
  .tk-res-main > .tk-run { order: 2; }
  .tk-fit, .tk-art, .tk-run { margin-top: 0; }
  .tk-pct { grid-template-columns: 1fr; gap: 8px; }
  .tk-pct b { font-size: 26px; }
  .tk-cond-grid { grid-template-columns: 1fr; }
  .tk-run { width: 100%; min-width: 0; }
  ol.tk-steps { gap: 0; }
  ol.tk-steps li + li { border-top: 0; }
}
.tk-hint { margin: 4px 0 0; font-size: 12px; color: var(--t-soft); line-height: 1.5; }
/* 裏面・塗り足し（表の絵柄と同じ行の形） */
.tk-bleed { color: var(--t-soft); }
.tk-bleed select { font: inherit; font-size: 14px; padding: 6px 8px; min-height: 40px; border: 1px solid var(--t-strong); background: #fff; color: var(--t-ink); max-width: 100%; min-width: 0; }
.tk-art + .tk-hint + .tk-art, .tk-hint + .tk-bleed { margin-top: 10px; }
/* 収まらないときの代わりの出し方: 設定の確認・塗り足しを外す・面を減らす を縦に並べる */
.tk-alts { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; margin-top: 6px; }
.tk-fit .tk-alt { min-height: 36px; padding: 4px 0; font-weight: 700; color: var(--t-ink); text-align: left; }
@media (max-width: 640px) {
  .tk-res-main > .tk-art, .tk-res-main > .tk-hint, .tk-res-main > .tk-note { margin-top: 0; }
}
.tk-fit.ok .tk-open-scale { color: inherit; }
