:root {
  --brand: #6b2e22;
  --brand-2: #8a4434;
  --brand-soft: #f3e4df;
  --ink: #1f1b18;
  --muted: #776e66;
  --line: #e3ddd6;
  --bg: #f5f3ef;
  --ok: #2f6b4f;
  --warn: #b07a00;
  --bad: #b3261e;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 "Source Sans 3", "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
h1 { font-size: 24px; margin: 0 0 10px; }
h2 { font-size: 20px; margin: 0 0 8px; }
h3 { font-size: 17px; margin: 0 0 6px; }
code { font-size: 0.88em; background: #efe9e3; padding: 0 4px; border-radius: 3px; }
input, select, textarea, button { font: inherit; }
input, select, textarea { border: 1px solid #bbb; border-radius: 4px; padding: 6px 8px; background: #fff; }
input.invalid { background: #ffe0e0 !important; border-color: var(--bad) !important; }
button, .btn { border: 1px solid #aaa; background: #fff; border-radius: 4px; padding: 6px 12px; cursor: pointer; display: inline-block; color: var(--ink); }
button:hover, .btn:hover { background: #ece8e4; }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
button.primary:hover { background: var(--brand-2); }
button.danger { color: var(--bad); border-color: #d8a7a3; }
button.tiny { font-size: 13px; padding: 2px 8px; }
button.seg { border-radius: 0; margin-right: -1px; font-size: 15px; padding: 5px 12px; }
.segs button.seg:first-child { border-radius: 4px 0 0 4px; }
.segs button.seg:last-child { border-radius: 0 4px 4px 0; }
button.seg.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.file input { display: none; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.bad { color: var(--bad); }
.big { font-size: 18px; font-weight: 600; }
.grow { flex: 1; }
.gap { width: 10px; }
.right { text-align: right; }
.row { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }

/* шапка */
.bar { display: flex; align-items: center; gap: 12px; padding: 4px 14px; background: var(--brand); color: #fff; flex-wrap: wrap; position: sticky; top: 0; z-index: 4; }
.bar a { color: #fff; text-decoration: none; }
.bar .muted { color: #e2c8c0; }
.logo { font-weight: 700; font-size: 18px; letter-spacing: .5px; padding: 6px 0; }
.piano-name { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.variants { display: inline-flex; gap: 2px; }
.variants .var { background: transparent; color: #f1dcd5; border: 1px solid rgba(255,255,255,.35); font-size: 13px; padding: 2px 9px; border-radius: 12px; }
.variants .var.on { background: #fff; color: var(--brand); border-color: #fff; font-weight: 600; }
.variants .var:hover:not(.on) { background: var(--brand-2); }
.bar nav { display: flex; gap: 2px; flex-wrap: wrap; }
.bar nav a { padding: 8px 12px; border-radius: 6px; font-weight: 600; color: #f1dcd5; }
.bar nav a:hover { background: var(--brand-2); color: #fff; }
.bar nav a.on { background: var(--bg); color: var(--brand); }
.tools { display: inline-flex; align-items: center; gap: 4px; }
.bar button.link { background: none; color: #fff; border: 1px solid rgba(255,255,255,.45); border-radius: 6px; padding: 2px 10px; font-size: 17px; }
.bar button.link:hover { background: var(--brand-2); }
.bar button.link:disabled { color: rgba(255,255,255,.4); border-color: rgba(255,255,255,.2); }
.save { font-size: 12px; color: #e2c8c0; min-width: 90px; }
.save.bad { color: #ffd0c8; }
.user { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; white-space: nowrap; }
.user a.name { font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.user a.name:hover { background: var(--brand-2); }
.bar button.out { border: 0; font-size: 13px; color: #f1dcd5; padding: 0 4px; }

.summary { display: flex; gap: 26px; flex-wrap: wrap; padding: 8px 18px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 46px; z-index: 3; }
.summary div { display: flex; flex-direction: column; line-height: 1.2; }
.summary b { font-size: 19px; font-weight: 600; }
.summary b small { font-size: 13px; font-weight: 400; color: var(--muted); }
.summary span { font-size: 12px; color: var(--muted); }

main { padding: 14px 16px 40px; max-width: 1600px; margin: 0 auto; }
.box { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 14px; margin-bottom: 12px; }
.box.warn { background: #fff8e5; border-color: #e6c66a; }
.narrow { max-width: 640px; }
.narrow.wide { max-width: 1100px; }
.narrow label, .login label, .pair form label { display: block; margin: 8px 0; }
.narrow label input, .login input, .pair form input, .pair form select, .pair form textarea { width: 100%; display: block; margin-top: 3px; }
.box .row label { display: inline-flex; flex-direction: column; margin: 0; font-size: 14px; color: var(--muted); }
.box .row label input { width: auto; margin-top: 2px; font-size: 16px; color: var(--ink); }
.login { max-width: 380px; margin: 60px auto; }
.head { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.head h1 { margin: 0 14px 0 0; }

table { border-collapse: collapse; }
table.list { width: 100%; background: #fff; }
table.list th, table.list td { text-align: left; padding: 9px 12px; border-bottom: 1px solid #e8e4e0; }
table.list tbody tr[data-id] { cursor: pointer; }
table.list tbody tr[data-id]:hover { background: #f3eeea; }
table.list.plain td input { width: 100%; }

.toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 4px 0 8px; }

/* таблица 88 нот */
.scroll { max-height: calc(100vh - 230px); overflow: auto; border: 1px solid #ddd; border-radius: 6px; background: #fff; }
table.grid { font-size: 15px; background: #fff; }
table.grid th, table.grid td { border: 1px solid #ebe7e3; padding: 2px 6px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.grid thead th { background: #eeeae6; position: sticky; top: 0; z-index: 1; font-size: 13px; font-weight: 600; padding: 6px; }
table.grid thead th.calc { background: #f1e3de; color: var(--brand); cursor: help; }
table.grid tbody th { text-align: left; font-weight: 500; background: #faf8f6; cursor: pointer; }
table.grid tbody th.key { color: var(--muted); font-size: 13px; }
table.grid tr.sharp th { background: #e4dfda; }
table.grid tr.wound th.note { color: var(--brand); font-weight: 700; }
table.grid tr.sel th, table.grid tr.sel td { background: #f3dcd4 !important; }
table.grid tr.err th.note { color: #fff; background: var(--bad); }
table.grid input { border: 1px solid transparent; text-align: right; padding: 2px 4px; font-size: 15px; font-weight: 600; background: transparent; border-radius: 2px; }
table.grid input:focus { border-color: var(--brand); outline: none; background: #fffde8; }
table.grid td.calc { color: #3a3330; background: #fbf8f6; }
table.grid td.calc.bad { color: #fff; background: #d0493f; font-weight: 600; }
table.grid td.calc.warn { background: #fdf0c8; }
table.grid td.calc.ok { color: var(--ok); }
table.grid td.chg { color: var(--brand); font-weight: 700; }
table.grid.compact td, table.grid.compact th { padding: 4px 8px; }
table.grid.compact tbody th { cursor: default; }

svg.strip { width: 100%; height: 42px; display: block; margin: 2px 0 8px; cursor: pointer; user-select: none; }
.key-white { fill: #fff; stroke: #b9b2ac; stroke-width: 0.5; }
.key-black { fill: #2b2b2b; stroke: #1a1a1a; stroke-width: 0.4; }
.key-white.key-filled { fill: #f6efec; }
.key-white.key-mark { fill: #d9a596; }
.key-black.key-mark { fill: var(--brand); }
.key-white.key-sel { fill: var(--brand); }
.key-black.key-sel { fill: #d9a596; }
.key-name { font-size: 9px; fill: #555; pointer-events: none; }

/* графики */
.charts { display: flex; flex-wrap: wrap; gap: 10px; }
.chart-box { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 4px; width: 100%; margin-bottom: 10px; }
.charts .chart-box { margin-bottom: 0; }
.chart-box.half { width: calc(50% - 5px); }
svg.chart { width: 100%; height: auto; display: block; user-select: none; }
.kb-sharp { fill: #000; opacity: 0.04; }
.kb-sel { fill: var(--brand); opacity: 0.25; }
.band { fill: #2f6b4f; opacity: 0.1; }
.band-label { font-size: 13px; font-weight: 600; fill: #2f6b4f; }
.grid line, line.grid { stroke: #d6d1cc; stroke-width: 0.6; stroke-dasharray: 3 3; }
.axis { font-size: 14px; font-weight: 600; fill: #333; }
.chart-title { font-size: 17px; font-weight: 600; fill: #222; }
.line-label { font-size: 13px; font-weight: 600; }
.hover-tip { font-size: 14px; font-weight: 700; fill: var(--brand); pointer-events: none; paint-order: stroke; stroke: #fff; stroke-width: 4px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; color: #333; padding: 2px 10px 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.keycard { display: flex; gap: 16px; align-items: baseline; flex-wrap: wrap; padding: 8px 14px; }

.split { display: grid; grid-template-columns: 1fr 340px; gap: 12px; align-items: start; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.side .box label.pick { display: flex; align-items: center; gap: 6px; margin: 4px 0; font-size: 15px; }
.side .box label.pick i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.side .segs { margin-bottom: 8px; }
.side .box label input:not([type=checkbox]) { width: 100%; }
.side .box .row label input { width: 70px; }
table.avg { width: 100%; font-size: 14px; }
table.avg th, table.avg td { padding: 4px 6px; border-bottom: 1px solid #eee; text-align: right; }
table.avg th:first-child { text-align: left; font-weight: 500; }
.about dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 18px; margin: 12px 0 0; }
.about dt { color: var(--muted); }
.about dd { margin: 0; }
.about summary { cursor: pointer; font-weight: 600; }
.sheet h2 { margin-top: 22px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--brand); color: #fff; padding: 10px 16px; border-radius: 6px; z-index: 10; max-width: 460px; }
.toast.bad { background: var(--bad); }

@media (max-width: 1100px) {
  .split, .pair { grid-template-columns: 1fr; }
  .chart-box.half { width: 100%; }
  .summary { position: static; }
  .bar nav a { padding: 8px 8px; }
}
@media (pointer: coarse) {
  table.grid input { font-size: 17px; padding: 6px 4px; }
  button, .btn { padding: 9px 14px; }
}
@media print {
  #top, .noprint, .toolbar { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .box { border: 0; }
  .scroll { max-height: none; overflow: visible; border: 0; }
  table.grid thead th { position: static; }
}
