/* =========================================================
   КОНВЕРТЕР ЦВЕТОВ (/tools/color-converter)
   Палитра и переменные — из style.css.

   Принципы (референс — Reg.ru):
   — одна белая карточка, внутри блоки разделяет воздух, а не рамки;
   — обводка только у полей ввода: серая, при фокусе зелёная;
   — кнопки: светло-серая заливка без обводки, иконки копирования —
     прозрачные; зелёный — только фокус и активное состояние;
   — вкладки — сегментный переключатель, чипсы — серые, активный
     чипс отмечен зелёным кольцом, а не заливкой.
   Раскладка переключается контейнерными запросами: с 1024px у сайта
   фиксированный сайдбар 332px, ширина окна ≠ ширине инструмента.
   ========================================================= */

[hidden] { display: none !important; }

.cc-tool {
  --cc-line: #E2E6EA;
  --cc-line-hover: #C8CED5;
  --cc-fill: #F2F4F6;
  --cc-fill-hover: #E7EAEE;
  --cc-soft: #F7F8FA;
  --cc-danger: #D14343;
  --cc-checker: repeating-conic-gradient(#DADEE3 0% 25%, #fff 0% 50%) 0 0 / 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  margin: 0 0 8px;
  padding: 28px;
  background: var(--color-surface);
  border: 1px solid rgba(25, 27, 30, 0.06);
  border-radius: 24px;
  box-shadow: 0 1px 2px rgba(16, 20, 24, 0.04);
  container: cctool / inline-size;
}

/* ---------- Базовые элементы ---------- */
.cc-input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 14px;
  background: var(--color-surface);
  border: 1px solid var(--cc-line);
  border-radius: 12px;
  font: inherit;
  font-size: 15px;
  color: var(--color-text-strong);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.cc-input:hover { border-color: var(--cc-line-hover); }
.cc-input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(29, 217, 122, 0.16); }
.cc-input.is-invalid { border-color: var(--cc-danger); box-shadow: 0 0 0 3px rgba(209, 67, 67, 0.12); }
.cc-input::placeholder { color: #A3AEB4; }
.cc-mono { font-family: var(--font-mono); font-size: 14px; }

.cc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-shrink: 0;
  height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 12px;
  background: var(--cc-fill);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  color: var(--color-text-strong);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}
.cc-btn i { display: inline-flex; font-size: 17px; }
.cc-btn:hover { background: var(--cc-fill-hover); }

.cc-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 16px;
  color: #8A979E;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}
.cc-icon-btn i { display: inline-flex; }
.cc-icon-btn:hover { background: var(--cc-fill); color: var(--color-text-strong); }
.cc-icon-btn.is-done { color: var(--color-accent-dark); background: #E3F7EC; }

.cc-hint { margin: 0; font-size: 13px; line-height: 1.55; color: var(--color-muted); }
.cc-hint--warn { color: #9A5B13; }

.cc-btn:focus-visible, .cc-icon-btn:focus-visible, .cc-seg-btn:focus-visible, .cc-chip:focus-visible, .cc-tile:focus-visible, .cc-code:focus-visible,
.cc-sv:focus-visible, .cc-track:focus-visible { outline: 2px solid var(--color-accent-dark); outline-offset: 3px; }

/* ---------- Строка ввода «любой формат» ---------- */
.cc-top { display: flex; gap: 8px; }
.cc-any { position: relative; flex: 1 1 auto; min-width: 0; }
.cc-any-input { height: 48px; padding-left: 52px; font-size: 15px; }
.cc-any-dot {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 28px;
  height: 28px;
  margin-top: -14px;
  border-radius: 8px;
  background: linear-gradient(var(--c), var(--c)), var(--cc-checker);
  box-shadow: inset 0 0 0 1px rgba(16, 20, 24, 0.1);
  pointer-events: none;
}

/* ---------- Раскладка ---------- */
.cc-layout { display: grid; grid-template-columns: minmax(0, 0.82fr) minmax(0, 1.18fr); gap: 36px; align-items: start; } /* правой колонке нужна ширина под oklch(… / 0.45) */

/* ---------- Подбор цвета ---------- */
.cc-picker { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.cc-sv {
  position: relative;
  aspect-ratio: 16 / 10;
  border-radius: 16px;
  background:
    linear-gradient(to top, #000, transparent),
    linear-gradient(to right, #fff, hsl(var(--hue, 204) 100% 50%));
  cursor: crosshair;
  touch-action: none;
}
.cc-sv-thumb, .cc-track-thumb {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--c, transparent);
  box-shadow: 0 0 0 1px rgba(16, 20, 24, 0.18), 0 2px 6px rgba(16, 20, 24, 0.28);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.cc-track { position: relative; height: 14px; border-radius: 999px; cursor: pointer; touch-action: none; }
.cc-track::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(16, 20, 24, 0.08); pointer-events: none; }
.cc-track-thumb { top: 50%; }
.cc-track--hue { background: linear-gradient(to right, #f00 0%, #ff0 16.67%, #0f0 33.33%, #0ff 50%, #00f 66.67%, #f0f 83.33%, #f00 100%); }
.cc-track--alpha { flex: 1 1 auto; background: linear-gradient(to right, transparent, var(--c)), var(--cc-checker); }
/* Невидимая зона захвата выше самой дорожки — удобно пальцем */
.cc-track::before { content: ""; position: absolute; inset: -12px 0; }
.cc-alpha-row { display: flex; align-items: center; gap: 14px; }
.cc-alpha-val { min-width: 40px; font-size: 13.5px; font-variant-numeric: tabular-nums; color: var(--color-muted); text-align: right; }

/* Ваш цвет и ближайший RAL */
.cc-match { display: flex; flex-direction: column; gap: 14px; padding: 16px; background: var(--cc-soft); border-radius: 18px; }
.cc-match-pair { display: grid; grid-template-columns: 1fr 1fr; height: 84px; border-radius: 12px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(16, 20, 24, 0.06); }
.cc-match-swatch { position: relative; display: flex; align-items: flex-end; padding: 8px; background: linear-gradient(var(--c), var(--c)), var(--cc-checker); }
#ccRalSwatch { background: var(--c); }
.cc-match-swatch > span { padding: 3px 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.92); font-size: 12px; font-weight: 600; line-height: 1.3; color: var(--color-text-strong); }
.cc-match-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cc-match-line { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cc-match-line strong { font-size: 16px; font-weight: 700; color: var(--color-text-strong); white-space: nowrap; }
.cc-match-line span { flex: 1 1 auto; min-width: 0; font-size: 15px; color: var(--color-text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-match-line .cc-icon-btn { margin: -6px -6px -6px 0; }
.cc-match-de { font-size: 13px; color: var(--color-muted); }
.cc-match-css { font-size: 13px; color: var(--color-muted); }
.cc-match-css code { display: inline; max-width: none; margin-block: 0; line-height: inherit; padding: 0; background: none; border-radius: 0; font-size: 12.5px; }

/* ---------- Форматы ---------- */
.cc-formats { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.cc-row { display: grid; grid-template-columns: 100px minmax(0, 1fr) 36px; align-items: center; gap: 10px; }
.cc-row label { font-size: 14px; font-weight: 600; color: var(--color-text-strong); }
.cc-formats .cc-hint { margin-top: 6px; }

/* ---------- Вкладки и чипсы ---------- */
.cc-extra { display: flex; flex-direction: column; gap: 18px; padding-top: 28px; border-top: 1px solid #EEF0F3; }
.cc-seg { display: inline-flex; align-self: flex-start; gap: 2px; padding: 3px; background: var(--cc-fill); border-radius: 12px; max-width: 100%; }
.cc-seg-btn {
  height: 36px;
  padding: 0 18px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  color: var(--color-muted);
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}
.cc-seg-btn:hover { color: var(--color-text-strong); }
.cc-seg-btn.is-active { background: var(--color-surface); font-weight: 600; color: var(--color-text-strong); box-shadow: 0 1px 2px rgba(16, 20, 24, 0.08), 0 0 0 0.5px rgba(16, 20, 24, 0.06); }
.cc-panel { display: flex; flex-direction: column; gap: 16px; }

.cc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cc-chip {
  height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--cc-fill);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  transition: background-color var(--transition-fast), box-shadow var(--transition-fast);
}
.cc-chip:hover { background: var(--cc-fill-hover); }
.cc-chip.is-active { background: var(--color-surface); color: var(--color-text-strong); box-shadow: inset 0 0 0 2px var(--color-accent); }

/* Плитки цветов */
.cc-tile { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 0; border: 0; background: none; cursor: pointer; }
.cc-tile-color { height: 56px; background: var(--c); transition: transform var(--transition-fast); }
.cc-tile:hover .cc-tile-color { transform: translateY(-3px); }
.cc-tile-code { font-family: var(--font-mono); font-size: 11.5px; color: var(--color-muted); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cc-tile:hover .cc-tile-code { color: var(--color-text-strong); }
.cc-strip { position: relative; display: grid; grid-template-columns: repeat(11, minmax(0, 1fr)); }
/* Кромка вокруг полосы — почти белые оттенки не теряются на белом */
.cc-strip::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 56px; border-radius: 12px; box-shadow: inset 0 0 0 1px rgba(16, 20, 24, 0.07); pointer-events: none; }
.cc-strip .cc-tile:first-child .cc-tile-color { border-radius: 12px 0 0 12px; }
.cc-strip .cc-tile:last-child .cc-tile-color { border-radius: 0 12px 12px 0; }
.cc-strip .cc-tile.is-base .cc-tile-color { position: relative; z-index: 1; border-radius: 6px; box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--color-text-strong); }
.cc-strip .cc-tile.is-base .cc-tile-code { font-weight: 700; color: var(--color-text-strong); }
.cc-harmony { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 12px; }
.cc-tile--big .cc-tile-color { height: 88px; border-radius: 14px; box-shadow: inset 0 0 0 1px rgba(16, 20, 24, 0.06); }

/* Контраст */
.cc-contrast { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cc-contrast-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; background: var(--cc-soft); border-radius: 18px; }
.cc-contrast-demo { display: flex; align-items: center; min-height: 76px; padding: 14px 18px; border-radius: 12px; font-family: var(--font-display); font-size: 19px; font-weight: 700; line-height: 1.25; color: var(--c); }
.cc-contrast-demo--white { background: #fff; box-shadow: inset 0 0 0 1px rgba(16, 20, 24, 0.06); }
.cc-contrast-demo--black { background: #000; }
.cc-contrast-ratio { font-size: 32px; font-weight: 500; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; color: var(--color-text-strong); } /* крупные цифры — не жирным, как у Reg.ru */
.cc-contrast-checks { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 13.5px; color: var(--color-text-strong); }
.cc-contrast-checks li { display: flex; align-items: center; gap: 8px; }
.cc-contrast-checks i { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; }
.cc-contrast-checks .is-ok i { background: #E3F7EC; color: var(--color-accent-dark); }
.cc-contrast-checks .is-bad i { background: #FBE9E9; color: var(--cc-danger); }
.cc-contrast-checks span { margin-left: auto; color: var(--color-muted); }

/* Код */
.cc-code-box { position: relative; background: var(--cc-soft); border-radius: 16px; }
.cc-code { margin: 0; padding: 18px 56px 18px 20px; font-family: var(--font-mono); font-size: 13px; line-height: 1.75; color: var(--color-text-strong); white-space: pre-wrap; overflow-wrap: anywhere; border-radius: 16px; }
.cc-code-copy { position: absolute; top: 10px; right: 10px; }

/* ---------- Уведомление ---------- */
.cc-msg {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: max-content;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 14px;
  background: #191B1E;
  box-shadow: 0 10px 30px -10px rgba(16, 20, 24, 0.45);
  font-size: 14px;
  line-height: 1.5;
  color: #fff;
  transform: translateX(-50%);
  animation: cc-toast 180ms ease-out;
}
.cc-msg i { display: inline-flex; margin-top: 2px; font-size: 16px; color: var(--color-accent); flex-shrink: 0; }
.cc-msg--error i { color: #FF8F8F; }
@keyframes cc-toast { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (min-width: 1024px) { .cc-msg { left: calc(50% + var(--sidebar-width, 332px) / 2); } }

/* ---------- Адаптив по ширине инструмента ---------- */
@container cctool (max-width: 760px) {
  .cc-layout { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  /* На узком экране сначала поля: большинство приходит перевести RGB в HEX */
  .cc-formats { order: -1; }
}
@container cctool (max-width: 560px) {
  .cc-top { flex-wrap: wrap; }
  .cc-any { flex-basis: 100%; }
  .cc-top .cc-btn { flex: 1 1 0; }
  .cc-row { grid-template-columns: minmax(0, 1fr) 36px; gap: 6px 8px; }
  .cc-row label { grid-column: 1 / -1; font-size: 13px; }
  .cc-row .cc-mono { font-size: 13px; padding: 0 12px; }
  .cc-formats { gap: 12px; }
  .cc-seg { align-self: stretch; }
  .cc-seg-btn { flex: 1 1 0; padding: 0 6px; font-size: 13.5px; }
  .cc-strip { grid-template-columns: repeat(11, minmax(0, 1fr)); }
  .cc-strip .cc-tile-code { display: none; }
  .cc-contrast { grid-template-columns: minmax(0, 1fr); }
  .cc-harmony { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
}
@media (max-width: 480px) { .cc-tool { padding: 18px 16px 20px; border-radius: 20px; } }
@supports not (container-type: inline-size) {
  @media (max-width: 1180px) { .cc-layout { grid-template-columns: minmax(0, 1fr); } }
}

/* =========================================================
   SEO-БЛОКИ — белые панели со строками
   ========================================================= */
.cc-seo { container-type: inline-size; container-name: ccseo; }
.cc-seo-panel { padding: 8px 32px; background: var(--color-surface); border: 1px solid rgba(43, 47, 51, 0.07); border-radius: var(--radius-lg); }
.cc-srow { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 28px; align-items: start; padding: 24px 0; border-top: 1px solid rgba(43, 47, 51, 0.08); }
.cc-srow:first-child { border-top: none; }
.cc-srow-mark { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; line-height: 1.5; letter-spacing: -0.01em; color: var(--color-accent-dark); }
.cc-srow h3 { font-size: 17px; line-height: 1.35; margin: 0 0 8px; color: var(--color-text-strong); }
.cc-srow p { font-size: 14.5px; line-height: 1.75; color: var(--color-muted); margin: 0 0 10px; }
.cc-srow p:last-child { margin-bottom: 0; }
.cc-srow strong { color: var(--color-text-strong); font-weight: 600; }

@container ccseo (max-width: 700px) {
  .cc-seo-panel { padding: 4px 20px; }
  .cc-srow { grid-template-columns: 1fr; gap: 6px; padding: 20px 0; }
}
@supports not (container-type: inline-size) {
  @media (max-width: 952px) { .cc-srow { grid-template-columns: 1fr; gap: 6px; padding: 20px 0; } }
}
