:root {
  --bg: #14151a;
  --panel: #1e2029;
  --text: #e8e9ee;
  --muted: #9498a5;
  --accent: #6c8cff;
  --active: #6c8cff;
  --white-key: #f4f5f8;
  --white-active: #b9c6ff;
  --black-key: #23252d;
  --black-active: #4864d8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.wrap {
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

h1 { font-size: 22px; margin: 0; font-weight: 650; }
h1 .em { font-size: 26px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--panel);
  border: 1px solid #2c2f3a;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4a4d59; }
.dot.on { background: #4ade80; }

.card {
  background: var(--panel);
  border: 1px solid #2c2f3a;
  border-radius: 14px;
  padding: 22px;
  margin-bottom: 18px;
}

button, .btn {
  font: inherit;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 600;
}
button:hover, .btn:hover { filter: brightness(1.08); }
button.ghost {
  background: transparent;
  border: 1px solid #363a47;
  color: var(--text);
}
button:disabled { opacity: .5; cursor: default; }
button.icon {
  background: var(--panel);
  border: 1px solid #2c2f3a;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 15px;
  line-height: 1;
}
button.icon.muted { opacity: .55; }

.linkrow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
input.link {
  flex: 1;
  min-width: 220px;
  background: #14161d;
  border: 1px solid #2c2f3a;
  color: var(--text);
  border-radius: 10px;
  padding: 11px 13px;
  font: inherit;
}

/* ---- piano ---- */
.piano-scroll {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  margin: 22px 0 8px;
  scrollbar-width: thin;
}
.piano {
  position: relative;
  width: 100%;
  /* keep near-real key proportions (~1:4.7) as the keyboard grows with the screen */
  height: clamp(190px, 9.5vw, 280px);
  user-select: none;
  /* pan-x: horizontal swipe scrolls the keyboard, taps still play keys */
  touch-action: pan-x;
}

/* Mobile: fixed key size, keyboard wider than screen, swipe to scroll */
@media (max-width: 760px) {
  .wrap { padding: 14px 10px 24px; }
  .card { padding: 16px 14px; border-radius: 12px; }
  /* full-bleed: escape card padding so keys reach screen edges */
  .piano-scroll { margin-left: -14px; margin-right: -14px; }
  .piano { width: 1560px; /* 52 white keys × 30px */ height: 160px; }
  h1 { font-size: 18px; }
}
.key {
  position: absolute;
  top: 0;
  border-radius: 0 0 5px 5px;
  transition: background .04s linear;
}
.key.white {
  height: 100%;
  background: var(--white-key);
  border: 1px solid #c9ccd6;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.key.white.active { background: var(--white-active); }
.key.black {
  height: 62%;
  background: var(--black-key);
  border: 1px solid #000;
  z-index: 2;
}
.key.black.active { background: var(--black-active); }
.key .label {
  font-size: 10px;
  color: #8b8f9c;
  padding-bottom: 5px;
  pointer-events: none;
}

.pedal {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid #2c2f3a;
  font-size: 13px;
  color: var(--muted);
  transition: all .08s linear;
}
.pedal .bar {
  width: 22px;
  height: 6px;
  border-radius: 3px;
  background: #3a3e4b;
  transition: all .08s linear;
}
.pedal.on {
  color: var(--text);
  border-color: var(--accent);
  background: rgba(108, 140, 255, .12);
}
.pedal.on .bar { background: var(--accent); }

.hint {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
}
kbd {
  background: #2a2d38;
  border: 1px solid #3a3e4b;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 12px;
  font-family: ui-monospace, monospace;
}

.center { text-align: center; }
a { color: var(--accent); }
