* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.4 -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: #222; background: #f4f4f2; }
a { color: #0b5e70; }
h1 { font-size: 20px; margin: 0 0 10px; }
h2 { font-size: 17px; margin: 0 0 8px; }
h3 { font-size: 14px; margin: 0 0 6px; }
input, select, textarea, button { font: inherit; }
input, select, textarea { border: 1px solid #bbb; border-radius: 4px; padding: 4px 6px; background: #fff; }
button, .btn { border: 1px solid #aaa; background: #fff; border-radius: 4px; padding: 4px 10px; cursor: pointer; display: inline-block; }
button:hover, .btn:hover { background: #eef5f6; }
button.primary { background: #0b5e70; color: #fff; border-color: #0b5e70; }
button.danger { color: #a00; border-color: #c88; }
button.link { border: 0; background: none; color: #fff; text-decoration: underline; }
button.seg { border-radius: 0; margin-right: -1px; }
button.seg.on { background: #0b5e70; color: #fff; }
.muted { color: #777; }
.small { font-size: 12px; }
.bad { color: #b00; }
.big { font-size: 18px; font-weight: 600; }
.grow { flex: 1; }
.gap { width: 14px; }
.row { display: flex; gap: 8px; align-items: center; margin: 8px 0; flex-wrap: wrap; }

.bar { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: #244; color: #fff; flex-wrap: wrap; }
.bar a { color: #fff; text-decoration: none; }
.bar .muted { color: #bcc; }
.logo { font-weight: 700; font-size: 18px; letter-spacing: 1px; }
.piano-name { font-weight: 600; }
.bar nav { display: flex; gap: 2px; flex-wrap: wrap; }
.bar nav a { padding: 3px 9px; border-radius: 4px; }
.bar nav a.on, .bar nav a:hover { background: #3c6a6a; }
.save { font-size: 12px; color: #cde; }
.save.bad { color: #ffb4b4; }

main { padding: 14px 16px 40px; max-width: 1500px; 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 label, .login label { display: block; margin: 8px 0; }
.narrow label input, .narrow label select, .login input { width: 100%; }
.login { max-width: 360px; margin: 60px auto; }

.head { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.head h1 { margin: 0 20px 0 0; }
.head input { width: 280px; }
table { border-collapse: collapse; }
table.list { width: 100%; background: #fff; }
table.list th, table.list td { text-align: left; padding: 7px 10px; border-bottom: 1px solid #e4e4e4; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: #eef5f6; }

.menu { display: grid; grid-template-columns: 340px 1fr; gap: 14px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tiles a { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 16px; text-decoration: none; color: #222; display: flex; flex-direction: column; gap: 4px; }
.tiles a:hover { border-color: #0b5e70; }
.tiles b { font-size: 16px; color: #0b5e70; }
.tiles span { color: #666; }

.toolbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.tabs { display: flex; gap: 2px; border-bottom: 2px solid #0b5e70; margin: 8px 0 10px; flex-wrap: wrap; }
.tabs a { padding: 5px 12px; text-decoration: none; background: #e4e9e9; border-radius: 4px 4px 0 0; color: #244; }
.tabs a.on { background: #0b5e70; color: #fff; }
.split { display: grid; grid-template-columns: 1fr 330px; gap: 12px; align-items: start; }
.charts { display: flex; flex-wrap: wrap; gap: 10px; }
.chart-box { background: #fff; border: 1px solid #ddd; border-radius: 6px; padding: 4px; width: 100%; }
.chart-box.half { width: calc(50% - 5px); }
.side .box, .side table { width: 100%; }

svg.chart { width: 100%; height: auto; display: block; user-select: none; }
.kb-sharp { fill: #000; opacity: 0.045; }
.key-white { fill: #fff; stroke: #b9b9b9; stroke-width: 0.5; }
.key-black { fill: #2b2b2b; stroke: #1a1a1a; stroke-width: 0.4; }
.key-name { font-size: 8px; fill: #444; }
.kb-sel { fill: #0b5e70; opacity: 0.18; }
.grid line, line.grid { stroke: #ccc; stroke-width: 0.6; stroke-dasharray: 3 3; }
.axis { font-size: 10px; fill: #555; }
.chart-title { font-size: 13px; font-weight: 600; fill: #222; }
.zone { stroke: #b07a00; stroke-width: 1; stroke-dasharray: 6 3; }
.zone-label, .line-label { font-size: 10px; fill: #b07a00; }
.handle circle { cursor: grab; }
.handle-label { font-size: 11px; font-weight: 600; fill: #c34400; pointer-events: none; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: #444; padding: 2px 8px 4px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-right: 4px; vertical-align: -2px; }

table.avg { background: #fff; border: 1px solid #ddd; margin-bottom: 10px; font-size: 13px; }
table.avg th, table.avg td { padding: 3px 7px; border-bottom: 1px solid #eee; text-align: right; }
table.avg th:first-child { text-align: left; font-weight: 500; }
table.avg thead th { background: #eef2f2; }

.scroll { overflow: auto; max-height: 70vh; border: 1px solid #ddd; background: #fff; }
table.grid { font-size: 13px; background: #fff; }
table.grid th, table.grid td { border: 1px solid #e2e2e2; padding: 2px 5px; text-align: right; white-space: nowrap; }
table.grid thead th { background: #eef2f2; position: sticky; top: 0; z-index: 1; }
table.grid tbody th { text-align: left; font-weight: 500; background: #fafafa; }
table.grid tr.sharp th { background: #e3e3e3; }
table.grid tr.sel td, table.grid tr.sel th { background: #d6ecef; }
table.grid input { width: 64px; border: 1px solid transparent; text-align: right; padding: 2px 4px; }
table.grid input:focus { border-color: #0b5e70; outline: none; background: #fffde8; }
table.grid input.invalid { background: #ffe0e0; }
table.grid th.calc, table.grid td.calc { color: #0b5e70; background: #f3f8f8; }
th[title], a[title], svg.chart { cursor: help; }
svg.chart text { cursor: default; }
table.specs td.ok { color: #1a7a1a; }
table.specs td.dev { color: #b00; font-weight: 600; }

.editor table.pts input { width: 80px; }
dialog { border: 1px solid #aaa; border-radius: 6px; max-width: 720px; width: 90%; }
.dlg textarea { width: 100%; font-family: Menlo, monospace; font-size: 12px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: #244; color: #fff; padding: 10px 16px; border-radius: 6px; z-index: 10; }
.toast.bad { background: #a00; }
.cards { display: flex; gap: 12px; flex-wrap: wrap; }
.cards .card { border: 1px solid #ddd; border-radius: 6px; padding: 12px; min-width: 160px; }
.cards .want .big { color: #00005e; }
.print-head { display: none; }

@media (max-width: 1000px) {
  .split, .menu { grid-template-columns: 1fr; }
  .chart-box.half { width: 100%; }
}
@media print {
  #top, .noprint, .toolbar { display: none !important; }
  .print-head { display: block; }
  body { background: #fff; }
  main { padding: 0; }
  .scroll { max-height: none; overflow: visible; border: 0; }
  table.grid thead th { position: static; }
  table.grid input[type=checkbox] { width: auto; }
}
