/* =====================================================================
   Tiện ích — bộ thành phần dùng chung cho mọi công cụ (xem app/tools/README.md)
   Dùng màu, font, nút của style.css. Một hệ kích thước: ô nhập và nút cao 44px.
   ===================================================================== */
.page-tool { --tl-ctl: 44px; --tl-r: 12px; }

/* Đầu trang công cụ */
.tl-hero { display: flex; align-items: center; gap: 16px; margin-top: 28px; }
.tl-hero h1 { font-family: var(--font-display); font-size: 30px; font-weight: 700; line-height: 1.2; text-wrap: balance; }
.tl-group-name { font-size: 12.5px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase; color: var(--faint); }
.tl-lead { margin-top: 6px; font-size: 15px; color: var(--muted); text-wrap: pretty; }
.tl-body { display: grid; gap: 14px; margin-top: 28px; }

/* Khung chính */
.tl-card {
  display: grid;
  gap: 14px;
  padding: 20px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.tl-field { display: grid; gap: 8px; min-width: 0; }
.tl-gap { margin-top: 8px; }
.tl-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tl-label { font-size: 14px; font-weight: 600; }
.tl-count { font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.tl-hint { font-size: 13px; line-height: 1.55; color: var(--muted); text-wrap: pretty; }
.tl-status { min-height: 20px; font-size: 13.5px; color: var(--muted); }
.tl-status:empty { display: none; }

.tl-input, .tl-select, .tl-textarea {
  width: 100%;
  min-width: 0;
  height: var(--tl-ctl);
  padding: 0 14px;
  font: inherit;
  font-size: 16px; /* 16px để iPhone không tự phóng to khi bấm vào ô */
  color: var(--text);
  border-radius: var(--tl-r);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  transition: border-color .15s, box-shadow .15s;
}
.tl-textarea { height: auto; min-height: 160px; padding: 12px 14px; line-height: 1.6; resize: vertical; }
.tl-select {
  padding-right: 36px;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 18px center, right 13px center;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.tl-input::placeholder, .tl-textarea::placeholder { color: var(--faint); opacity: .8; }
.tl-input:focus, .tl-select:focus, .tl-textarea:focus { outline: none; border-color: var(--text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--text) 16%, transparent); }
.tl-input[aria-invalid="true"] { border-color: color-mix(in srgb, #ef4444 70%, var(--border-strong)); }

/* Hàng nút: nút cao bằng ô nhập */
.tl-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.tl-actions-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.page-tool .tl-actions .btn, .page-tool .tl-links .btn { height: var(--tl-ctl); }
.page-tool .btn.copied { color: var(--green); border-color: color-mix(in srgb, var(--green) 40%, transparent); }

/* Thông báo lỗi */
.tl-alert {
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.55;
  border-radius: var(--tl-r);
  color: #ef4444;
  background: color-mix(in srgb, #ef4444 9%, transparent);
  border: 1px solid color-mix(in srgb, #ef4444 35%, transparent);
}

/* Kết quả */
.tl-result { scroll-margin-top: 24px; }
.tl-head { display: flex; align-items: center; gap: 14px; }
.tl-avatar { width: 64px; height: 64px; flex: none; border-radius: 50%; object-fit: cover; background: var(--card-2); border: 1px solid var(--border); }
.tl-head-text { min-width: 0; }
span.tl-avatar, span.tl-thumb { display: block; }
.tl-head h2 { font-family: var(--font-display); font-size: 20px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.tl-head h2 a { display: inline-flex; align-items: center; gap: 6px; }
.tl-head h2 svg { width: 16px; height: 16px; flex: none; color: var(--faint); }
.tl-head h2 a:hover svg { color: var(--text); }
.tl-head p { margin-top: 2px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }

.tl-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; }
.tl-stat { display: grid; gap: 4px; padding: 14px; text-align: center; border-radius: var(--tl-r); background: var(--card-2); border: 1px solid var(--border); }
.tl-stat dt { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.tl-stat dt svg { width: 14px; height: 14px; }
.tl-stat dd { margin: 0; font-family: var(--font-display); font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.tl-links { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.tl-links .btn { min-width: 0; padding: 0 8px; }

.tl-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 0; }
.tl-meta dt, .tl-block h3 { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.tl-meta dt svg, .tl-block h3 svg { width: 14px; height: 14px; flex: none; }
.tl-meta dd { margin: 4px 0 0; font-size: 14.5px; overflow-wrap: anywhere; }

.tl-block { display: grid; gap: 8px; }
.tl-block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tl-pre { font-size: 14.5px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; color: color-mix(in srgb, var(--text) 85%, var(--bg)); }
.tl-box { padding: 12px 14px; font-size: 14.5px; line-height: 1.6; overflow-wrap: anywhere; border-radius: var(--tl-r); background: var(--bg); border: 1px solid var(--border); }
.tl-code { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.tl-clamped { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.tl-more { justify-self: start; min-height: 36px; padding: 0; font: inherit; font-size: 13.5px; font-weight: 500; color: var(--text); text-decoration: underline; text-underline-offset: 3px; background: none; border: 0; cursor: pointer; }

.tl-footlinks { display: flex; flex-wrap: wrap; gap: 8px 22px; padding-top: 14px; border-top: 1px solid var(--border); }
.tl-footlinks a { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; font-size: 14px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }
.tl-footlinks svg { width: 16px; height: 16px; }

/* Danh sách video */
.tl-result-head h2 { font-family: var(--font-display); font-size: 20px; font-weight: 700; }
.tl-result-head p { margin-top: 4px; font-size: 13.5px; color: var(--muted); }
.tl-videos { display: grid; gap: 10px; margin: 14px 0 0; padding: 0; list-style: none; }
.tl-video {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border-radius: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  transition: border-color .15s, background-color .15s;
}
.tl-video:hover { border-color: var(--border-strong); background: var(--card-2); }
.tl-video-link { position: absolute; inset: 0; border-radius: inherit; }
.tl-video-link:focus-visible { box-shadow: inset var(--ring); }
.tl-rank {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  border-radius: 8px;
  background: var(--card-2);
  border: 1px solid var(--border);
}
.tl-rank.is-top { color: var(--btn-primary-fg); background: var(--btn-primary-bg); border-color: transparent; }
.tl-thumb { flex: none; width: 160px; height: 90px; object-fit: cover; border-radius: 10px; background: var(--card-2); }
.tl-video-text { flex: 1; min-width: 0; display: grid; gap: 6px; }
.tl-video-text strong { font-size: 15px; font-weight: 600; line-height: 1.45; overflow-wrap: anywhere; }
.tl-video-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.tl-video-meta > * { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.tl-video-meta svg { width: 14px; height: 14px; flex: none; }
.tl-video-channel { position: relative; z-index: 1; text-decoration: underline; text-decoration-color: var(--border-strong); text-underline-offset: 3px; }
.tl-video-channel:hover { color: var(--text); text-decoration-color: currentColor; }

/* ----- Điện thoại ----- */
@media (max-width: 560px) {
  .tl-hero { align-items: flex-start; gap: 14px; }
  .tl-hero h1 { font-size: 26px; }
  .tl-icon-lg { width: 48px; height: 48px; }
  .tl-card { padding: 16px; }
  .tl-actions .btn { flex: 1; }
  .tl-stats { gap: 8px; }
  .tl-stat { padding: 12px 6px; }
  .tl-stat dd { font-size: 17px; }
  .tl-links .btn { flex-direction: column; gap: 2px; height: auto; min-height: 56px; padding: 6px 4px; font-size: 12.5px; }
  .tl-meta { grid-template-columns: 1fr 1fr; }
  .tl-video { align-items: flex-start; gap: 10px; padding: 10px; }
  .tl-rank { width: 26px; height: 26px; font-size: 12px; }
  .tl-thumb { width: 112px; height: 63px; }
  .tl-video-text strong { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .tl-video { transition: none; }
}
