/* Инструменты perfinn.ru/tools/ — поверх токенов основного style.css */

.tool { margin-top: 8px; }
.tool-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 2.2vw, 26px);
}
.tool-card + .tool-card { margin-top: 16px; }

/* Режимы: radio, оформленные как «пилюли» */
.tool-opts { display: flex; flex-wrap: wrap; gap: 10px 22px; margin-bottom: 16px; align-items: center; }
.tool-opt { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tool-opt__label { font-size: 13px; color: var(--muted-2); margin-right: 4px; }
.seg { position: relative; display: inline-flex; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: inline-block; padding: 7px 14px; font-size: 14px; line-height: 1.2;
  border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
  cursor: pointer; user-select: none; transition: border-color .15s, color .15s, background .15s;
}
.seg span:hover { color: var(--text); border-color: rgba(255,255,255,.22); }
.seg input:checked + span { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.tool-check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); cursor: pointer; }
.tool-check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Две панели: ввод и результат */
.tool-io { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.tool-io--stack { grid-template-columns: minmax(0, 1fr); }
.tool-pane { display: flex; flex-direction: column; min-width: 0; }
.tool-pane__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; min-height: 32px; flex-wrap: wrap; }
.tool-pane__title { font-size: 14px; font-weight: 600; color: var(--text); }
.tool-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tool-btn {
  font: inherit; font-size: 13px; line-height: 1; padding: 8px 11px; border-radius: 8px;
  background: transparent; color: var(--muted); border: 1px solid var(--line); cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.tool-btn:hover { color: var(--text); border-color: rgba(255,255,255,.24); }
.tool-btn.is-done { color: var(--accent); border-color: var(--accent-line); }
.tool-pane textarea, .tool-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13.5px; line-height: 1.55; tab-size: 4;
}
.tool-pane textarea { min-height: 340px; flex: 1; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.tool-pane textarea.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.tool-pane textarea[readonly] { background: rgba(255,255,255,.02); }
.tool-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.tool-row > .field { flex: 1 1 200px; }
.tool-row .btn { white-space: nowrap; }
.field label, .field > span { font-size: 13px; color: var(--muted); }
.tool-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.tool-status { min-height: 22px; margin-top: 10px; font-size: 14px; color: var(--muted); }
.tool-status.is-ok { color: #4ADE80; }
.tool-status.is-error { color: #FF7A7A; }
.tool-status.is-warn { color: #FBBF24; }

/* Результаты: таблицы «ключ — значение», карточки чисел */
.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv th, .kv td { text-align: left; vertical-align: top; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); }
.kv th { width: 32%; color: var(--muted); font-weight: 500; }
.kv td { color: var(--text); word-break: break-word; }
.kv td code, .kv td .tool-mono { font-size: 13px; }
.tool-out-table { width: 100%; overflow: auto; max-height: 560px; border: 1px solid var(--line); border-radius: var(--radius); }
.tool-out-table table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.tool-out-table th, .tool-out-table td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); text-align: left; white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.tool-out-table th { position: sticky; top: 0; background: var(--card-2); color: var(--muted); font-weight: 600; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.stat-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.stat-box__k { font-size: 12.5px; color: var(--muted-2); margin-bottom: 4px; }
.stat-box__v { font-size: 16px; color: var(--text); word-break: break-word; }
.stat-box__v.big { font-family: var(--font-display); font-size: clamp(22px, 2.6vw, 30px); }

.list-out { display: grid; gap: 6px; }
.list-out__row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 12px; border: 1px solid var(--line-soft); border-radius: 8px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; word-break: break-all; }

/* Подсветка совпадений регулярного выражения */
.rx-view { white-space: pre-wrap; word-break: break-word; min-height: 120px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.02); }
.rx-view mark { background: rgba(255,106,51,.28); color: var(--text); border-radius: 3px; box-shadow: 0 0 0 1px var(--accent-line); }
.rx-view mark:nth-of-type(even) { background: rgba(96,165,250,.28); box-shadow: 0 0 0 1px rgba(96,165,250,.5); }

/* Предпросмотр HTML/Markdown */
.md-body { padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); min-height: 340px; overflow: auto; background: rgba(255,255,255,.015); line-height: 1.6; }
.md-body h1, .md-body h2, .md-body h3 { font-family: var(--font-body); font-weight: 700; line-height: 1.25; margin: 1em 0 .5em; }
.md-body h1 { font-size: 26px; } .md-body h2 { font-size: 21px; } .md-body h3 { font-size: 18px; }
.md-body pre { background: rgba(0,0,0,.35); padding: 12px; border-radius: 8px; overflow: auto; }
.md-body code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; }
.md-body blockquote { border-left: 3px solid var(--accent-line); margin: 0; padding-left: 14px; color: var(--muted); }
.md-body table { border-collapse: collapse; } .md-body th, .md-body td { border: 1px solid var(--line); padding: 6px 10px; }
.md-body img { max-width: 100%; }
.md-body a { color: var(--accent); }

/* Визуальный редактор */
.wys-bar { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.wys-bar .tool-btn { min-width: 34px; }
.wys { min-height: 300px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); background: rgba(255,255,255,.02); outline: none; line-height: 1.6; overflow: auto; }
.wys:focus { border-color: var(--accent-line); }

/* Цвета */
.swatch { height: 150px; border-radius: var(--radius); border: 1px solid var(--line); position: relative; }
.swatch__hex { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.55); color: #fff; padding: 5px 9px; border-radius: 6px; font: 13px ui-monospace, Menlo, monospace; cursor: pointer; border: 0; }
.color-row { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 14px; align-items: center; }
.color-row__op { font-size: 26px; color: var(--muted-2); }
.color-pick { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.color-pick input[type="color"] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: transparent; cursor: pointer; }
.color-pick input[type="text"] { max-width: 130px; }
.cb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.cb-grid figure { margin: 0; }
.cb-grid canvas { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.cb-grid figcaption { font-size: 13.5px; color: var(--muted); margin-top: 6px; }

/* Символы и эмодзи */
.glyph-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; }
.glyph {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 64px; padding: 6px 4px; border: 1px solid var(--line-soft); border-radius: 8px; background: transparent;
  color: var(--text); cursor: pointer; font: inherit;
}
.glyph:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.glyph__c { font-size: 24px; line-height: 1; }
.glyph__n { font-size: 10.5px; color: var(--muted-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.glyph-group { margin: 22px 0 10px; font-size: 16px; font-weight: 600; font-family: var(--font-body); }
.glyph-pop { position: fixed; z-index: 960; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }

/* QR */
.qr-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 16px; }
.qr-type { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: 13px; }
.qr-type svg { width: 20px; height: 20px; }
.qr-type[aria-pressed="true"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--text); }
.qr-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.qr-preview { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center; position: sticky; top: 90px; }
.qr-preview canvas, .qr-preview img { max-width: 100%; height: auto; image-rendering: pixelated; background: #fff; border-radius: 6px; }
.qr-fields { display: grid; gap: 12px; }
details.tool-details { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
details.tool-details > summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details.tool-details[open] > summary { margin-bottom: 10px; }

/* Тест скорости */
.speed-dial { text-align: center; padding: 26px 10px; }
.speed-dial__v { font-family: var(--font-display); font-size: clamp(44px, 7vw, 76px); line-height: 1; }
.speed-dial__u { color: var(--muted); margin-top: 6px; }
.speed-bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin: 18px auto 0; max-width: 420px; }
.speed-bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* Каталог инструментов */
.tools-hub { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; }
.tools-hub__cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px 28px; }
.tools-hub h2 { font-family: var(--font-body); font-size: 13px; font-weight: 600; color: var(--muted-2); text-transform: none; letter-spacing: 0; margin: 0 0 10px; }
.tools-hub ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.tools-hub li a { color: var(--text); text-decoration: none; font-size: 15.5px; }
.tools-hub li a:hover { color: var(--accent); }
.tools-hub__side h2 { font-size: 20px; color: var(--text); }
.tools-hub__side p { font-size: 14px; }

.tool-related { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.tool-related a { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; font-size: 14.5px; }
.tool-related a:hover { border-color: var(--accent-line); }
.tool-related small { display: block; color: var(--muted-2); font-size: 12.5px; margin-top: 3px; }

.tool-text { max-width: 860px; }
.tool-text h2 { font-size: clamp(22px, 2.4vw, 30px); margin: 1.6em 0 .6em; }
.tool-text h3 { font-size: 19px; font-family: var(--font-body); font-weight: 700; margin: 1.3em 0 .5em; }
.tool-text p, .tool-text li { line-height: 1.65; color: rgba(255,255,255,.82); }
.tool-text code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; background: rgba(255,255,255,.06); padding: 1px 5px; border-radius: 4px; }
.tool-text pre { background: rgba(0,0,0,.35); border: 1px solid var(--line-soft); padding: 12px 14px; border-radius: 8px; overflow: auto; font-size: 13.5px; }
.tool-text .table-wrap { margin: 1em 0; }
.tool-faq details { border-bottom: 1px solid var(--line); padding: 14px 0; }
.tool-faq summary { cursor: pointer; font-weight: 600; font-size: 16px; }
.tool-faq details p { margin: 10px 0 0; }
.tool-privacy { font-size: 13px; color: var(--muted-2); margin-top: 12px; }

@media (max-width: 900px) {
  .tool-io { grid-template-columns: minmax(0, 1fr); }
  .tool-pane textarea { min-height: 220px; }
  .qr-layout { grid-template-columns: minmax(0, 1fr); }
  .qr-preview { position: static; }
  .tools-hub { grid-template-columns: minmax(0, 1fr); }
  .tools-hub__cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .color-row { grid-template-columns: minmax(0, 1fr); }
  .color-row__op { display: none; }
}
@media (max-width: 560px) {
  .tools-hub__cols { grid-template-columns: minmax(0, 1fr); }
  .kv th { width: 40%; }
}

/* В глобальном style.css нет правил для url и search — повторяем оформление полей сайта */
.tool input[type="url"],
.tool input[type="search"] {
  width: 100%; padding: 14px 16px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--text); font-family: var(--font-body); font-size: 16px;
  line-height: 1.3; transition: border-color var(--t), background var(--t); appearance: none;
}
.tool input[type="url"]:focus, .tool input[type="search"]:focus { outline: none; border-color: var(--accent); background: var(--card-2); }
.tool input[type="search"]::-webkit-search-cancel-button { filter: invert(1); opacity: .5; }
.tool input[type="color"] { cursor: pointer; }

/* Конвертер Word в HTML */
.wd-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 18px 16px; margin-bottom: 14px; text-align: center; border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; }
.wd-drop b { color: var(--text); font-weight: 600; }
.wd-drop span { font-size: 13.5px; }
.wd-drop:hover, .wd-drop:focus-visible, .wd-drop.is-over { border-color: var(--accent-line); background: var(--accent-soft); outline: none; }
.wd-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.wd-views { display: inline-flex; gap: 6px; }
.wd-views .tool-btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--text); }
.wd-count { font-size: 13px; color: var(--muted-2); }
.wd-bar__end { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.tool[data-tool="word-to-html"] > .tool-status { margin: -2px 0 10px; }
.wd-panes { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.tool[data-view="split"] .wd-panes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tool[data-view="visual"] .wd-pane--code, .tool[data-view="code"] .wd-pane--visual { display: none; }
.wd-pane { display: flex; flex-direction: column; min-width: 0; }
.wd-pane--code textarea { min-height: 520px; flex: 1; white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: hidden; }
/* Документ показываем «на бумаге»: цвета из Word рассчитаны на белый фон */
.wys.wd-paper { min-height: 520px; max-height: 78vh; background: #fff; color: #1f1f1f; border-color: transparent; font: 16px/1.55 Calibri, Carlito, "Segoe UI", Arial, sans-serif; padding: 22px 26px; }
.wys.wd-paper:focus { box-shadow: 0 0 0 2px var(--accent-line); }
.wd-paper h1, .wd-paper h2, .wd-paper h3, .wd-paper h4 { color: #111; font-family: inherit; line-height: 1.25; margin: .9em 0 .45em; font-weight: 700; }
.wd-paper h1 { font-size: 28px; } .wd-paper h2 { font-size: 22px; } .wd-paper h3 { font-size: 18px; } .wd-paper h4 { font-size: 16px; }
.wd-paper p { margin: 0 0 .7em; }
/* общий стиль сайта красит strong и em в светлый цвет темы — на «бумаге» наследуем цвет текста */
.wd-paper :where(strong, b, em, i, u, s, mark, small, code, kbd, li, td, th, p, span, blockquote, figcaption) { color: inherit; }
.wd-paper code { font-family: Consolas, Menlo, monospace; font-size: .92em; background: #f1f1f1; padding: 1px 4px; border-radius: 4px; }
.wd-paper pre code { background: none; padding: 0; }
.wd-paper ul, .wd-paper ol { margin: 0 0 .7em; padding-left: 1.6em; }
.wd-paper a { color: #0b57d0; text-decoration: underline; }
.wd-paper table { border-collapse: collapse; margin: 0 0 .9em; max-width: 100%; }
.wd-paper td, .wd-paper th { border: 1px solid #c8c8c8; padding: 5px 9px; vertical-align: top; }
.wd-paper img { max-width: 100%; height: auto; }
.wd-paper blockquote { margin: 0 0 .8em; padding-left: 14px; border-left: 3px solid #d0d0d0; color: #444; }
.wd-paper pre { background: #f3f3f3; padding: 10px 12px; border-radius: 6px; overflow: auto; font-size: 14px; }
.wd-clean { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); }
.wd-clean__head { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.wd-clean__list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 6px 18px; margin-bottom: 12px; }
.wd-clean__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wd-clean__row .tool-btn { padding: 5px 8px; font-size: 12px; flex: none; }
.wd-out { margin-top: 14px; }
.tool-btn--accent { color: var(--text); border-color: var(--accent-line); background: var(--accent-soft); }
@media (max-width: 860px) {
  .tool[data-view="split"] .wd-panes { grid-template-columns: minmax(0, 1fr); }
  .wys.wd-paper, .wd-pane--code textarea { min-height: 360px; }
  .wys.wd-paper { padding: 16px; }
}
