/* ===== 개발자 유틸리티 ===== */

.tl {
  --card: #132620;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "D2Coding", monospace;
  max-width: 96rem;
  margin-inline: auto;
  padding: clamp(1.25rem, 3vw, 2rem) var(--gutter) 3rem;
  font-size: 0.875rem;
}
:root[data-theme="light"] .tl { --card: #F6FAF7; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.tl-head { margin-bottom: 1.25rem; }
.tl-head h1 { font-size: clamp(1.5rem, 3vw, 2rem); font-weight: 800; }
.tl-head p { max-width: 52rem; margin-top: 0.35rem; color: var(--ink-soft); font-size: 0.8125rem; line-height: 1.6; }

.tl-layout { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: 1.5rem; align-items: start; }

/* 도구 목록 */
.tl-nav { position: sticky; top: calc(var(--top-offset, 0px) + 1rem); transition: top .28s cubic-bezier(.2, .8, .2, 1); display: grid; gap: 0.75rem; }
.tl-nav__search { width: 100%; }
.tl-nav__group { display: grid; gap: 0.1rem; }
.tl-nav__group + .tl-nav__group { margin-top: 0.6rem; }
.tl-nav__label { margin-bottom: 0.15rem; padding-inline: 0.6rem; color: var(--ink-soft); font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.04em; }
.tl-nav__item { padding: 0.35rem 0.6rem; border-radius: 8px; color: var(--ink); font-weight: 500; text-decoration: none; }
.tl-nav__item:hover { background: var(--tile); }
.tl-nav__item[aria-current="page"] { background: color-mix(in srgb, var(--seal) 16%, transparent); color: var(--ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--seal); }
.tl-nav__empty { padding: 0.5rem 0.6rem; color: var(--ink-soft); }

/* 도구 하나 */
.tl-tool { display: grid; gap: 0.85rem; min-width: 0; }
.tl-tool[hidden] { display: none; }
.tl-tool__head h2 { font-size: 1.25rem; font-weight: 800; }
.tl-tool__head p { margin-top: 0.25rem; color: var(--ink-soft); line-height: 1.6; }
.tl-tool h3 { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.6rem; font-size: 0.875rem; }

.tl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.tl-split { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 0.85rem; }
.tl-card { min-width: 0; padding: 0.9rem 1rem; border: 1px solid var(--rule); border-radius: 12px; background: var(--card); }
.tl-card .tl-field + .tl-field { margin-top: 0.6rem; }

.tl-field { display: grid; gap: 0.3rem; min-width: 0; font-size: 0.8125rem; font-weight: 600; }
.tl-field > span:first-child { color: var(--ink-soft); }
.tl-field__bar { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; color: var(--ink-soft); }
.tl-inline { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--ink-soft); font-size: 0.8125rem; font-weight: 600; }
.tl-check { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--ink); font-size: 0.8125rem; cursor: pointer; }
.tl-check input { accent-color: var(--seal); }

.tl-input {
  min-width: 0;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--field-line, var(--rule));
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 400;
}
.tl-input:focus { border-color: var(--seal); outline: none; }
.tl-input[readonly] { background: var(--card); }
textarea.tl-input { width: 100%; resize: vertical; line-height: 1.55; }
.tl-code { font-family: var(--mono); font-size: 0.8125rem; tab-size: 2; }
.tl-num { width: 5.5rem; }
.tl-file { max-width: 14rem; font-size: 0.75rem; }

.tl-btn {
  padding: 0.42rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
}
.tl-btn:hover:not(:disabled) { border-color: var(--ink-soft); }
.tl-btn:disabled { opacity: 0.6; cursor: default; }
.tl-btn--primary { border-color: var(--seal-btn, var(--seal)); background: var(--seal-btn, var(--seal)); color: #fff; }
.tl-btn--primary:hover:not(:disabled) { border-color: var(--seal); filter: brightness(.92); }
.tl-copy,
.tl-link { padding: 0.05rem 0.45rem; border: 1px solid var(--rule); border-radius: 6px; background: none; color: var(--ink-soft); font: inherit; font-size: 0.6875rem; font-weight: 600; cursor: pointer; }
.tl-copy:hover, .tl-link:hover { border-color: var(--ink-soft); color: var(--ink); }

.tl-status { min-height: 1.3em; color: var(--ink-soft); font-size: 0.8125rem; }
.tl-status.is-bad { color: var(--seal); font-weight: 600; }
.tl-hint { color: var(--ink-soft); font-size: 0.75rem; }
.tl-warn { padding: 0.6rem 0.85rem; border: 1px solid color-mix(in srgb, var(--seal) 60%, transparent); border-radius: 10px; background: color-mix(in srgb, var(--seal) 8%, transparent); font-size: 0.8125rem; line-height: 1.6; }

.tl-pre {
  min-height: 3rem;
  margin: 0;
  padding: 0.6rem 0.75rem;
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--card);
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* 이름 - 값 목록 */
.tl-dl { display: grid; gap: 0.35rem; margin: 0; }
.tl-dl div { display: grid; grid-template-columns: 9rem minmax(0, 1fr); gap: 0.6rem; align-items: start; }
.tl-dl--wide div { grid-template-columns: 11rem minmax(0, 1fr); }
.tl-dl dt { padding-top: 0.15rem; color: var(--ink-soft); font-size: 0.75rem; }
.tl-dl dd { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; margin: 0; min-width: 0; }
.tl-dl code { font-family: var(--mono); font-size: 0.8125rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.tl-dl small { color: var(--ink-soft); font-size: 0.75rem; }

/* 타임스탬프 */
.tl-now { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.tl-now div { display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.85rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); }
.tl-now span { color: var(--ink-soft); font-size: 0.75rem; }
.tl-now output { font-family: var(--mono); font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* API */
.tl-api { display: grid; gap: 0.75rem; }
.tl-api__line { display: flex; gap: 0.5rem; }
.tl-api__line .tl-code { flex: 1; }
.tl-api__result { display: grid; gap: 0.6rem; }
.tl-api__result[hidden] { display: none; }
.tl-api__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; color: var(--ink-soft); font-size: 0.8125rem; }
.tl-badge { padding: 0.1rem 0.55rem; border: 1px solid var(--rule); border-radius: 999px; font-weight: 700; }
.tl-badge.is-ok { border-color: #5DAE6B; color: #5DAE6B; }
.tl-badge.is-bad { border-color: var(--seal); color: var(--seal); }
:root[data-theme="light"] .tl-badge.is-ok { border-color: #2F7A3F; color: #2F7A3F; }
.tl-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--rule); }
.tl-tabs button { margin-bottom: -1px; padding: 0.4rem 0.8rem; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--ink-soft); font: inherit; font-weight: 700; cursor: pointer; }
.tl-tabs button[aria-selected="true"] { border-bottom-color: var(--seal); color: var(--ink); }

/* 계산기 */
.tl-calc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem); gap: 1rem; align-items: start; }
.tl-calc__main { display: grid; gap: 0.6rem; }
.tl-calc__input { width: 100%; padding: 0.7rem 0.8rem; font-size: 1.125rem; }
.tl-calc__result { display: block; min-height: 2.6rem; padding: 0.25rem 0.2rem; overflow-wrap: anywhere; font-family: var(--mono); font-size: 1.75rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.tl-calc__result.is-bad { color: var(--seal); font-size: 0.9375rem; font-weight: 600; }
.tl-calc__side { display: grid; gap: 0.85rem; }
.tl-keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; max-width: 26rem; }
.tl-key { padding: 0.6rem 0; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); color: var(--ink); font: inherit; font-family: var(--mono); font-size: 0.9375rem; font-weight: 600; cursor: pointer; }
.tl-key:hover { border-color: var(--ink-soft); }
.tl-key--eq { border-color: var(--seal-btn, var(--seal)); background: var(--seal-btn, var(--seal)); color: #fff; }
.tl-key--clear { color: var(--seal); }
.tl-history { display: grid; gap: 0.25rem; max-height: 18rem; margin: 0; padding: 0; overflow: auto; list-style: none; }
.tl-history__item { display: grid; width: 100%; padding: 0.35rem 0.5rem; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; text-align: right; cursor: pointer; }
.tl-history__item:hover { background: var(--tile); }
.tl-history__item span { overflow: hidden; color: var(--ink-soft); font-family: var(--mono); font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.tl-history__item strong { font-family: var(--mono); overflow-wrap: anywhere; }

/* 정규식 */
.tl-regex { display: flex; align-items: center; gap: 0.35rem; }
.tl-regex .tl-code { flex: 1; }
.tl-regex .tl-regex__flags { flex: none; width: 4.5rem; }
.tl-regex__slash { color: var(--ink-soft); font-family: var(--mono); font-size: 1.125rem; }
.tl-highlight mark { padding: 0 1px; border-radius: 3px; background: color-mix(in srgb, #E9B949 55%, transparent); color: inherit; }
.tl-matches { display: grid; gap: 0.45rem; max-height: 20rem; overflow: auto; font-weight: 400; }
.tl-match { padding: 0.45rem 0.6rem; border: 1px solid var(--rule); border-radius: 8px; background: var(--card); }
.tl-match p { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem; }
.tl-match code { font-family: var(--mono); overflow-wrap: anywhere; }
.tl-match small { color: var(--ink-soft); }
.tl-match ol, .tl-match ul { display: grid; gap: 0.15rem; margin: 0.3rem 0 0; padding: 0; list-style: none; }
.tl-match li { display: flex; gap: 0.5rem; font-size: 0.75rem; }
.tl-match li span { color: var(--ink-soft); font-family: var(--mono); }

/* 텍스트 비교 */
.tl-diff { overflow: auto; border: 1px solid var(--rule); border-radius: 10px; font-family: var(--mono); font-size: 0.8125rem; }
.tl-diff:empty { display: none; }
.tl-diff__row { display: grid; grid-template-columns: 2.75rem 2.75rem 1.5rem minmax(0, 1fr); }
.tl-diff__row.is-add { background: color-mix(in srgb, #5DAE6B 18%, transparent); }
.tl-diff__row.is-del { background: color-mix(in srgb, var(--seal) 16%, transparent); }
.tl-diff__no { padding: 0.1rem 0.5rem; border-right: 1px solid var(--rule); color: var(--ink-soft); text-align: right; user-select: none; }
.tl-diff__op { padding: 0.1rem 0; font-weight: 800; text-align: center; user-select: none; }
.tl-diff__row.is-add .tl-diff__op { color: #5DAE6B; }
.tl-diff__row.is-del .tl-diff__op { color: var(--seal); }
.tl-diff__text { padding: 0.1rem 0.5rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* 색상 */
.tl-color { display: flex; flex-wrap: wrap; gap: 1rem; align-items: stretch; }
.tl-color__swatch { flex: none; width: 8rem; min-height: 6rem; border: 1px solid var(--rule); border-radius: 12px; }
.tl-color__form { display: grid; flex: 1 1 16rem; gap: 0.6rem; }
.tl-color__form input[type="color"] { width: 4rem; height: 2.4rem; padding: 0; border: 1px solid var(--field-line, var(--rule)); border-radius: 8px; background: none; cursor: pointer; }

/* 글자 수 */
.tl-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 0.6rem; }
.tl-stat { padding: 0.7rem 0.85rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--card); }
.tl-stat span { display: block; color: var(--ink-soft); font-size: 0.75rem; }
.tl-stat strong { font-size: 1.375rem; font-variant-numeric: tabular-nums; }
.tl-stats .tl-hint { grid-column: 1 / -1; }

/* URL */
.tl-table { width: 100%; border-collapse: collapse; font-weight: 400; }
.tl-table th, .tl-table td { padding: 0.3rem 0.4rem; border-bottom: 1px solid var(--rule); text-align: left; }
.tl-table th { color: var(--ink-soft); font-size: 0.75rem; }
.tl-table .tl-input { width: 100%; }
.tl-table td:last-child { width: 4rem; }

.tl-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  z-index: 60;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.8125rem;
  opacity: 0;
  transform: translate(-50%, 0.5rem);
  transition: opacity 160ms, transform 160ms;
  pointer-events: none;
}
.tl-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 860px) {
  .tl-layout { grid-template-columns: 1fr; gap: 1rem; }
  /* 좁은 화면: 도구 목록은 가로로 넘기는 칩 */
  .tl-nav { position: static; }
  #tool-list { display: flex; gap: 0.35rem; overflow-x: auto; padding-bottom: 0.25rem; scrollbar-width: thin; }
  .tl-nav__group { display: contents; }
  .tl-nav__label { display: none; }
  .tl-nav__item { flex: none; padding: 0.35rem 0.75rem; border: 1px solid var(--rule); border-radius: 999px; white-space: nowrap; }
  .tl-nav__item[aria-current="page"] { border-color: var(--seal); box-shadow: none; }
  .tl-calc { grid-template-columns: 1fr; }
  .tl-dl div, .tl-dl--wide div { grid-template-columns: 1fr; gap: 0.1rem; }
  .tl-api__line { flex-wrap: wrap; }
  .tl-api__line .tl-code { flex-basis: 100%; order: -1; }
}
