:root {
  --page-bg: #faf7f0;
  --paper: #ffffff;
  --ink: #2a2620;
  --line-color: #55504a;
  --accent: #b5482a;
  --accent-soft: #f0d9cf;
  --muted: #8a8378;
  --cell-w: 34px;
  --bar-w: 14px;
  --row-h: 26px;
  --label-w: 30px;
  --system-gap: 34px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page-bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
  height: 100%;
}

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid #ddd6c9;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.toolbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.brand {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
  padding-right: 10px;
  border-right: 1px solid #ddd6c9;
  margin-right: 4px;
}
.title-input {
  font-size: 18px;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  border-radius: 4px;
  min-width: 220px;
  color: var(--ink);
}
.title-input:hover, .title-input:focus {
  border-color: #ccc;
  background: #fff;
  outline: none;
}
.tuning-picker { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.tuning-picker select { padding: 3px 6px; }

button {
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid #d8d0c0;
  background: #fbfaf6;
  color: var(--ink);
  border-radius: 5px;
  cursor: pointer;
}
button:hover { background: var(--accent-soft); border-color: var(--accent); }
button:active { transform: translateY(1px); }
.sep { width: 1px; align-self: stretch; background: #e0dace; margin: 0 4px; }

/* ---------- Tab sheet ---------- */
.tab-sheet {
  padding: 28px 24px 80px;
  max-width: 1100px;
  margin: 0 auto;
  outline: none;
}

.tab-line {
  display: flex;
  align-items: flex-start;
  margin-bottom: var(--system-gap);
}

.string-labels {
  display: grid;
  width: var(--label-w);
  flex: 0 0 auto;
  padding-top: 0;
}
.string-labels .label-cell {
  height: var(--row-h);
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-style: italic;
}

.tab-grid {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  align-items: stretch;
}

.string-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--line-color);
  z-index: 0;
}

.cell {
  position: relative;
  z-index: 1;
  height: var(--row-h);
  width: var(--cell-w);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.cell.has-value {
  background: var(--page-bg);
}
.cell.mute { color: var(--muted); }
.cell:hover { background: #f1ebe0; }
.cell.selected {
  background: var(--accent-soft);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 3px;
}

.barline {
  position: relative;
  z-index: 1;
  width: var(--bar-w);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.barline::before {
  content: "";
  width: 2px;
  background: var(--ink);
  align-self: stretch;
  margin: 0 auto;
}
.barline.selected::before { background: var(--accent); width: 3px; }

/* ---------- Footer ---------- */
.hint-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--paper);
  border-top: 1px solid #ddd6c9;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 14px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
kbd {
  background: #eee;
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 0 4px;
  font-size: 11px;
}

/* ---------- Print ---------- */
@media print {
  .toolbar, .hint-bar { display: none; }
  body { background: #fff; }
  .tab-sheet { padding: 0; max-width: none; }
  .cell.selected, .barline.selected::before { outline: none; background: none !important; }
}
