:root {
  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #fafbfd;
  --border: #e5e8ee;
  --border-strong: #cdd2db;
  --text: #1a1d24;
  --text-muted: #5b6270;
  --text-dim: #8a909c;
  --primary: #5b6cff;
  --primary-hov: #4a5beb;
  --accent: #ff5a6e;
  --accent-hov: #ee4a5f;
  --success: #2bb673;
  --shadow-sm: 0 1px 2px rgba(20, 25, 40, 0.04);
  --shadow-md: 0 4px 16px rgba(20, 25, 40, 0.06);
  --shadow-lg: 0 10px 32px rgba(20, 25, 40, 0.08);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", "Noto Sans KR", -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #2c2f4a 0%, #5b6cff 60%, #8b5cff 100%);
  color: #fff;
  padding: 56px 28px 64px;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(900px 220px at 75% 0%, rgba(255,255,255,0.18), transparent 70%);
  pointer-events: none;
}
.hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 28px;
  letter-spacing: -0.01em;
}
.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  border-radius: 12px;
  font-size: 26px;
  line-height: 1;
}
.tagline {
  margin: 14px 0 0;
  color: rgba(255,255,255,0.85);
  font-size: 15px;
}

/* ---------- Layout ---------- */
.container {
  max-width: 1100px;
  margin: -32px auto 48px;
  padding: 0 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: relative;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 22px 24px;
}
.card-head {
  margin-bottom: 16px;
}
.card-head h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.card-sub {
  color: var(--text-muted);
  font-size: 13px;
}
.row-between {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* ---------- Input grid ---------- */
.input-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 18px;
  align-items: stretch;
}
.input-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.block-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.file-row {
  display: flex;
  gap: 8px;
}
.file-pick {
  flex: 1;
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  transition: border-color 0.15s, background 0.15s;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.file-pick:hover { border-color: var(--primary); background: #f0f3ff; }
.text-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.text-input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 108, 255, 0.15);
}
.divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 12px;
  position: relative;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  width: 1px;
  background: var(--border);
}
.divider span {
  padding: 6px 0;
}

/* ---------- Buttons ---------- */
.btn {
  padding: 10px 16px;
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text);
  transition: all 0.12s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: #f3f5fa;
  border-color: var(--text-dim);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-hov);
  border-color: var(--primary-hov);
}
.btn-accent {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-accent:hover:not(:disabled) {
  background: var(--accent-hov);
  border-color: var(--accent-hov);
}
.btn-outline {
  background: #fff;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-outline:hover:not(:disabled) {
  background: #f0f3ff;
  border-color: var(--primary);
  color: var(--primary);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: #eef0f5;
  color: var(--text);
}

/* ---------- Progress ---------- */
.progress-wrap {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}
#progressStage {
  font-weight: 500;
  color: var(--text);
}
#progressPct {
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  font-weight: 600;
}
.progress-bar {
  height: 8px;
  background: #e6e9f1;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #8b5cff);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.progress-fill.indeterminate {
  width: 35% !important;
  animation: indet 1.4s ease-in-out infinite;
}
@keyframes indet {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}
.progress-fill.error {
  background: var(--accent);
}

/* ---------- Status ---------- */
.status-line {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  min-height: 18px;
}

/* ---------- Score ---------- */
.toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}
.hint {
  color: var(--text-muted);
  font-size: 12px;
  margin: 4px 0 12px;
}
.hint b {
  background: #eef0f5;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
  color: var(--text);
  font-size: 11.5px;
}

.edit-panel {
  background: linear-gradient(180deg, #fff8e8 0%, #fff3d6 100%);
  border: 1px solid #f0d589;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 14px;
}
.edit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.edit-row:last-child { margin-bottom: 0; }
.edit-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.edit-row input[type="number"], .edit-row select {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  width: 80px;
}
.edit-title {
  font-weight: 600;
  font-size: 13px;
  color: #b07b00;
}
.edit-hint {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 12px;
}
body.edit-mode #osmd {
  box-shadow: 0 0 0 2px rgba(255, 90, 110, 0.4);
  cursor: crosshair;
}
body.edit-mode #editModeBtn {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

#osmd {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  overflow-x: auto;
  min-height: 320px;
  /* no max-height: show the whole score on one page (Endless format) */
}
.selected-note path { fill: #ff5722 !important; }
.measure-highlight {
  position: absolute;
  background: rgba(255, 213, 79, 0.28);
  border: 2px solid rgba(245, 166, 35, 0.7);
  border-radius: 5px;
  pointer-events: none;
  z-index: 5;
  transition: left 0.18s ease, top 0.18s ease, width 0.18s ease, height 0.18s ease;
  box-shadow: 0 0 12px rgba(245, 166, 35, 0.25);
}

.roll-details {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--surface-2);
}
.roll-details summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  outline: none;
}
.roll-details[open] summary { color: var(--text); }
#rollWrap {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: auto;
  max-height: 480px;
  margin-top: 10px;
}
#roll { display: block; }

/* ---------- Separation option ---------- */
.sep-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 16px;
  padding: 11px 13px;
  background: #f0f3ff;
  border: 1px solid #d6ddff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.45;
}
.sep-option input { margin-top: 2px; flex: none; }
.sep-option b { color: var(--text); }

/* ---------- Blank-score row ---------- */
.blank-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}
.blank-or {
  color: var(--text-dim);
  font-size: 13px;
}

/* ---------- Compose bar ---------- */
.compose-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.cb-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.dur-palette {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}
.dur-btn {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--text);
  transition: all 0.12s ease;
}
.dur-btn:hover { border-color: var(--primary); color: var(--primary); }
.dur-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.dur-btn.dot-btn.active {
  background: var(--accent);
  border-color: var(--accent);
}
.compose-bar select {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
}

/* ---------- Library / Gallery ---------- */
.lib-tabs {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tab-btn {
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 0.12s ease;
}
.tab-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.lib-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.lib-empty {
  grid-column: 1 / -1;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  padding: 22px 0;
}
.lib-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.lib-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.lib-item-title {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lib-item-meta {
  font-size: 11.5px;
  color: var(--text-dim);
}
.lib-item-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}
.lib-item-actions .btn {
  padding: 5px 10px;
  font-size: 12px;
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .input-grid { grid-template-columns: 1fr; }
  .divider { flex-direction: row; min-height: 24px; }
  .divider::before, .divider::after { width: auto; height: 1px; }
  .hero { padding: 40px 20px 56px; }
  .container { padding: 0 16px; }
  .card { padding: 18px 18px; }
}

/* Ghost cursor: where a staff-click would place a note */
.ghost-note {
  position: absolute;
  width: 14px;
  height: 10px;
  margin: -5px 0 0 -7px;
  border-radius: 50%;
  background: rgba(63, 122, 245, 0.45);
  border: 1.5px solid #3f7af5;
  pointer-events: none;
  z-index: 6;
  font-size: 10px;
  font-weight: 600;
  color: #3f7af5;
  text-indent: 16px;
  line-height: 9px;
  white-space: nowrap;
}

/* ----- Static site: footer / ads / policy pages ----- */
.ad-slot { margin: 18px auto; max-width: 1080px; text-align: center; min-height: 0; }
.site-footer {
  margin-top: 48px;
  padding: 32px 24px 40px;
  background: #1d2333;
  color: #aab2c5;
  font-size: 13px;
}
.footer-inner { max-width: 1080px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.footer-brand { font-weight: 600; color: #e8ebf3; }
.footer-links { display: flex; gap: 18px; flex-wrap: wrap; }
.footer-links a { color: #aab2c5; text-decoration: none; }
.footer-links a:hover { color: #fff; text-decoration: underline; }
.footer-copy { color: #7c8499; }
.page-card { max-width: 860px; margin: 32px auto; }
.page-card h1 { font-size: 26px; margin: 0 0 6px; }
.page-card h2 { font-size: 18px; margin: 28px 0 8px; }
.page-card p, .page-card li { line-height: 1.75; color: #3a4152; }
.page-card .updated { color: #8a909c; font-size: 13px; margin-bottom: 20px; }

/* Score title heading (real-sheet look, click to rename) */
.score-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: 18px 0 2px;
  color: #1d2333;
  cursor: pointer;
}
.score-title:hover { color: #3f7af5; }

/* playback timing toggle */
.perf-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: #5b6472;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

/* build stamp: instantly tells whether the browser runs current code */
.build-tag {
  position: fixed;
  right: 8px;
  bottom: 6px;
  font-size: 11px;
  color: #b0b6c3;
  background: rgba(255,255,255,.7);
  padding: 1px 7px;
  border-radius: 8px;
  z-index: 999;
  pointer-events: none;
}

.speed-sel { font-size: 12.5px; padding: 3px 4px; border: 1px solid #dfe3e8; border-radius: 6px; color: #5b6472; }

/* community-style gallery cards */
.lib-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.lib-item { display: flex; flex-direction: column; gap: 6px; }
.lib-thumb {
  width: 100%;
  height: 64px;
  border-radius: 8px;
  border: 1px solid #eceff4;
  background: #f7f8fb;
}

.like-btn { color: #e05263; font-weight: 600; }
.like-btn:disabled { opacity: .75; cursor: default; }

/* ----- bottom transport bar (songscription-style) ----- */
.player-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: #1d2333;
  color: #e8ebf3;
  z-index: 900;
  box-shadow: 0 -4px 16px rgba(0,0,0,.18);
}
.pb-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: #3f7af5;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
.pb-btn:hover { background: #2f66db; }
.pb-time { font-size: 12.5px; color: #aab2c5; min-width: 92px; text-align: center; }
.pb-seek { flex: 1; accent-color: #3f7af5; height: 4px; cursor: pointer; }
.pb-mode {
  background: #2a3145; color: #e8ebf3;
  border: 1px solid #3a4258; border-radius: 6px;
  font-size: 12.5px; padding: 4px 6px;
}
body.has-player main.container { padding-bottom: 76px; }
.play-cursor {
  position: absolute;
  width: 2.5px;
  background: #e53935;
  border-radius: 2px;
  pointer-events: none;
  z-index: 7;
  box-shadow: 0 0 4px rgba(229,57,53,.5);
}
