:root {
  --bg: #f4f1ea;
  --surface: #fffdf9;
  --surface-2: #f7f4ee;
  --ink: #18201c;
  --muted: #6e756f;
  --line: #ddd8cf;
  --accent: #1e5b48;
  --accent-2: #dfece5;
  --danger: #a53f3f;
  --shadow: 0 20px 55px rgba(36, 44, 39, 0.08);
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% -10%, rgba(34, 90, 70, .08), transparent 30%),
    var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 82px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(130, 130, 120, .18);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center;
  background: var(--accent); color: white; font-size: 23px;
  box-shadow: 0 8px 20px rgba(30, 91, 72, .2);
}
.brand h1 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.top-actions, .footer-actions { display: flex; gap: 10px; }

.button {
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 15px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.button:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(20, 30, 25, .08); }
.button.primary { background: var(--accent); color: white; border-color: var(--accent); }
.button.ghost { background: rgba(255,255,255,.48); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(380px, .8fr);
  gap: 20px;
  max-width: 1500px;
  margin: 0 auto;
  padding: 22px 28px 32px;
  min-height: calc(100vh - 82px);
}
.panel {
  min-height: 0;
  background: rgba(255,253,249,.82);
  border: 1px solid rgba(170,165,155,.38);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}
.library { padding: 24px; }
.set-panel { display: flex; flex-direction: column; padding: 24px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.section-head h2 { margin: 3px 0 0; font-size: 25px; letter-spacing: -.03em; }
.eyebrow { color: var(--accent); text-transform: uppercase; font-size: 11px; font-weight: 850; letter-spacing: .14em; }
.count-pill {
  min-width: 34px; height: 30px; padding: 0 9px; border-radius: 999px;
  display: grid; place-items: center; background: var(--accent-2); color: var(--accent); font-weight: 800; font-size: 12px;
}

.search-wrap {
  margin: 18px 0 20px;
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--line); background: white; border-radius: 13px; padding: 0 12px;
}
.search-wrap span { color: var(--muted); font-size: 20px; }
.search-wrap input { border: 0; outline: 0; background: transparent; width: 100%; padding: 12px 0; color: var(--ink); }

.song-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
  align-content: start;
}
.song-card {
  position: relative;
  border: 1px solid var(--line);
  background: white;
  border-radius: 15px;
  overflow: hidden;
  min-width: 0;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.song-card:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(28, 34, 30, .09); border-color: #c7c0b4; }
.song-thumb-wrap {
  aspect-ratio: 4 / 5;
  background: #ece8e0;
  overflow: hidden;
  position: relative;
}
.song-thumb { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
.add-overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(17, 35, 28, .04); opacity: 0; transition: opacity .15s ease;
}
.song-card:hover .add-overlay { opacity: 1; }
.add-circle {
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--accent); color: white; font-size: 28px; line-height: 1;
  box-shadow: 0 10px 28px rgba(30, 91, 72, .3);
}
.song-meta { padding: 11px 12px 13px; }
.song-title { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-sub { margin-top: 4px; color: var(--muted); font-size: 11px; }

.set-title-input {
  display: block; border: 0; background: transparent; outline: 0; padding: 0; margin-top: 3px;
  width: min(320px, 100%); color: var(--ink); font-weight: 850; font-size: 25px; letter-spacing: -.03em;
}
.small-actions { display: flex; gap: 8px; }
.icon-button {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line);
  background: white; color: var(--ink); font-size: 19px; display: grid; place-items: center;
}
.icon-button.danger { color: var(--danger); }
.saved-sets-row {
  display: grid; grid-template-columns: auto 1fr auto; gap: 9px; align-items: center;
  margin: 18px 0 12px; padding-bottom: 15px; border-bottom: 1px solid var(--line);
}
.saved-sets-row label { color: var(--muted); font-size: 12px; font-weight: 700; }
.saved-sets-row select {
  width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink);
}

.set-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; padding: 3px 2px 12px; }
.set-item {
  display: grid; grid-template-columns: 22px 34px minmax(0, 1fr) 30px; gap: 10px; align-items: center;
  padding: 10px 11px;
  border: 1px solid var(--line); border-radius: 13px; background: white;
  user-select: none;
}
.set-item.dragging { opacity: .45; }
.set-item.drop-before { border-top: 3px solid var(--accent); }
.drag-handle { color: #a8aaa6; font-size: 19px; cursor: grab; letter-spacing: -3px; }
.set-number {
  width: 28px; height: 28px; border-radius: 9px; background: var(--surface-2); display: grid; place-items: center; font-weight: 850; font-size: 12px;
}
.set-item-title { font-weight: 760; font-size: 14px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-item-pages { color: var(--muted); font-size: 11px; }
.remove-song { border: 0; background: transparent; color: #8a8f8b; font-size: 20px; border-radius: 8px; }
.remove-song:hover { color: var(--danger); background: #fff2f2; }

.empty-state, .empty-set { text-align: center; color: var(--muted); padding: 54px 24px; }
.empty-state h3, .empty-set h3 { color: var(--ink); margin: 10px 0 6px; }
.empty-state p, .empty-set p { max-width: 360px; margin: 0 auto 16px; line-height: 1.45; font-size: 13px; }
.empty-icon, .drop-symbol { margin: auto; width: 58px; height: 58px; border-radius: 18px; background: var(--accent-2); color: var(--accent); display: grid; place-items: center; font-size: 28px; }
.set-panel .empty-set { margin: auto; }

.set-footer {
  margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.set-stats { display: flex; flex-direction: column; gap: 2px; }
.set-stats strong { font-size: 13px; }
.set-stats span { color: var(--muted); font-size: 11px; }
.hidden { display: none !important; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 15px);
  opacity: 0; pointer-events: none; z-index: 500;
  background: #17201b; color: white; padding: 11px 15px; border-radius: 11px; box-shadow: 0 12px 30px rgba(0,0,0,.2);
  font-size: 13px; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.player {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; flex-direction: column; background: #1a1d1b;
}
.player-bar {
  height: 70px; flex: 0 0 70px; padding: 0 18px;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center;
  background: #111412; color: white; border-bottom: 1px solid rgba(255,255,255,.1);
}
.player-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.player-close { width: 38px; height: 38px; border-radius: 11px; border: 1px solid rgba(255,255,255,.15); background: rgba(255,255,255,.06); color: white; font-size: 24px; }
.player-kicker { color: #9fafaa; font-size: 10px; text-transform: uppercase; letter-spacing: .13em; font-weight: 800; }
.player-song { font-size: 15px; font-weight: 780; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-progress { color: #d9e3de; font-size: 13px; font-weight: 750; }
.player-hint { justify-self: end; color: #9fafaa; font-size: 11px; }
.player-stage {
  flex: 1; overflow: auto; padding: 22px;
  display: flex; flex-direction: column; align-items: safe center; gap: 18px;
  scroll-behavior: smooth;
}
.player-page {
  width: min(1100px, calc(100vw - 70px)); max-width: none; height: auto; display: block;
  background: white; box-shadow: 0 20px 55px rgba(0,0,0,.32); border-radius: 3px;
}
.player-loading { color: #c8cfcb; margin-top: 18vh; font-size: 14px; }
.player-controls {
  position: fixed; right: 24px; bottom: 22px; z-index: 1100; display: flex; gap: 10px;
}
.player-zoom-controls {
  position: fixed; left: 24px; bottom: 22px; z-index: 1100;
  display: flex; align-items: center; gap: 8px;
}
.zoom-label {
  min-width: 62px; height: 42px; padding: 0 10px;
  border-radius: 21px; border: 1px solid rgba(255,255,255,.18);
  background: rgba(20,25,22,.78); color: white; font-size: 12px; font-weight: 800;
  backdrop-filter: blur(8px);
}
.zoom-label:hover { background: rgba(39,46,42,.92); }
.round-button {
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(255,255,255,.18); background: rgba(20,25,22,.78); color: white; font-size: 22px; backdrop-filter: blur(8px);
}
.round-button.main { background: var(--accent); border-color: var(--accent); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; padding: 14px; }
  .topbar { padding: 0 14px; }
  .top-actions .ghost { display: none; }
  .set-panel { min-height: 580px; }
  .player-hint { display: none; }
  .player-bar { grid-template-columns: 1fr auto; }
}

@media (max-width: 560px) {
  .player-controls { right: 12px; bottom: 12px; }
  .player-zoom-controls { left: 12px; bottom: 12px; }
  .player-zoom-controls .round-button { width: 44px; height: 44px; }
  .zoom-label { min-width: 54px; height: 40px; padding: 0 7px; }
  .brand p { display: none; }
  .top-actions .button { padding: 9px 11px; }
  .song-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .set-footer { align-items: flex-end; }
  .footer-actions { flex-direction: column; }
  .footer-actions .button { padding: 9px 11px; font-size: 12px; }
}

/* Sharing / public mode */
.inline-form { margin: 0; }
.link-button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.button.compact { padding: 8px 11px; font-size: 12px; }
.share-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 12px; padding: 11px 12px;
  border: 1px solid #cdded4; border-radius: 13px; background: #f3faf6;
}
.share-label { display: block; color: var(--accent); font-size: 12px; font-weight: 850; }
.share-help { display: block; margin-top: 2px; color: var(--muted); font-size: 10px; }
.share-actions { display: flex; align-items: center; gap: 7px; }

.login-body {
  min-height: 100vh; display: grid; place-items: center; padding: 22px;
}
.login-card { width: min(430px, 100%); padding: 28px; }
.login-brand { margin-bottom: 28px; }
.login-card h2 { margin: 0; font-size: 28px; letter-spacing: -.03em; }
.login-copy { margin: 7px 0 22px; color: var(--muted); font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 9px; }
.login-form label { font-size: 12px; font-weight: 800; }
.login-form input {
  width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px;
  outline: none; background: white; color: var(--ink);
}
.login-form input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,91,72,.09); }
.login-form .button { margin-top: 6px; }
.login-error { margin: 0 0 13px; padding: 10px 12px; border-radius: 10px; background: #fff0f0; color: var(--danger); font-size: 12px; font-weight: 700; }

.public-body { min-height: 100vh; }
.public-topbar {
  min-height: 82px; padding: 15px 28px; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  border-bottom: 1px solid rgba(130, 130, 120, .18);
}
.public-main { max-width: 920px; margin: 0 auto; padding: 26px 22px 48px; }
.public-set-card { padding: 24px; }
.public-song-list { display: flex; flex-direction: column; gap: 9px; margin-top: 20px; }
.public-song-row {
  display: grid; grid-template-columns: 34px 54px minmax(0, 1fr) 36px; align-items: center; gap: 12px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 13px; background: white;
}
.public-song-row img { width: 54px; height: 64px; object-fit: cover; object-position: top; border-radius: 6px; background: #ece8e0; }
.public-song-info { min-width: 0; }
.public-song-info strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.public-song-info span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.public-row-play { font-size: 13px; color: var(--accent); }
.not-found-card { width: min(520px, calc(100% - 32px)); margin: 15vh auto 0; padding: 42px 28px; text-align: center; }
.not-found-card h1 { margin: 16px 0 7px; }
.not-found-card p { margin: 0; color: var(--muted); }

@media (max-width: 700px) {
  .public-topbar { align-items: flex-start; padding: 14px; }
  .public-topbar .top-actions { flex-direction: column; }
  .public-main { padding: 14px; }
  .public-set-card { padding: 16px; }
  .share-row { align-items: flex-start; flex-direction: column; }
  .share-actions { width: 100%; }
  .share-actions .compact { flex: 1; }
}
