/* =============================================================================
   tools.css: free tools placed at the top of guide pages (app/tools/).

   Built on the marketing tokens in marketing.css (--ta-*). Marketing pages
   have a 10px root font-size, so px only. One bordered panel per tool; rows
   inside it are separated by dividers, not nested boxes. Loaded only on
   pages that carry a tool.
   ========================================================================== */

.tt-tool { margin: 0 0 40px; }
.tt-tool--wide {
  width: min(1140px, calc(100vw - 40px));
  margin-left: calc(50% - min(570px, calc(50vw - 20px)));
}

.tt-panel {
  background: #fff;
  border: 1px solid var(--ta-border);
  border-radius: var(--ta-radius);
}
.tt-panel__head { padding: 20px 20px 0; }
.tt-panel__head h2 { font-size: 20px; line-height: 1.3; margin: 0 0 4px; }
.tt-panel__head p { margin: 0; font-size: 14px; color: var(--ta-text-2); }
.tt-panel__head--bare { padding: 0 0 16px; max-width: 760px; }
.tt-body { padding: 20px; }
.tt-body + .tt-body, .tt-results { border-top: 1px solid var(--ta-border-soft); }
.tt-results { padding: 20px; }
.tt-results[hidden], .tt-body[hidden] { display: none; }
.tt-foot { padding: 14px 20px; border-top: 1px solid var(--ta-border-soft); }

.tt-note { font-size: 13px; line-height: 1.5; color: var(--ta-text-3); margin: 0; }
.tt-note + .tt-note { margin-top: 6px; }
.tt-note a, .tt-help a { color: var(--ta-sky); }
.tt-help { font-size: 14px; color: var(--ta-text-2); margin: 0 0 12px; }
.tt-error { margin: 12px 0 0; font-size: 14px; color: #b42318; }
.tt-error:empty { display: none; }
.tt-status { margin: 12px 0 0; font-size: 14px; color: var(--ta-text-2); }
.tt-status:empty { display: none; }

/* Segmented control for modes */
.tt-tabs {
  display: flex;
  border: 1px solid var(--ta-border);
  border-radius: var(--ta-radius);
  overflow: hidden;
  margin: 0 0 16px;
}
.tt-tabs button {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  font: 600 14px/1.2 var(--ta-font);
  color: var(--ta-text-2);
  background: #fff;
  border: 0;
  border-left: 1px solid var(--ta-border);
  cursor: pointer;
}
.tt-tabs button:first-child { border-left: 0; }
.tt-tabs button[aria-pressed="true"], .tt-tabs button[aria-selected="true"] { background: var(--ta-navy); color: #fff; }
.tt-tabs button:focus-visible { outline: 2px solid var(--ta-sky); outline-offset: -2px; }

/* Fields */
.tt-row { display: flex; gap: 10px; align-items: stretch; }
.tt-row .ta-input { flex: 1 1 auto; min-width: 0; }
.tt-row .ta-btn { flex: none; }
.tt-field { margin: 0 0 14px; }
.tt-field:last-child { margin-bottom: 0; }
.tt-field > label, .tt-legend { display: block; font-size: 14px; font-weight: 600; color: var(--ta-navy); margin: 0 0 6px; }
.tt-field .tt-note { margin-top: 6px; }
.tt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.tt-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tt-grid .tt-field { margin: 0; }
.tt-textarea {
  display: block;
  width: 100%;
  min-height: 160px;
  padding: 12px;
  font: 400 16px/1.5 var(--ta-font);
  color: var(--ta-navy);
  background: #fff;
  border: 1px solid var(--ta-border);
  border-radius: var(--ta-radius);
  resize: vertical;
}
.tt-textarea--short { min-height: 96px; }
.tt-textarea--mono, .tt-mono { font-family: var(--ta-mono); font-size: 14px; }
.tt-textarea:focus { outline: none; border-color: var(--ta-sky); box-shadow: 0 0 0 3px rgba(0, 153, 236, 0.2); }
/* style.css styles input[type=text] (0,1,1) with a currentColor border and
   24px side padding; restate the .ta-input look at higher specificity. */
.tt-panel input.ta-input, .tt-panel select.ta-input {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--ta-border);
  border-radius: var(--ta-radius);
  background-color: #fff;
}
.tt-panel input.ta-input:focus, .tt-panel select.ta-input:focus { border-color: var(--ta-sky); box-shadow: 0 0 0 3px rgba(0, 153, 236, 0.2); }
.tt-panel select.ta-input { padding-right: 32px; }
select.ta-input { padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--ta-text-3) 50%), linear-gradient(135deg, var(--ta-text-3) 50%, transparent 50%); background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px; background-size: 5px 5px; background-repeat: no-repeat; }
.tt-check { display: flex; gap: 8px; align-items: flex-start; font-size: 15px; color: var(--ta-navy); margin: 0 0 8px; }
.tt-check input { margin-top: 4px; width: 16px; height: 16px; flex: none; }
.tt-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }
.tt-actions .tt-help { margin: 0; }
.tt-results > .tt-actions:first-child { margin-top: 0; margin-bottom: 14px; }

/* File picker */
.tt-drop {
  display: block;
  padding: 20px;
  text-align: center;
  border: 1px dashed var(--ta-border);
  border-radius: var(--ta-radius);
  color: var(--ta-text-2);
  font-size: 15px;
  cursor: pointer;
}
.tt-drop strong { color: var(--ta-navy); }
.tt-drop .tt-note { display: block; margin-top: 6px; }
.tt-drop.is-over { border-color: var(--ta-sky); background: var(--ta-tint); }
.tt-drop input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.tt-drop:focus-within { outline: 2px solid var(--ta-sky); outline-offset: 2px; }
.tt-file { display: block; margin: 8px 0 0; font-size: 14px; color: var(--ta-text-2); word-break: break-all; }
.tt-file:empty { display: none; }

/* Plain stats separated by dividers (no boxes) */
.tt-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 0; margin: 0 0 16px; }
.tt-stat { padding: 2px 16px; border-left: 1px solid var(--ta-border-soft); }
.tt-stat:first-child { padding-left: 0; border-left: 0; }
.tt-stat__label { display: block; font-size: 13px; color: var(--ta-text-3); }
.tt-stat__value { display: block; font-size: 24px; font-weight: 700; line-height: 1.25; color: var(--ta-navy); font-variant-numeric: tabular-nums; word-break: break-word; }
.tt-stat__value--lg { font-size: 36px; }
.tt-stat__sub { display: block; font-size: 13px; color: var(--ta-text-2); }

/* Meter */
.tt-meter { height: 6px; background: var(--ta-border-soft); border-radius: 3px; overflow: hidden; margin: 10px 0 6px; }
.tt-meter span { display: block; height: 100%; width: 0; background: var(--ta-sky); }
.tt-meter.is-over span { background: #b42318; }
.tt-over { color: #b42318; font-weight: 600; }

/* Result lists and tables */
.tt-table-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--ta-border); border-radius: var(--ta-radius); }
.tt-table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 0; }
.tt-table th, .tt-table td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--ta-border-soft); }
.tt-table thead th { position: sticky; top: 0; background: var(--ta-section); font-weight: 600; color: var(--ta-navy); z-index: 1; }
.tt-table tbody tr:last-child td { border-bottom: 0; }
.tt-table td.tt-num, .tt-table th.tt-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tt-table a { color: var(--ta-sky); }
.tt-table .tt-mono { word-break: break-all; }
.tt-table .tt-nowrap, .tt-stat__value.tt-nowrap { white-space: nowrap; word-break: normal; }
.tt-links a { display: inline-block; margin-right: 12px; white-space: nowrap; }
.tt-links a:last-child { margin-right: 0; }
.tt-list { list-style: none; margin: 0; padding: 0; }
.tt-list > li { padding: 10px 0; border-bottom: 1px solid var(--ta-border-soft); }
.tt-list > li:first-child { padding-top: 0; }
.tt-list > li:last-child { border-bottom: 0; padding-bottom: 0; }

/* Check results */
.tt-checks { list-style: none; margin: 0; padding: 0; }
.tt-checks li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--ta-border-soft); font-size: 15px; color: var(--ta-navy); }
.tt-checks li:last-child { border-bottom: 0; }
.tt-checks svg { width: 18px; height: 18px; flex: none; margin-top: 3px; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tt-checks .is-ok svg { stroke: #067647; }
.tt-checks .is-warn svg { stroke: #b54708; }
.tt-checks .is-error svg { stroke: #b42318; }
.tt-checks .is-info svg { stroke: var(--ta-text-3); }
.tt-checks code { font-size: 13px; }
.tt-level { font-weight: 600; }
.is-ok .tt-level { color: #067647; }
.is-warn .tt-level { color: #b54708; }
.is-error .tt-level { color: #b42318; }

.tt-h3 { font-size: 16px; font-weight: 600; margin: 20px 0 10px; color: var(--ta-navy); }
.tt-h3:first-child { margin-top: 0; }
.tt-kv { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 15px; }
.tt-kv dt { color: var(--ta-text-3); font-weight: 400; }
.tt-kv dd { margin: 0; color: var(--ta-navy); word-break: break-word; }

/* Thread posts */
.tt-posts { list-style: none; margin: 0; padding: 0; }
.tt-posts li { padding: 14px 0; border-bottom: 1px solid var(--ta-border-soft); }
.tt-posts li:first-child { padding-top: 0; }
.tt-posts li:last-child { border-bottom: 0; }
.tt-posts p { margin: 0 0 8px; white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.tt-posts .tt-post-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; color: var(--ta-text-3); }

/* Link card preview (approximate X card) */
.tt-xcard { max-width: 516px; border: 1px solid #cfd9de; border-radius: 16px; overflow: hidden; background: #fff; color: #0f1419; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
.tt-xcard__img { position: relative; background: #f7f9f9; }
.tt-xcard--large .tt-xcard__img { aspect-ratio: 2 / 1; }
.tt-xcard__img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tt-xcard__overlay { position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 24px); padding: 2px 6px; border-radius: 4px; background: rgba(0, 0, 0, 0.77); color: #fff; font-size: 13px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-xcard__noimg { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 120px; color: #536471; font-size: 13px; }
.tt-xcard__domain { padding: 4px 2px 0; font-size: 13px; color: #536471; }
.tt-xcard--summary { display: flex; align-items: stretch; }
.tt-xcard--summary .tt-xcard__img { width: 130px; flex: none; border-right: 1px solid #cfd9de; }
.tt-xcard--summary .tt-xcard__img img { aspect-ratio: 1 / 1; }
.tt-xcard__text { padding: 12px; min-width: 0; font-size: 15px; line-height: 1.35; }
.tt-xcard__text span { display: block; overflow: hidden; text-overflow: ellipsis; }
.tt-xcard__text .tt-xcard__muted { color: #536471; }
.tt-xcard__title { font-weight: 400; }

/* Draw result */
.tt-winners { list-style: none; margin: 0 0 12px; padding: 0; counter-reset: winner; }
.tt-winners li { counter-increment: winner; display: flex; gap: 12px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--ta-border-soft); font-size: 18px; font-weight: 600; }
.tt-winners li::before { content: counter(winner) "."; min-width: 28px; font-size: 15px; font-weight: 600; color: var(--ta-text-3); }
.tt-winners li:last-child { border-bottom: 0; }
.tt-winners a { color: var(--ta-navy); }
.tt-winners--backup li { font-size: 16px; font-weight: 400; }

.tt-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 767.98px) {
  .tt-tool { margin-bottom: 32px; }
  .tt-tool--wide { width: auto; margin-left: 0; }
  .tt-panel__head { padding: 16px 16px 0; }
  .tt-body, .tt-results { padding: 16px; }
  .tt-foot { padding: 12px 16px; }
  .tt-grid, .tt-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .tt-row { flex-wrap: wrap; }
  .tt-row .ta-btn { flex: 1 1 100%; }
  .tt-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 12px; }
  .tt-stat { padding: 2px 12px; }
  .tt-stat:nth-child(odd) { padding-left: 0; border-left: 0; }
  .tt-stat__value { font-size: 22px; }
  .tt-stat__value--lg { font-size: 30px; }
  .tt-kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .tt-kv dd { margin-bottom: 8px; }
  .tt-xcard--summary .tt-xcard__img { width: 100px; }
  .tt-panel__head--bare { padding: 0 0 14px; }
  .tt-table { font-size: 13px; }
  .tt-table th, .tt-table td { padding: 8px 8px; }
  .tt-links a { display: block; margin: 0 0 4px; }
  .tt-stat__value.tt-nowrap { font-size: 19px; }
}

.tt-mt { margin-top: 14px; }
.tt-mt-s { margin-top: 8px; }
