﻿:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1e2a32;
  --muted: #61707c;
  --primary: #114b5f;
  --accent: #f45b69;
  --ok: #1f7a4c;
  --warn: #b67811;
  --border: #d5dde3;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(180deg, #f8fbfd 0%, var(--bg) 45%);
  color: var(--text);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1200;
}
.topbar-start {
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar .main-nav { display: flex; align-items: center; gap: 12px; }
.topbar .main-nav a.active { font-weight: 700; }
.menu-toggle { display: none; }
.library-sidebar-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  min-width: 46px;
  height: 46px;
  padding: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f2f6f8 100%);
  color: #143847;
  border: 1px solid var(--border);
  box-shadow: 0 12px 24px rgba(17, 38, 48, 0.1);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.library-sidebar-toggle:hover {
  transform: translateY(-1px);
  border-color: #b9c9d2;
  box-shadow: 0 16px 28px rgba(17, 38, 48, 0.14);
}
.library-sidebar-toggle:focus-visible {
  outline: 3px solid rgba(17, 75, 95, 0.18);
  outline-offset: 2px;
}
.library-sidebar-toggle span {
  position: absolute;
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform .22s ease, opacity .18s ease, width .22s ease;
}
.library-sidebar-toggle span:nth-child(1) { transform: translateY(-6px); }
.library-sidebar-toggle span:nth-child(2) { transform: translateY(0); }
.library-sidebar-toggle span:nth-child(3) { transform: translateY(6px); }
.library-sidebar-toggle[aria-expanded="true"] {
  background: linear-gradient(180deg, #f4fafc 0%, #e9f3f6 100%);
  border-color: #b7cbd4;
}
.library-sidebar-toggle[aria-expanded="true"] span:nth-child(1) {
  transform: rotate(45deg);
}
.library-sidebar-toggle[aria-expanded="true"] span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0.2);
}
.library-sidebar-toggle[aria-expanded="true"] span:nth-child(3) {
  transform: rotate(-45deg);
}
.library-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 27, 35, 0.52);
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease;
  z-index: 1400;
}
.library-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(400px, 92vw);
  padding: 16px;
  transform: translateX(calc(-100% - 24px));
  transition: transform .28s ease;
  visibility: hidden;
  pointer-events: none;
  z-index: 1500;
}
.library-sidebar-inner {
  height: 100%;
  overflow-y: auto;
  padding: 14px 14px 16px;
  border-right: 1px solid var(--border);
  border-radius: 0 20px 20px 0;
  background: rgba(248, 251, 253, 0.98);
  box-shadow: 18px 0 40px rgba(13, 31, 41, 0.2);
}
.library-sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.library-sidebar-header h2 {
  margin: 4px 0 0;
  font-size: 1.4rem;
  line-height: 1.1;
}
.library-song-list {
  margin-top: 8px;
}
.library-song-list-head {
  margin: 0 0 8px;
}
.library-song-list-head h3 {
  margin: 2px 0 0;
  font-size: 1.05rem;
  line-height: 1.15;
}
.library-song-group + .library-song-group {
  margin-top: 12px;
}
.library-song-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 6px;
}
.library-song-group-head h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
.library-song-group-head span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.sidebar-eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
body.sidebar-open {
  overflow: hidden;
}
body.sidebar-open .library-sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}
body.sidebar-open .library-sidebar {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}
.container { max-width: 1100px; margin: 24px auto; padding: 0 16px 36px; }
.library-main {
  position: relative;
  z-index: 1;
}
.library-main .quota {
  max-width: 760px;
}
.piece-inline-stage {
  min-height: 260px;
}
.stage-topline {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 12px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.quota-inline {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}
.quota-inline strong {
  color: var(--text);
}
.piece-inline-empty h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}
.piece-inline-empty p {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
}
#piece-inline-content {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 320px));
  gap: 16px;
  align-items: stretch;
  justify-content: start;
}
#piece-inline-content > h3 {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.15;
}
#piece-inline-content .modal-copy {
  grid-column: 1 / -1;
  margin: 8px 0 2px;
  max-width: 720px;
}
#piece-inline-content .level-row {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  min-height: 100%;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 10px 22px rgba(17, 38, 48, 0.06);
}
#piece-inline-content .level-row[data-available="0"] {
  background: #f7f9fb;
  opacity: 0.88;
}
#piece-inline-content .level-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
#piece-inline-content .level-content > .muted {
  margin: 0;
}
#piece-inline-content .level-title {
  margin-bottom: 4px;
}
#piece-inline-content .preview-wrap {
  width: 100%;
  max-width: 220px;
  margin: 12px auto 0;
}
#piece-inline-content .exercise-section {
  margin-top: 14px;
}
#piece-inline-content .exercise-item {
  align-items: flex-start;
  flex-wrap: wrap;
}
#piece-inline-content .exercise-item a {
  white-space: nowrap;
}
#piece-inline-content .actions {
  width: 100%;
  margin-top: 12px;
}
#piece-inline-content .actions .button-link {
  width: 100%;
}
#piece-inline-content .level-row[data-available="0"] .actions {
  display: none;
}
.page-intro { margin-bottom: 18px; }
.page-intro h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 3vw, 2.6rem);
  line-height: 1.1;
}
.page-intro p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: 0 10px 24px rgba(17, 38, 48, 0.05);
}
.quota {
  display: grid;
  gap: 6px;
  align-items: start;
}
.quota-main {
  margin: 0;
  font-size: 1.2rem;
}
.quota-detail {
  margin: 0;
}
.filters {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) minmax(180px, 1fr) auto auto auto;
  gap: 14px;
  align-items: end;
}
.library-sidebar .filters {
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: stretch;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: none;
}
.library-sidebar .card {
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 12px;
  box-shadow: none;
}
.library-sidebar .quota {
  gap: 4px;
}
.library-sidebar .quota-main {
  font-size: 1rem;
}
.library-sidebar .quota-detail {
  font-size: 13px;
  line-height: 1.4;
}
.library-sidebar .grid {
  grid-template-columns: 1fr;
  gap: 0;
}
.library-sidebar .tab-panel:not(.hidden) {
  display: block;
}
.filter-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}
.filter-search {
  gap: 4px;
}
.filter-search span {
  font-size: 12px;
  letter-spacing: 0.01em;
  color: var(--muted);
}
.library-sidebar #library-search {
  min-height: 46px;
  padding: 12px 14px;
  font-size: 15px;
}
.filter-more {
  border-top: 1px solid #e3eaee;
  padding-top: 8px;
}
.filter-more summary {
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.filter-more summary::-webkit-details-marker {
  display: none;
}
.filter-more summary::after {
  content: "+";
  float: right;
  color: var(--primary);
}
.filter-more[open] summary::after {
  content: "-";
}
.filter-more-body {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}
.piece-list-item {
  border-bottom: 1px solid var(--border);
}
.piece-list-item:last-child {
  border-bottom: 0;
}
.library-search-hidden {
  display: none !important;
}
.piece-list-item.is-active .piece-list-trigger {
  color: var(--primary);
}
.piece-list-trigger {
  width: 100%;
  min-height: 0;
  padding: 8px 2px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  justify-content: flex-start;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.35;
  text-align: left;
}
.piece-list-trigger:hover {
  background: transparent;
  color: var(--primary);
  transform: none;
  box-shadow: none;
}
.piece-list-trigger:focus-visible {
  outline: 3px solid rgba(17, 75, 95, 0.16);
  outline-offset: 2px;
  border-radius: 8px;
}
.piece-list-item.is-active .piece-list-trigger::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--primary);
  vertical-align: middle;
}
.piece-list-item-muted .piece-list-trigger {
  color: var(--muted);
}
.library-empty-list {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.filter-field {
  color: var(--text);
  font-weight: 600;
}
.filter-field span {
  font-size: 14px;
}
.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 500;
  padding-bottom: 0;
  font-size: 13px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.piece-card {
  position: relative;
  overflow: hidden;
  min-height: 190px;
}
.piece-card h3 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.2;
}
.piece-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.piece-meta,
.piece-support {
  margin: 8px 0 0;
  color: var(--muted);
}
.piece-support {
  font-weight: 600;
}
.locked-card { opacity: 0.9; }
.locked-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 10px 14px;
  background: rgba(17, 75, 95, 0.85);
  color: #fff;
  font-weight: 600;
}
.locked-card h3 {
  margin-top: 52px;
}
.badge {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
}
.badge-good { background: #e6f8ed; color: var(--ok); }
.badge-warn { background: #fff3de; color: var(--warn); }
.badge-muted { background: #edf1f5; color: var(--muted); }
.badge-new { background: #e5f2ff; color: #1b5f91; }
.muted { color: var(--muted); }
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 14px;
  flex-wrap: wrap;
}
button,
.button-link {
  border: 0;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
}
button[disabled] { background: #9fb2bd; cursor: not-allowed; }
.button-secondary {
  background: #edf4f7;
  color: #123d4d;
}
.tabs {
  display: flex;
  gap: 8px;
  align-items: center;
}
.library-sidebar .tabs {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.tab-btn { background: #d9e4ea; color: #0f3340; }
.library-sidebar .tab-btn {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  font-size: 13px;
  justify-content: flex-start;
}
.tab-btn.active { background: var(--primary); color: #fff; }
.hidden { display: none; }
.piece-detail-template.hidden { display: none; }
.level-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  border-top: 1px solid var(--border);
  padding: 16px 0;
}
.level-row:first-of-type { border-top: 0; }
.level-content {
  min-width: 0;
}
.level-title {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 1rem;
}
.modal-copy {
  margin: 8px 0 6px;
  color: var(--muted);
}
.preview-wrap {
  position: relative;
  width: min(100%, 220px);
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #eef2f5;
}
.locked-preview-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
}
.preview-overlay {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  padding: 7px 9px;
  font-size: 12px;
  color: #fff;
  border-radius: 8px;
  background: rgba(20, 38, 48, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.exercise-section {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.exercise-section p {
  margin: 0 0 8px;
}
.exercise-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
}
.exercise-item span {
  flex: 1;
}
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  z-index: 10000;
  padding: 18px;
}
.modal.hidden { display: none; }
.modal-inner {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 18px;
  box-shadow: 0 18px 40px rgba(13, 31, 41, 0.18);
}
.zoom-inner {
  width: min(1040px, 100%);
}
.modal-close {
  margin-bottom: 12px;
}
#zoom-stage {
  position: relative;
  margin-top: 10px;
}
#zoom-preview-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f1f4f7;
}
#zoom-locked-mask {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 50%;
  border-radius: 0 0 8px 8px;
  display: flex;
  align-items: flex-end;
  padding: 12px;
  color: #fff;
  font-size: 14px;
  background: linear-gradient(180deg, rgba(13, 31, 41, 0.06) 0%, rgba(13, 31, 41, 0.72) 75%);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
#zoom-locked-mask.hidden {
  display: none;
}
.auth-wrap { min-height: 100vh; display: grid; place-content: center; padding: 24px; }
.auth-card { min-width: 320px; display: grid; gap: 10px; }
label { display: grid; gap: 5px; }
input, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
input[type="checkbox"] {
  width: auto;
  margin: 0;
}
.error-text { color: #b21231; }
.legal-links {
  margin: 10px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
#toast-container { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 9999; }
.toast {
  background: #0f1720;
  color: #fff;
  border-radius: 10px;
  padding: 12px 14px;
  min-width: 240px;
  opacity: 0.95;
  transition: transform .2s ease, opacity .2s ease;
  box-shadow: 0 12px 24px rgba(15, 23, 32, 0.18);
}
.toast-success { background: #175a39; }
.toast-warn { background: #8f6415; }
.toast-error { background: #90243f; }
.toast-info { background: #1f4252; }
.toast.out { opacity: 0; transform: translateY(5px); }
@media (max-width: 760px) {
  .filters { grid-template-columns: 1fr; }
  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
  }
  .topbar-start {
    min-width: 0;
  }
  .topbar .main-nav {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
    border-top: 0;
    padding-top: 0;
  }
  .page-intro h1 {
    font-size: 1.9rem;
  }
  .piece-inline-stage {
    min-height: 220px;
  }
  .library-sidebar {
    width: min(380px, 96vw);
    padding: 10px;
  }
  .library-sidebar-inner {
    padding: 16px;
    border-radius: 0 18px 18px 0;
  }
  #piece-inline-content {
    grid-template-columns: 1fr;
    justify-content: stretch;
    gap: 14px;
  }
  #piece-inline-content .level-row {
    padding: 14px;
  }
  #piece-inline-content .preview-wrap {
    width: min(100%, 260px);
    max-width: 260px;
  }
  #piece-inline-content .exercise-item {
    display: grid;
    grid-template-columns: 1fr;
    gap: 4px;
  }
  #piece-inline-content .exercise-item a {
    white-space: normal;
  }
  .level-row {
    grid-template-columns: 1fr;
  }
  .preview-wrap {
    width: 100%;
    max-width: 100%;
  }
  .actions {
    flex-direction: column;
    align-items: stretch;
  }
  .modal {
    padding: 10px;
  }
  .modal-inner {
    padding: 16px;
  }
}
