/* =====================================================================
   GuitarTunerOnline — метроном и камертон
   Дополняет tuner.css: те же переменные, та же тёмная карточка.
   Простой режим на телефоне должен уместиться в первый экран вместе
   с верхним баннером 100px и Floor Ad снизу (16vh): карточка ≤ 340px.
   ===================================================================== */

/* страницы инструментов: заголовок компактнее */
.tool-page .page-head { padding: 18px 0 12px; }
.tool-page .page-head h1 { font-size: 26px; }
.tool-page .page-head p { font-size: 15px; }

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

/* общая строка настроек (как .tuner-settings) */
.tool-settings {
  display: flex; flex-wrap: wrap; align-items: end; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-dark); background: var(--panel-2);
}
.tool-settings .field { flex: 1 1 120px; }
.tool-settings .mode-toggle { flex: 0 0 auto; }
.tool[data-mode="simple"] .only-full { display: none !important; }
.tool[data-mode="full"] .only-simple { display: none !important; }

/* ---------- метроном ---------- */

.metro-main { padding: 18px 20px 16px; text-align: center; position: relative; }

.metro-tempo { display: flex; align-items: center; justify-content: center; gap: 6px; }
.tempo-btn {
  width: 44px; height: 44px; border-radius: 50%;
  font-weight: 600; font-size: 14px; line-height: 1; font-family: inherit; color: var(--on-dark);
  background: var(--panel-2); border: 1px solid var(--line-dark); cursor: pointer;
}
.tempo-btn:hover { background: var(--panel-3); }
.tempo-val { min-width: 150px; }
.tempo-val input {
  width: 150px; text-align: center; font-weight: 700; font-size: 64px; line-height: 1; font-family: inherit; letter-spacing: -2px;
  color: var(--on-dark); background: transparent; border: 0; outline: 0; -moz-appearance: textfield;
}
.tempo-val input::-webkit-inner-spin-button, .tempo-val input::-webkit-outer-spin-button { -webkit-appearance: none; }
.tempo-meta { font-size: 13px; color: var(--on-dim); margin-top: -4px; }
.tempo-meta b { color: var(--on-dark); font-weight: 600; margin-right: 8px; }

.metro-range { width: 100%; max-width: 520px; margin: 14px auto 6px; display: block; accent-color: var(--accent); height: 28px; }

/* доли такта: кликабельные точки */
.beats { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 6px; max-width: 520px; margin: 10px auto 0; }
.beat {
  height: 34px; border-radius: 8px; border: 1px solid var(--line-dark); background: var(--panel-2);
  color: var(--on-dim); font-weight: 600; font-size: 13px; line-height: 1; font-family: inherit; cursor: pointer; position: relative; transition: background .05s, transform .05s;
}
.beat-1 { border-color: #3d76c9; color: var(--on-dark); }
.beat-2 { opacity: .55; }
.beat-3 { opacity: .3; background: transparent; }
.beat-3 span { text-decoration: line-through; }
.beat.is-on { background: var(--accent); border-color: var(--accent); color: #fff; transform: scale(1.06); }
.beat-1.is-on { background: #3d76c9; border-color: #3d76c9; }
.is-silent-bar .beat.is-on { background: transparent; color: var(--accent); }

/* маятник и вспышка — в простом режиме тонкая полоса, в полном выше */
.metro-visual { position: relative; height: 56px; max-width: 520px; margin: 8px auto 0; }
.pendulum-box { position: absolute; left: 50%; top: 0; width: 2px; height: 56px; margin-left: -1px; transform-origin: 50% 0; will-change: transform; }
.pendulum-box i { position: absolute; left: -7px; bottom: 0; width: 16px; height: 16px; border-radius: 50%; background: var(--on-dim); }
.pendulum-box::before { content: ''; position: absolute; left: 0; top: 0; width: 2px; height: 100%; background: var(--line-dark); }
.flash { position: absolute; inset: 0; border-radius: 10px; background: var(--ok-soft); opacity: 0; transition: opacity .08s; pointer-events: none; }
.flash.is-lit { opacity: 1; transition: none; }

.metro-controls { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.metro-start {
  display: inline-flex; align-items: center; gap: 10px; min-width: 180px; justify-content: center;
  padding: 14px 24px; font-weight: 600; font-size: 17px; line-height: 1; font-family: inherit; color: #fff;
  background: var(--accent); border: 0; border-radius: 12px; cursor: pointer;
}
.metro-start:hover { background: #1c9350; }
.is-running .metro-start { background: var(--off); }
.is-running .metro-start:hover { background: #c4443f; }
.tap-btn, .ghost-btn {
  padding: 13px 18px; font-weight: 600; font-size: 15px; line-height: 1; font-family: inherit; color: var(--on-dark);
  background: var(--panel-2); border: 1px solid var(--line-dark); border-radius: 12px; cursor: pointer;
}
.tap-btn:hover, .ghost-btn:hover { background: var(--panel-3); }
.tap-btn.is-hit { background: var(--accent); border-color: var(--accent); }

.metro-status { margin-top: 10px; font-size: 13px; color: var(--on-dim); display: flex; justify-content: center; gap: 14px; }
.metro-status b { color: var(--on-dark); font-weight: 600; font-variant-numeric: tabular-nums; }
.metro-active { margin-top: 6px; font-size: 12px; color: var(--warn); }
.metro-hint { margin-top: 8px; font-size: 12px; color: var(--on-dim); }

/* ---- панель тренировки (полный режим) ---- */
.metro-train { border-top: 1px solid var(--line-dark); padding: 14px 16px 16px; }
.metro-train .panel-title { margin-bottom: 12px; }
.train-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.train-card { background: var(--panel-2); border: 1px solid var(--line-dark); border-radius: 10px; padding: 12px; }
.train-card h4 { font-size: 14px; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.train-card p { font-size: 12px; color: var(--on-dim); margin-bottom: 8px; line-height: 1.4; }
.train-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.train-row select, .train-row input[type=number] {
  padding: 6px 8px; font-size: 14px; font-family: inherit; color: var(--on-dark);
  background: var(--panel-3); border: 1px solid var(--line-dark); border-radius: 6px; min-width: 0;
}
.train-row input[type=number] { width: 64px; }
.train-row input[type=range] { flex: 1 1 100px; accent-color: var(--accent); }
.train-row label { color: var(--on-dim); }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: var(--panel-3); border: 1px solid var(--line-dark); border-radius: 22px; cursor: pointer; transition: background .15s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--on-dim); transition: transform .15s, background .15s; }
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); background: #fff; }

/* тап-тест */
.tap-area {
  margin-top: 12px; padding: 26px 16px; border-radius: 12px; text-align: center; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  background: var(--panel-2); border: 2px dashed var(--line-dark); transition: background .05s;
}
.tap-area.is-hit { background: var(--panel-3); border-color: var(--accent); }
.tap-area b { display: block; font-size: 18px; margin-bottom: 4px; }
.tap-area small { color: var(--on-dim); }
.tap-progress { font-size: 13px; color: var(--on-dim); margin-top: 6px; }
.tap-last { font-size: 22px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tap-last.is-ok { color: var(--ok); } .tap-last.is-near { color: var(--warn); } .tap-last.is-off { color: var(--off); }
.tap-result { margin-top: 12px; padding: 14px; background: var(--panel-2); border-radius: 12px; }
.tap-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; text-align: center; }
.tap-stats b { display: block; font-size: 24px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.tap-stats small { font-size: 13px; margin-left: 2px; color: var(--on-dim); }
.tap-stats span { display: block; font-size: 11px; color: var(--on-dim); line-height: 1.3; }
.tap-verdict { margin: 12px 0 10px; font-size: 14px; text-align: center; }
.tap-graph { display: flex; align-items: flex-end; gap: 2px; height: 70px; padding: 0 2px; border-bottom: 1px solid var(--line-dark); }
.tap-graph i { flex: 1 1 0; min-width: 2px; border-radius: 2px 2px 0 0; background: var(--warn); opacity: .85; }
.tap-graph i.early { background: #3d76c9; }
.tap-graph i.late { background: var(--warn); }
.tap-legend { display: flex; justify-content: space-between; font-size: 11px; color: var(--on-dim); margin-top: 4px; }
.tap-legend span:first-child { color: #3d76c9; } .tap-legend span:last-child { color: var(--warn); }
.tap-again { margin-top: 10px; width: 100%; padding: 10px; font-weight: 600; font-size: 14px; line-height: 1; font-family: inherit; color: var(--on-dark); background: var(--panel-3); border: 1px solid var(--line-dark); border-radius: 8px; cursor: pointer; }

/* пресеты */
.metro-presets { border-top: 1px solid var(--line-dark); padding: 12px 16px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 7px 11px; font-weight: 500; font-size: 13px; line-height: 1.2; font-family: inherit; color: var(--on-dark);
  background: var(--panel-2); border: 1px solid var(--line-dark); border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.chip:hover { background: var(--panel-3); border-color: #3a4553; }
.chip small { color: var(--on-dim); margin-left: 4px; }

.tool-offer { padding: 0 16px; }
.tool-offer .tuned-offer { margin: 0 0 16px; }

/* ---------- камертон ---------- */

.kam-main { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; align-items: center; padding: 18px 20px 16px; }
.kam-fork { width: 150px; height: 190px; cursor: pointer; display: block; margin: 0 auto; -webkit-tap-highlight-color: transparent; background: transparent; border: 0; padding: 0; }
.kam-fork:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.kam-fork svg { width: 100%; height: 100%; overflow: visible; }
.kam-fork .tine { transform-origin: 50% 100%; }
.is-ringing .kam-fork .tine-l { animation: tineL .09s ease-in-out infinite alternate; }
.is-ringing .kam-fork .tine-r { animation: tineR .09s ease-in-out infinite alternate; }
.is-ringing .kam-fork .ring { animation: ring 1.1s ease-out infinite; }
@keyframes tineL { from { transform: translateX(-1.6px) rotate(-.6deg); } to { transform: translateX(1.6px) rotate(.6deg); } }
@keyframes tineR { from { transform: translateX(1.6px) rotate(.6deg); } to { transform: translateX(-1.6px) rotate(-.6deg); } }
@keyframes ring { 0% { opacity: .55; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.5); } }
.kam-fork .ring { transform-origin: 50% 30%; opacity: 0; }
.kam-readout { text-align: center; }
.kam-note { font-size: 64px; font-weight: 700; letter-spacing: -2px; line-height: 1; }
.kam-note-ru { color: var(--on-dim); font-size: 14px; margin-top: 2px; }
.kam-hz { font-size: 26px; font-weight: 600; margin-top: 8px; font-variant-numeric: tabular-nums; }
.kam-controls { display: flex; justify-content: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.kam-controls .metro-start { min-width: 150px; }
.ghost-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.kam-hint { font-size: 12px; color: var(--on-dim); margin-top: 8px; }

.kam-freq { display: flex; align-items: center; gap: 6px; }
.kam-freq input {
  width: 100px; padding: 9px 10px; 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);
}

.kam-section { border-top: 1px solid var(--line-dark); padding: 14px 16px 16px; }
.kam-section .panel-title { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.kam-section .panel-note { text-transform: none; letter-spacing: 0; font-size: 12px; }
.kam-octave { margin-bottom: 10px; }
.kam-oct-label { display: block; font-size: 11px; color: var(--on-dim); margin-bottom: 4px; }
.kam-keyrow { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 3px; }
.kam-key {
  display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 2px 6px; min-width: 0;
  font-family: inherit; color: var(--on-dark); background: var(--panel-2); border: 1px solid var(--line-dark); border-radius: 6px; cursor: pointer;
}
.kam-key.is-black { background: #0c0f13; }
.kam-key b { font-size: 13px; font-weight: 600; }
.kam-key small { font-size: 9px; color: var(--on-dim); }
.kam-key:hover { background: var(--panel-3); }
.kam-key.is-active, .ref-btn.is-active { border-color: var(--accent); background: var(--ok-soft); }
.kam-strings-head { display: flex; gap: 10px; align-items: end; margin-bottom: 10px; flex-wrap: wrap; }
.kam-strings-head .field { flex: 1 1 180px; }
.kam-strings { display: flex; flex-wrap: wrap; gap: 8px; }
.kam-strings .ref-btn small { font-size: 11px; color: var(--on-dim); }

/* ---------- таблицы и текст под инструментами ---------- */
.tempo-table td:first-child, .tempo-table th:first-child { white-space: nowrap; }
.content .bpm-links { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.content .bpm-links a {
  padding: 6px 11px; font-size: 14px; text-decoration: none; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px;
}
.content .bpm-links a:hover { border-color: #b8bfc8; }
.content .bpm-links a.is-current { background: var(--text); color: #fff; border-color: var(--text); }
.dl-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.dl-row a {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; font-size: 14px; font-weight: 600;
  text-decoration: none; color: #fff; background: var(--text); border-radius: 8px;
}
.dl-row a:hover { background: #000; }
.dl-row small { font-weight: 400; opacity: .7; }
.faq h3 { font-size: 16px; margin: 16px 0 6px; }

/* ---------- адаптив ---------- */
@media (max-width: 620px) {
  .tool-page .site-nav a { padding: 6px 7px; font-size: 14px; }
  .tool-page .crumbs { padding-top: 8px; }
  .tool-page .page-head { padding: 10px 0 8px; }
  .tool[data-mode="simple"] .tool-settings { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .tool[data-mode="simple"] .tool-settings .mode-toggle { width: auto; padding: 9px 11px; }
  .tool[data-mode="simple"] .tool-settings .mode-toggle .mode-label { display: none; }
  .tool[data-mode="simple"] .tool-settings .mode-toggle::after { content: 'Ещё'; }
  .tool-page .page-head h1 { font-size: 20px; }
  .tool-page .page-head p { display: none; }
  .tool-page .crumbs { font-size: 12px; }
  .tool-settings { padding: 10px 12px; gap: 8px; }
  .tool[data-mode="full"] .tool-settings .mode-toggle { width: 100%; justify-content: center; }
  .metro-main { padding: 12px 12px 12px; }
  .tempo-val input { font-size: 54px; width: 130px; }
  .tempo-val { min-width: 130px; }
  .tempo-btn { width: 40px; height: 40px; }
  .metro-range { margin: 8px auto 4px; }
  .beat { height: 30px; }
  .metro-visual { height: 36px; }
  .pendulum-box { height: 36px; }
  .pendulum-box i { width: 12px; height: 12px; left: -5px; }
  .metro-controls { margin-top: 8px; gap: 8px; }
  .metro-start { min-width: 0; flex: 1 1 auto; padding: 13px 16px; font-size: 16px; }
  .tap-btn { padding: 12px 14px; }
  .metro-status { margin-top: 8px; }
  .metro-hint { display: none; }
  .tap-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tap-stats b { font-size: 22px; }
  .kam-main { grid-template-columns: 92px minmax(0, 1fr); padding: 12px 12px 12px; gap: 10px; }
  .kam-fork { width: 92px; height: 118px; }
  .kam-note { font-size: 46px; }
  .kam-note-ru { font-size: 12px; }
  .kam-hz { font-size: 20px; margin-top: 4px; }
  .kam-controls { margin-top: 10px; gap: 6px; }
  .kam-controls .metro-start { min-width: 0; flex: 1 1 auto; padding: 12px 14px; font-size: 15px; }
  .kam-controls .ghost-btn { padding: 12px 12px; font-size: 14px; }
  .kam-hint { display: none; }
  .kam-keyrow { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .kam-key b { font-size: 14px; }
}
@media (max-width: 380px) {
  .tempo-val input { font-size: 48px; width: 115px; }
  .tempo-btn { width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  .is-ringing .kam-fork .tine-l, .is-ringing .kam-fork .tine-r, .is-ringing .kam-fork .ring { animation: none; }
  .beat { transition: none; }
}

/* ---------- статьи ---------- */
.article-page .page-head { text-align: left; padding: 18px 0 6px; }
.article-page .page-head h1 { font-size: 28px; line-height: 1.2; }
.article-page .page-head p:empty { display: none; }
.article p.lead { font-size: 17px; line-height: 1.65; }
.article h2 { font-size: 22px; margin: 26px 0 10px; letter-spacing: -.3px; scroll-margin-top: 16px; }
.article h3 { font-size: 17px; margin: 18px 0 8px; }
.article table { width: 100%; border-collapse: collapse; font-size: 15px; margin: 12px 0 16px; }
.article th, .article td { border: 1px solid var(--line); padding: 7px 9px; text-align: left; vertical-align: top; }
.article th { background: #f7f8f9; font-weight: 600; }
.article code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; background: #eef0f3; padding: 1px 5px; border-radius: 4px; }
.article ol, .article ul { margin: 0 0 12px 22px; }
.article li { margin-bottom: 6px; }
.article a { color: #1668c4; }
.article a.tool-link {
  display: inline-flex; align-items: center; gap: 6px; margin: 4px 8px 12px 0; padding: 10px 16px;
  font-weight: 600; font-size: 15px; color: #fff; background: var(--accent); border-radius: 10px; text-decoration: none;
}
.article a.tool-link:hover { background: #1c9350; }
.toc { margin: 4px 0 20px; padding: 12px 16px; background: #f7f8f9; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 14px; }
.toc b { display: block; margin-bottom: 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-dim); }
.toc ol { margin: 0 0 0 18px; columns: 2; column-gap: 20px; }
.toc li { margin-bottom: 3px; break-inside: avoid; }
.toc a { color: var(--text); text-decoration: none; }
.toc a:hover { color: #1668c4; }
.faq h2 { margin-top: 0; }
.faq p { margin-bottom: 12px; }
.related ul { margin-left: 20px; }
.article-item h2 { margin-top: 18px; }
@media (max-width: 620px) {
  .article-page .page-head h1 { font-size: 22px; }
  .article-page .page-head { padding: 12px 0 4px; }
  .toc ol { columns: 1; }
  .article table { font-size: 13px; display: block; overflow-x: auto; }
}

/* ---------- тренажёр ритма: уровни ---------- */
.levels { display: grid; gap: 10px; margin: 8px 0 16px; }
.level { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.level-no { width: 44px; height: 44px; border-radius: 50%; background: var(--text); color: #fff; font-weight: 700; font-size: 18px; display: flex; align-items: center; justify-content: center; }
.level h3 { font-size: 16px; margin: 0 0 4px; }
.level p { margin: 0 0 6px; font-size: 14px; color: var(--text-dim); }
.level .goal { font-size: 13px; color: var(--text); }
.level .goal b { color: var(--ok); }
.level button { align-self: center; padding: 10px 14px; font-weight: 600; font-size: 14px; line-height: 1; font-family: inherit; color: #fff; background: var(--accent); border: 0; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.level button:hover { background: #1c9350; }
.level.is-active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--ok-soft); }
@media (max-width: 620px) {
  .level { grid-template-columns: 36px minmax(0, 1fr); }
  .level-no { width: 36px; height: 36px; font-size: 15px; }
  .level button { grid-column: 1 / -1; width: 100%; }
}
