/* =====================================================================
   GuitarTunerOnline — оформление
   Светлая страница, тёмная карточка инструмента.
   Файл общий для всех страниц каталога и кэшируется браузером.
   ===================================================================== */

:root {
  --bg:        #f4f5f7;
  --surface:   #ffffff;
  --panel:     #12161c;
  --panel-2:   #1b2129;
  --panel-3:   #232b35;
  --line:      #e3e6ea;
  --line-dark: #2c3541;
  --text:      #1a1d21;
  --text-dim:  #5b636d;
  --on-dark:   #eef1f4;
  --on-dim:    #8b95a1;
  --ok:        #22a75b;
  --ok-soft:   rgba(34,167,91,.18);
  --warn:      #e0912b;
  --off:       #d9534f;
  --accent:    #22a75b;
  --radius:    12px;
  --radius-sm: 8px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 940px; margin: 0 auto; padding: 0 16px; }

/* ---------- шапка ---------- */

.site-head {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-head .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
}

.logo {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -.3px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.logo b { color: var(--accent); font-weight: 700; }

.site-nav { display: flex; align-items: center; gap: 4px; }

.site-nav a {
  display: inline-block;
  padding: 8px 12px;
  font-size: 15px;
  color: var(--text-dim);
  text-decoration: none;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--text); }
.site-nav a.is-active { color: var(--text); border-bottom-color: var(--accent); }

.lang-btn {
  padding: 5px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  text-decoration: none;
}
.lang-btn:hover { border-color: #c9cfd6; color: var(--text); }

/* ---------- статьи ---------- */

.article h2 { font-size: 19px; margin: 22px 0 10px; letter-spacing: -.2px; }
.article h2:first-child { margin-top: 0; }
.article h1 { font-size: 26px; margin-bottom: 14px; letter-spacing: -.4px; }
.article img { max-width: 100%; height: auto; border-radius: var(--radius-sm); margin: 6px 0 14px; }
.article audio { width: 100%; max-width: 420px; margin: 6px 0 14px; display: block; }
.article .source {
  margin-top: 20px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- рекламные позиции ---------- */

/* min-height резервирует место заранее: без него объявление
   подгружается и рывком сдвигает вниз весь контент. Высота задана
   под ограничение блока в кабинете РСЯ. */
.ad-top,
.ad-middle,
.ad-bottom {
  margin: 16px auto 4px;
  max-width: 728px;
  min-height: 100px;
}
.ad-middle { margin: 20px auto 6px; }
.ad-bottom { margin: 24px auto 10px; }

/* Пустая позиция не должна занимать место: если blockId не задан
   или объявление не пришло, контейнер схлопывается. */
.ad-top:empty,
.ad-middle:empty,
.ad-bottom:empty { min-height: 0; margin: 0; }

/* ---------- хлебные крошки ---------- */

.crumbs {
  padding: 14px 0 0;
  font-size: 13px;
  color: var(--text-dim);
}
.crumbs a { color: var(--text-dim); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
.crumbs span { margin: 0 5px; }
.crumbs span:last-child { color: var(--text); margin-left: 0; }

/* ---------- заголовок страницы ---------- */

.page-head { text-align: center; padding: 32px 0 20px; }
.page-head h1 { font-size: 30px; line-height: 1.25; font-weight: 700; letter-spacing: -.5px; }
.page-head p { margin-top: 8px; color: var(--text-dim); font-size: 16px; }

/* ---------- карточка тюнера ---------- */

.tuner {
  background: var(--panel);
  border-radius: 16px;
  color: var(--on-dark);
  overflow: hidden;
}

/* Панель настроек: в простом режиме показывается одной строкой,
   в полном раскрывается в три селектора. */
.tuner-settings {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, auto);
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-dark);
  background: var(--panel-2);
}

.tuner[data-mode="simple"] .tuner-settings { grid-template-columns: minmax(0, 1fr) minmax(0, auto); }
.tuner[data-mode="simple"] .field-a4 { display: none; }

.field { position: relative; }
.field label {
  display: block;
  font-size: 11px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--on-dim);
  margin-bottom: 4px;
}
.field select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  text-overflow: ellipsis;
  appearance: none;
  -webkit-appearance: none;
  padding: 9px 30px 9px 11px;
  font-size: 14px;
  font-family: inherit;
  color: var(--on-dark);
  background: var(--panel-3);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field .chevron {
  position: absolute;
  right: 10px; bottom: 10px;
  color: var(--on-dim);
  pointer-events: none;
}

.mode-toggle {
  align-self: end;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 13px;
  font-size: 13px;
  font-family: inherit;
  color: var(--on-dim);
  background: transparent;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}
.mode-toggle:hover { color: var(--on-dark); border-color: #3a4553; }

/* ---------- основная область ---------- */

/* minmax(0, ...) обязателен: без него колонка не даёт себя сжать
   меньше содержимого и вся сетка выпирает за пределы экрана. */
.tuner-body {
  display: grid;
  grid-template-columns: minmax(0, 200px) minmax(0, 1fr) minmax(0, 190px);
  gap: 0;
}
.tuner-body > * { min-width: 0; }
.tuner[data-mode="simple"] .tuner-body { grid-template-columns: minmax(0, 1fr); }
.tuner[data-mode="simple"] .string-panel,
.tuner[data-mode="simple"] .meta-panel { display: none; }

/* список струн */

.string-panel {
  border-right: 1px solid var(--line-dark);
  padding: 14px 12px;
}
.panel-title {
  font-size: 11px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--on-dim);
  margin-bottom: 10px;
}

.str-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 5px;
  font-family: inherit;
  text-align: left;
  color: var(--on-dark);
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.str-row:hover { background: var(--panel-3); }
.str-row.is-active { border-color: #3d76c9; background: var(--panel-3); }
.str-row.is-active.is-ok { border-color: var(--ok); background: var(--ok-soft); }

.str-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #3a4553;
  flex: none;
}
.str-row.is-done .str-dot { background: var(--ok); }
.str-row.is-active .str-dot { background: #3d76c9; }
.str-row.is-active.is-ok .str-dot { background: var(--ok); }

.str-main { flex: 1 1 auto; min-width: 0; }
.str-note { display: block; font-size: 17px; font-weight: 600; line-height: 1.2; }
.str-freq {
  display: block;
  font-size: 12px;
  color: var(--on-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.str-play { color: var(--on-dim); flex: none; }
.str-row:hover .str-play { color: var(--on-dark); }

/* показания */

.readout { padding: 22px 20px 18px; text-align: center; }

.mode-tabs {
  display: inline-flex;
  padding: 3px;
  margin-bottom: 18px;
  background: var(--panel-2);
  border-radius: 10px;
}
.mode-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 14px;
  font-family: inherit;
  color: var(--on-dim);
  background: transparent;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
}
.mode-tabs button[aria-selected="true"] { color: #fff; background: var(--accent); }

.note-name {
  font-size: 76px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -2px;
  min-height: 78px;
}
.tuner.is-tuned .note-name { color: var(--ok); }

.note-freq { font-size: 17px; color: var(--on-dim); margin-top: 6px; }

.note-cents { font-size: 17px; font-weight: 600; min-height: 26px; margin-top: 2px; }
.note-cents.is-ok { color: var(--ok); }
.note-cents.is-near { color: var(--warn); }
.note-cents.is-off { color: var(--off); }

.verdict {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 26px;
  margin-top: 6px;
  font-size: 15px;
  font-weight: 600;
}
.verdict.is-ok { color: var(--ok); }
.verdict.is-near { color: var(--warn); }
.verdict.is-off { color: var(--off); }

/* шкала */

.scale { position: relative; margin: 18px auto 0; max-width: 520px; }
.scale-track {
  position: relative;
  height: 44px;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.scale-zone {
  position: absolute;
  left: 45%; width: 10%;
  top: 0; bottom: 0;
  background: var(--ok-soft);
}
.scale-center { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: #45a06e; }
.scale-ticks { position: absolute; inset: 0; display: flex; justify-content: space-between; padding: 0 2px; }
.scale-ticks i { width: 1px; background: #333d49; }
.scale-ticks i:nth-child(5n+1) { background: #4a5763; }

.needle {
  position: absolute;
  top: 4px; bottom: 4px;
  left: 50%;
  width: 3px;
  margin-left: -1.5px;
  background: #fff;
  border-radius: 2px;
}
.tuner.is-tuned .needle { background: var(--ok); }

.scale-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 12px;
  color: var(--on-dim);
}

/* кнопка микрофона */

.mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  max-width: 320px;
  margin: 20px auto 0;
  padding: 14px 22px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.mic-btn:hover { background: #1c9350; }
.tuner.is-listening .mic-btn { background: #c0403c; }
.tuner.is-listening .mic-btn:hover { background: #a93430; }

.mic-status {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--on-dim);
  min-height: 20px;
}

/* панель метрик */

.meta-panel { border-left: 1px solid var(--line-dark); padding: 14px 14px; }
.meta-card {
  padding: 11px 12px;
  margin-bottom: 10px;
  background: var(--panel-2);
  border-radius: var(--radius-sm);
}
.meta-card h3 {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--on-dim);
  margin-bottom: 5px;
}
.meta-val { font-size: 24px; font-weight: 700; line-height: 1.1; }
.meta-val small { font-size: 13px; font-weight: 500; color: var(--on-dim); }

.signal-track { height: 5px; margin-top: 8px; background: var(--panel-3); border-radius: 3px; overflow: hidden; }
.signal-bar { height: 100%; width: 0; background: #3d76c9; border-radius: 3px; transition: width .12s linear; }

/* эталонный тон */

.reference {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line-dark);
}
.reference .panel-title { text-align: center; }

.ref-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}
.ref-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 72px;
  padding: 10px 12px;
  font-family: inherit;
  color: var(--on-dark);
  background: var(--panel-2);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.ref-btn:hover { background: var(--panel-3); border-color: #3a4553; }
.ref-btn:active { background: var(--accent); border-color: var(--accent); }
.ref-note { font-size: 16px; font-weight: 600; }
.ref-btn svg { color: var(--on-dim); }

/* ---------- контент под тюнером ---------- */

.content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  margin: 24px 0;
}
.content h2 { font-size: 22px; margin-bottom: 14px; letter-spacing: -.3px; }
.content h3 { font-size: 17px; margin: 20px 0 8px; }
.content p { margin-bottom: 12px; }
.content a { color: #1668c4; }
.content ul { margin: 0 0 12px 20px; }
.content li { margin-bottom: 6px; }

.tuning-table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 14px 0; }
.tuning-table th, .tuning-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.tuning-table th { background: #f7f8f9; font-weight: 600; }

.site-foot {
  padding: 22px 0 30px;
  text-align: center;
  font-size: 13px;
  color: var(--text-dim);
}

/* ---------- адаптив ---------- */

/* Планшет и узкий десктоп: три колонки не помещаются, раскладываем в одну.
   Порядок меняем — на узком экране сначала должны идти показания тюнера,
   и только под ними список струн. Иначе главное уезжает под сгиб. */
@media (max-width: 900px) {
  /* Колонку в колонке лучше не вкладывать: вложенная сетка норовит
     схлопнуться по содержимому вместо того, чтобы занять всю ширину.
     Столбец на flex ведёт себя предсказуемо — дети растягиваются сами. */
  .tuner-body {
    display: flex;
    flex-direction: column;
  }

  .readout      { order: 1; width: 100%; }
  .string-panel { order: 2; width: 100%; border-right: 0; border-top: 1px solid var(--line-dark); }
  .meta-panel   { order: 3; width: 100%; border-left: 0; border-top: 1px solid var(--line-dark); }

  .string-panel .str-list,
  .meta-panel {
    display: grid;
    gap: 8px;
  }
  .string-panel .str-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .meta-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .meta-panel .panel-title { grid-column: 1 / -1; }
  .meta-panel .meta-card { margin-bottom: 0; }
  .str-row { margin-bottom: 0; }
}

@media (max-width: 620px) {
  .page-head { padding: 22px 0 16px; }
  .page-head h1 { font-size: 22px; }

  .tuner-settings,
  .tuner[data-mode="simple"] .tuner-settings { grid-template-columns: minmax(0, 1fr); }
  .mode-toggle { width: 100%; justify-content: center; }

  .note-name { font-size: 56px; min-height: 58px; }
  .readout { padding: 18px 14px 16px; }
  .reference { padding: 14px 14px 16px; }
  .content { padding: 18px 16px; }

  .string-panel { padding: 12px 10px; }
  .string-panel .str-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .str-row { padding: 8px; gap: 7px; }
  .str-note { font-size: 15px; }
  .str-freq { font-size: 11px; }

  .ref-grid { gap: 6px; }
  .ref-btn { min-width: 0; flex: 1 1 60px; padding: 9px 6px; }

  .site-head .wrap { flex-wrap: wrap; min-height: 0; padding-top: 10px; padding-bottom: 10px; }
  .site-nav a { padding: 8px 10px; }
  .tuning-table { font-size: 14px; }
  .tuning-table th, .tuning-table td { padding: 6px 7px; }
}

/* Совсем узкие экраны: две колонки струн и без переносов в шкале */
@media (max-width: 380px) {
  .string-panel .str-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .note-name { font-size: 48px; min-height: 50px; }
  .wrap { padding: 0 12px; }
}

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