/* J トークナイザページ。トークン（色・フォント・余白）は ../style.css の :root を使用 */

.tk {
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Noto Sans Mono CJK JP", "Hiragino Sans", monospace;
  --warn: #8a4b00;
  --warn-soft: #fdf1e0;
  --err: #a8201a;
  --chip-0: #e8eefc;
  --chip-1: #e7f4ec;
  --chip-2: #fdf0e1;
  --chip-3: #f2e9fb;
  --chip-4: #fbe8ec;
  --chip-line-0: #b9c9f3;
  --chip-line-1: #b4d9c2;
  --chip-line-2: #efcf9f;
  --chip-line-3: #d3bbea;
  --chip-line-4: #efb8c4;
  overflow-x: hidden;
}

.tk-back {
  font-size: var(--fs-small); font-weight: 500; color: var(--ink);
  text-decoration: none; padding: 8px 4px; white-space: nowrap;
}
.tk-back:hover { color: var(--accent); }

/* ---------- Hero ---------- */
.tk-hero { padding: clamp(40px, 6vw, 80px) 0 32px; border-bottom: 1px solid var(--rule); }
.tk-eyebrow { color: var(--accent); font-weight: 700; font-size: var(--fs-meta); letter-spacing: 0.14em; text-transform: uppercase; }
.tk-title {
  font-family: var(--font-display); font-size: clamp(2rem, 1.2rem + 3.6vw, 3.25rem);
  line-height: 1.3; letter-spacing: 0.02em; margin-top: 4px;
}
.tk-lead { margin-top: 16px; max-width: 40em; color: var(--ink-sub); line-height: 1.9; }
.tk-subnav { display: flex; flex-wrap: wrap; gap: 8px 8px; margin-top: 24px; }
.tk-subnav a {
  padding: 6px 16px; border: 1px solid var(--rule); border-radius: 999px;
  color: var(--ink); font-size: var(--fs-small); font-weight: 500; text-decoration: none;
}
.tk-subnav a:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.tk-load { margin-top: 20px; font-size: var(--fs-small); color: var(--ink-sub); }
.tk-load.is-ok { color: var(--green); }
.tk-error, .tk-load.is-error { color: var(--err); font-size: var(--fs-small); font-weight: 500; }
.tk-load .tk-btn { margin-left: 8px; }

/* ---------- Sections ---------- */
.tk-section { padding: clamp(40px, 5vw, 72px) 0; }
.tk-section-tint { background: var(--paper-tint); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.tk-h2 {
  font-family: var(--font-display); font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2rem);
  letter-spacing: 0.04em; line-height: 1.4; margin-bottom: 24px;
  padding-top: 14px; border-top: 2px solid var(--rule-strong);
}
.tk-h3 { font-size: var(--fs-h3); line-height: 1.6; margin: 0 0 12px; }
.tk-text { color: var(--ink-sub); font-size: 0.9375rem; line-height: 1.85; }
.tk-hint { margin-top: 8px; color: var(--ink-faint); font-size: var(--fs-meta); line-height: 1.7; }
.tk-note {
  margin-top: 8px; padding: 8px 12px; border-radius: var(--radius);
  background: var(--warn-soft); color: var(--warn); font-size: var(--fs-small); line-height: 1.7;
}
.tk code, .tk .tk-hash { font-family: var(--mono); font-size: 0.875em; }
.tk code { padding: 0 4px; border-radius: 3px; background: var(--paper-tint); }
.tk-section-tint code { background: #fff; }

/* ---------- Form parts ---------- */
.tk-label { display: block; font-size: var(--fs-meta); font-weight: 700; color: var(--ink-sub); letter-spacing: 0.04em; }
.tk-field-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 6px; }
.tk-samples { display: flex; flex-wrap: wrap; gap: 6px; }

.tk-textarea, .tk-input, .tk-select {
  width: 100%; border: 1px solid #b7c0cf; border-radius: var(--radius);
  background: #fff; color: var(--ink); font: inherit;
}
.tk-textarea { padding: 12px 14px; font-size: 1rem; line-height: 1.7; resize: vertical; min-height: 7.5em; max-height: 60vh; font-family: var(--font-body); }
.tk-input { height: 44px; padding: 0 12px; font-family: var(--mono); font-size: 0.9375rem; }
.tk-select { height: 44px; padding: 0 32px 0 12px; font-size: 0.9375rem; appearance: none; -webkit-appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%234f5a6e' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 12px center; }
.tk-textarea:focus-visible, .tk-input:focus-visible, .tk-select:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.tk-textarea:disabled, .tk-input:disabled, .tk-select:disabled { background: var(--paper-tint); color: var(--ink-faint); }

.tk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border: 1px solid #b7c0cf; border-radius: var(--radius);
  background: #fff; color: var(--ink); font: inherit; font-size: var(--fs-small); font-weight: 700; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.tk-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.tk-btn:disabled { color: var(--ink-faint); cursor: not-allowed; background: var(--paper-tint); }
.tk-btn.is-done { border-color: var(--green); color: var(--green); background: var(--green-soft); }
.tk-btn-sm { min-height: 32px; padding: 0 12px; font-size: 12px; font-weight: 500; }

.tk-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-top: 16px; }

.tk-switch { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--fs-small); font-weight: 500; line-height: 1.5; min-height: 44px; padding-top: 2px; }
.tk-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tk-switch-ui {
  flex: none; position: relative; width: 40px; height: 24px; margin-top: 2px; border-radius: 12px;
  background: #aab3c3; transition: background .2s;
}
.tk-switch-ui::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .2s var(--ease-out);
}
.tk-switch input:checked + .tk-switch-ui { background: var(--accent); }
.tk-switch input:checked + .tk-switch-ui::after { transform: translateX(16px); }
.tk-switch input:focus-visible + .tk-switch-ui { outline: 2px solid var(--accent); outline-offset: 2px; }
.tk-switch-sub { display: block; color: var(--ink-faint); font-size: 12px; font-weight: 400; }

.tk-seg { display: inline-flex; margin: 0; padding: 0; border: 1px solid #b7c0cf; border-radius: var(--radius); overflow: hidden; min-width: 0; }
.tk-seg label { position: relative; display: block; }
.tk-seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.tk-seg span { display: flex; align-items: center; min-height: 42px; padding: 0 18px; font-size: var(--fs-small); font-weight: 700; background: #fff; color: var(--ink-sub); }
.tk-seg label + label span { border-left: 1px solid #b7c0cf; }
.tk-seg input:checked + span { background: var(--accent); color: #fff; }
.tk-seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -4px; }

.tk-check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-size: var(--fs-small); font-weight: 500; cursor: pointer; align-self: flex-end; }
.tk-check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- Stats ---------- */
.tk-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 20px 0 0; border-top: 1px solid var(--rule-strong); }
.tk-stats > div { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); }
.tk-stats dt { font-size: 12px; color: var(--ink-faint); font-weight: 500; letter-spacing: 0.04em; }
.tk-stats dd { margin: 0; font-family: var(--mono); font-size: 1.375rem; font-weight: 700; line-height: 1.4; font-variant-numeric: tabular-nums; }

/* ---------- Token output ---------- */
.tk-out {
  display: flex; flex-wrap: wrap; align-content: flex-start; gap: 3px 2px;
  margin-top: 16px; padding: 12px; min-height: 96px; max-height: 70vh; overflow: auto;
  border: 1px solid var(--rule); border-radius: var(--radius); background: #fff;
  font-size: 1rem; line-height: 1.5;
}
.tk-out .brk { flex-basis: 100%; height: 0; }
.tk-out .empty { color: var(--ink-faint); font-size: var(--fs-small); }

.chip {
  display: inline-block; max-width: 100%; margin: 0; padding: 2px 5px; border: 0; border-bottom: 2px solid transparent; border-radius: 4px;
  font: inherit; color: var(--ink); cursor: pointer; text-align: left; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45;
}
.chip.c0 { background: var(--chip-0); border-bottom-color: var(--chip-line-0); }
.chip.c1 { background: var(--chip-1); border-bottom-color: var(--chip-line-1); }
.chip.c2 { background: var(--chip-2); border-bottom-color: var(--chip-line-2); }
.chip.c3 { background: var(--chip-3); border-bottom-color: var(--chip-line-3); }
.chip.c4 { background: var(--chip-4); border-bottom-color: var(--chip-line-4); }
.chip:hover, .chip.is-active { box-shadow: 0 0 0 2px var(--accent); position: relative; z-index: 1; }
.chip:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-radius: 4px; position: relative; z-index: 1; }
.chip.is-id { font-family: var(--mono); font-size: 0.875rem; }
.chip.is-byte, .chip-demo.is-byte {
  font-family: var(--mono); font-size: 0.8125rem; color: #3a4357;
  background: repeating-linear-gradient(135deg, #eceff4 0 5px, #dde2eb 5px 10px);
  border: 1px dashed #7d889c; padding: 1px 4px;
}
.chip.is-special { background: var(--ink); color: #fff; border-bottom-color: var(--ink); }
.chip-demo { display: inline-block; padding: 0 6px; border-radius: 4px; margin-right: 6px; }

.sym {
  display: inline-block; margin: 0 1px; padding: 0 3px; border-radius: 3px; vertical-align: baseline;
  background: rgba(20, 27, 43, .12); color: #2a3550; font-family: var(--mono); font-size: 0.75em; font-weight: 500; line-height: 1.5;
}
.sym-esc { background: rgba(168, 32, 26, .14); color: #8c1b16; }
.is-special .sym { background: rgba(255,255,255,.2); color: #fff; }
.sp { color: #2d5bd6; font-weight: 700; }
.chip.is-id .sp, .is-special .sp { color: inherit; }
.mk { color: var(--ink-faint); }

.tk-detail {
  margin-top: 12px; padding: 12px 14px; min-height: 72px; border-radius: var(--radius);
  background: var(--paper-tint); border: 1px solid var(--rule); font-size: var(--fs-small);
}
.tk-detail-empty { color: var(--ink-faint); line-height: 1.7; }
.tk-detail dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px 16px; margin: 0; }
.tk-detail dt { font-size: 11px; color: var(--ink-faint); font-weight: 500; letter-spacing: .04em; }
.tk-detail dd { margin: 0; font-family: var(--mono); font-size: 0.9375rem; overflow-wrap: anywhere; line-height: 1.5; }
.tk-detail dd.wide { grid-column: 1 / -1; }
.tk-detail .jump { margin-top: 10px; }

.tk-legend { display: flex; flex-wrap: wrap; gap: 6px 24px; list-style: none; margin: 16px 0 0; padding: 0; font-size: 12px; color: var(--ink-sub); line-height: 1.8; }

/* ---------- Vocab ---------- */
.tk-search { display: grid; gap: 12px; margin-bottom: 4px; }
.tk-search-row { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.tk-field-inline { min-width: 0; }
.tk-field-inline .tk-label { margin-bottom: 4px; }
.tk-grow { flex: 1 1 260px; }
.tk-select { width: auto; min-width: 120px; }
.tk-count { margin-top: 12px; font-size: var(--fs-small); font-weight: 700; font-variant-numeric: tabular-nums; }
#v-error { margin-top: 4px; }

.tk-table { margin-top: 12px; border: 1px solid var(--rule-strong); border-radius: var(--radius); background: #fff; overflow: hidden; }
.tk-scroll { position: relative; height: min(70vh, 640px); min-height: 280px; overflow: auto; overscroll-behavior: contain; }
.tk-vhead, .vrow {
  display: grid; grid-template-columns: 88px minmax(0, 1fr) 100px 72px 64px; align-items: center; column-gap: 8px;
  padding: 0 12px; height: 36px;
}
.tk-vhead {
  position: sticky; top: 0; z-index: 2; background: var(--ink); color: #fff; font-size: 12px; font-weight: 700; letter-spacing: .06em;
}
.tk-spacer { position: relative; }
.tk-rows { position: absolute; left: 0; right: 0; top: 0; }
.vrow { border-bottom: 1px solid var(--rule); font-size: 0.875rem; cursor: pointer; }
.vrow:nth-child(even) { background: #fafbfd; }
.vrow:hover { background: var(--accent-soft); }
.vrow.is-target { background: #fff3c4; box-shadow: inset 3px 0 0 var(--accent); }
.vrow > div { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vrow .id { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-sub); }
.vrow .pc { font-family: var(--font-body); font-size: 1rem; }
.vrow .num, .tk-vhead .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tk-vhead .num { font-family: inherit; }
.vrow .ty { font-size: 12px; }
.ty-normal { color: var(--ink-sub); }
.ty-byte { color: #5a4a8a; }
.ty-special { color: var(--err); font-weight: 700; }
.vrow .sym { font-size: 0.7em; }

.tk-empty { padding: 32px 16px; text-align: center; color: var(--ink-faint); font-size: var(--fs-small); }

/* ---------- About ---------- */
.tk-cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 40px 56px; }
.tk-spec { margin: 0; border-top: 1px solid var(--rule-strong); }
.tk-spec > div { display: grid; grid-template-columns: 8.5em minmax(0, 1fr); gap: 4px 16px; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.tk-spec dt { font-weight: 700; font-size: var(--fs-small); }
.tk-dt-sub { font-weight: 400; color: var(--ink-faint); font-size: 12px; }
.tk-spec dd { margin: 0; color: var(--ink-sub); font-size: 0.9375rem; line-height: 1.7; overflow-wrap: anywhere; }
.tk-hash { word-break: break-all; }
.tk-etable { width: 100%; border-collapse: collapse; margin: 14px 0 32px; font-size: var(--fs-small); }
.tk-etable th, .tk-etable td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--rule); }
.tk-etable thead th { border-bottom: 1px solid var(--rule-strong); font-size: 12px; color: var(--ink-faint); }
.tk-links { margin: 0 0 16px; padding-left: 1.2em; font-size: 0.9375rem; line-height: 1.9; }
.tk-privacy { padding: 12px 14px; border-left: 3px solid var(--green); background: var(--green-soft); color: var(--ink); }

/* ---------- Tokenizer picker ---------- */
.tk-picker { margin-top: 24px; max-width: 28rem; }
.tk-picker .tk-select { margin-top: 4px; }
.tk-picker .tk-hint { min-height: 1.7em; }
.tk-using { margin: -4px 0 16px; color: var(--ink-sub); font-size: var(--fs-small); }

/* ---------- Compare ---------- */
.tk-cmp-pick { list-style: none; margin: 16px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 2px 20px; }
.tk-cmp-pick li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.tk-cmp-pick .tk-check { align-self: auto; }
.tk .tk-btn[hidden] { display: none; }
.tk-cmp-st { color: var(--ink-faint); font-size: 12px; min-width: 0; overflow-wrap: anywhere; }
.tk-cmp-st.is-error { color: var(--err); }
.tk-cmp-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 8px; }
.tk-cmp-actions .tk-hint { margin: 0; }
.tk-cmp { margin-top: 20px; display: grid; gap: 12px; }
.tk-cmp-row { min-width: 0; padding: 14px 16px; border: 1px solid var(--rule); border-radius: var(--radius); background: #fff; }
.tk-cmp-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; }
.tk-cmp-head strong { font-size: 1.0625rem; }
.tk-cmp-sz { color: var(--ink-faint); font-size: 12px; }
.tk-cmp-best { padding: 0 8px; border-radius: 999px; background: var(--green-soft); color: var(--green); font-size: 12px; font-weight: 700; }
.tk-cmp-wait { margin: 6px 0 0; color: var(--ink-faint); font-size: var(--fs-small); }
.tk-cmp-nums { display: flex; flex-wrap: wrap; gap: 4px 28px; margin: 8px 0 0; }
.tk-cmp-nums > div { min-width: 0; }
.tk-cmp-nums dt { font-size: 12px; color: var(--ink-faint); }
.tk-cmp-nums dd { margin: 0; font-family: var(--mono); font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tk-cmp-bar { height: 6px; margin-top: 8px; border-radius: 3px; background: var(--paper-tint); overflow: hidden; }
.tk-cmp-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.tk-cmp-chips { display: flex; flex-wrap: wrap; gap: 3px 2px; margin-top: 10px; font-size: 0.9375rem; line-height: 1.5; min-width: 0; }
.chip.cchip { cursor: default; }
.chip.cchip:hover { box-shadow: none; }
.tk-cmp-more { align-self: center; padding: 0 6px; color: var(--ink-faint); font-size: 12px; }
.tk-h3-gap { margin-top: 32px; }
.tk-ver { margin-bottom: 28px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .tk-cols { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .tk-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tk-back { font-size: 13px; }
  .brand-ja { font-size: 10px; letter-spacing: 0.02em; }
  .tk-spec > div { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .tk-vhead, .vrow { grid-template-columns: 48px minmax(0, 1fr) 60px 52px; padding: 0 8px; column-gap: 6px; }
  .tk-vhead > :nth-child(5), .vrow > :nth-child(5) { display: none; }
  .vrow { font-size: 0.75rem; }
  .vrow .pc { font-size: 0.9375rem; }
  .tk-select { min-width: 0; max-width: 100%; }
  .tk-field-inline { flex: 1 1 130px; }
  .tk-check { align-self: auto; }
  .header-inner { gap: 8px; }
  .brand-mark { flex: none; }
}
@media (max-width: 400px) {
  .brand-ja { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .tk-switch-ui, .tk-switch-ui::after { transition: none; }
}
