:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #0d0e10;
  --panel: #15171a;
  --panel-raised: #1b1e22;
  --line: #2a2d32;
  --muted: #8d929b;
  --text: #f2f0eb;
  --accent: #d7a44a;
  --accent-soft: #5c4520;
  --active: #69b59b;
  --paper: #f5f0e6;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
button, input { font: inherit; }
button { color: inherit; }

.app { display: flex; width: 100vw; height: 100dvh; background: var(--bg); }
.app.panel-right { flex-direction: row-reverse; }

.library {
  width: clamp(350px, 31vw, 450px);
  min-width: 350px;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  background: linear-gradient(180deg, #181a1e 0%, #121417 100%);
  border-right: 1px solid var(--line);
  position: relative;
  z-index: 10;
}
.panel-right .library { border-right: 0; border-left: 1px solid var(--line); }

.brand-row { height: 78px; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.brand-mark { width: 45px; height: 45px; position: relative; display: grid; place-items: center; border: 1px solid #765d30; border-radius: 12px; background: linear-gradient(145deg, #392c18, #1b1c1f); box-shadow: inset 0 0 18px #d7a44a18; }
.brand-mark span { font-size: 25px; font-weight: 800; color: var(--accent); transform: translateX(-4px); }
.brand-mark i { position: absolute; font-size: 8px; letter-spacing: .5px; right: 5px; bottom: 6px; color: #f7e0b5; font-style: normal; font-weight: 800; }
.brand-row h1 { margin: 0; font-size: 22px; letter-spacing: .4px; }
.brand-row p { margin: 2px 0 0; color: var(--muted); font-size: 11px; letter-spacing: .65px; text-transform: uppercase; }
.icon-button { margin-left: auto; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: #202329; font-size: 20px; cursor: pointer; }
.icon-button:active { transform: scale(.96); }

.view-tabs { display: grid; grid-template-columns: repeat(3, 1fr) 45px 45px; gap: 4px; padding: 10px 12px 8px; }
.tab { height: 35px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; }
.tab.active { color: #1b160d; background: var(--accent); box-shadow: 0 4px 16px #d7a44a20; }
.icon-tab { font-size: 16px; }

.search-box { margin: 0 12px 9px; height: 42px; display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 10px; background: #101215; padding: 0 11px; color: var(--muted); }
.search-box:focus-within { border-color: #8d6b32; box-shadow: 0 0 0 2px #d7a44a12; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 13px; }
.search-box kbd { min-width: 25px; padding: 3px 6px; border: 1px solid #34373d; border-radius: 6px; background: #23262b; color: var(--muted); text-align: center; font-size: 10px; }

.list-caption { height: 34px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .7px; }
.text-button { border: 0; background: transparent; color: var(--accent); font-size: 11px; cursor: pointer; }
.song-list { min-height: 0; overflow-y: auto; padding: 0 8px 8px; scrollbar-color: #45484d transparent; }

.song-row { min-height: 62px; display: grid; grid-template-columns: minmax(0, 1fr) 39px 44px; align-items: center; gap: 6px; margin: 3px 0; padding: 7px 8px 7px 12px; border: 1px solid transparent; border-radius: 10px; background: #1a1d21; transition: .15s ease; }
.song-row:hover { background: #202328; border-color: #30343a; }
.song-row.active { border-color: #356657; background: linear-gradient(90deg, #193128, #1a1d21 70%); }
.song-row.previewing { border-color: #8d6b32; background: linear-gradient(90deg, #3a2d18, #1a1d21 70%); }
.song-info { min-width: 0; }
.song-title { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 720; }
.song-subtitle { display: flex; gap: 6px; align-items: center; margin-top: 4px; color: var(--muted); font-size: 10px; overflow: hidden; white-space: nowrap; }
.song-subtitle span:first-child { overflow: hidden; text-overflow: ellipsis; }
.tiny-pill { padding: 2px 5px; border: 1px solid #383b41; border-radius: 5px; color: #c4c0b8; }
.row-button { height: 38px; border: 1px solid #373a40; border-radius: 9px; background: #25282d; cursor: pointer; font-size: 17px; touch-action: none; }
.row-button.preview { color: #e9c782; }
.row-button.load { background: #3d311d; border-color: #735829; color: #f6d99f; }
.row-button:active { transform: scale(.94); filter: brightness(1.15); }

.library-footer { min-height: 58px; display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); background: #111316; }
.footer-button { border: 0; border-right: 1px solid #23262a; background: transparent; color: var(--muted); font-size: 10px; cursor: pointer; }
.footer-button span { display: block; color: #cbc7be; font-size: 17px; margin-bottom: 3px; }

.stage { min-width: 0; flex: 1; display: grid; grid-template-rows: 67px auto minmax(0, 1fr) 70px; position: relative; background: radial-gradient(circle at 50% 35%, #282b30 0%, #121417 72%); }
.stage-header { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) auto; align-items: center; gap: 18px; padding: 0 18px; border-bottom: 1px solid var(--line); background: #121417e8; backdrop-filter: blur(12px); z-index: 4; }
.current-meta { display: flex; align-items: center; gap: 10px; min-width: 0; }
.status-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--active); box-shadow: 0 0 10px #69b59b88; }
.current-meta div { min-width: 0; }
.current-meta small { display: block; color: var(--active); font-size: 9px; font-weight: 800; letter-spacing: 1.1px; }
.current-meta strong { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.musical-meta { display: flex; justify-content: center; align-items: center; gap: 8px; color: #c0bdb6; font-size: 12px; white-space: nowrap; overflow: hidden; }
.musical-meta > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.meta-pill { padding: 4px 7px; border: 1px solid #373a40; border-radius: 7px; background: #1c1f23; color: #ded8cd; }
.header-actions { display: flex; gap: 7px; }
.header-button { height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 9px; background: #202328; color: #bbb8b1; font-size: 11px; cursor: pointer; }
.header-button[aria-pressed="true"] { border-color: #6a532b; color: #f1d294; background: #312719; }

.preview-banner { display: none; height: 32px; align-items: center; justify-content: space-between; padding: 0 16px; background: #493719; color: #f4d59a; border-bottom: 1px solid #906b2d; font-size: 10px; font-weight: 900; letter-spacing: 1.2px; }
.preview-banner.visible { display: flex; }
.preview-banner button { border: 0; background: transparent; color: #f3deb6; font-size: 11px; cursor: pointer; }

.viewer-shell { min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; padding: 14px 54px; }
.paper-wrap { height: 100%; max-width: 100%; aspect-ratio: 1.414 / 1; display: flex; align-items: center; justify-content: center; filter: drop-shadow(0 18px 30px #0008); touch-action: pan-y; }
.paper { width: 100%; height: 100%; overflow: hidden; background: var(--paper); color: #171717; border-radius: 3px; }
.paper svg { width: 100%; height: 100%; display: block; }
.page-zone { position: absolute; top: 0; bottom: 0; width: 50px; border: 0; background: transparent; color: #a8a59f; font-size: 48px; cursor: pointer; opacity: .55; z-index: 2; }
.page-zone:hover { opacity: 1; background: linear-gradient(90deg, #0000, #ffffff08); }
.page-zone.left { left: 0; }
.page-zone.right { right: 0; }
.page-zone:disabled { opacity: .08; cursor: default; }
.locked-indicator { display: none; position: absolute; top: 12px; left: 50%; transform: translateX(-50%); padding: 7px 11px; border: 1px solid #547b6e; border-radius: 99px; background: #16241fe8; color: #8ac9b3; font-size: 9px; font-weight: 800; letter-spacing: .8px; }
.locked-indicator span { font-size: 7px; }
.locked .locked-indicator { display: block; }
.locked .library { opacity: .35; pointer-events: none; filter: saturate(.35); }

.transport { display: grid; grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr); align-items: center; gap: 18px; padding: 8px 16px; border-top: 1px solid var(--line); background: #121417f3; }
.transport-button { height: 52px; min-width: 0; display: flex; align-items: center; gap: 12px; border: 1px solid #2e3237; border-radius: 11px; background: #1b1e22; text-align: left; cursor: pointer; }
.transport-button.next { justify-content: flex-end; text-align: right; }
.transport-button > span { padding: 0 7px; color: var(--accent); font-size: 32px; line-height: 1; }
.transport-button div { min-width: 0; }
.transport-button small { display: block; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .9px; }
.transport-button strong { display: block; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.page-status { min-width: 90px; text-align: center; color: var(--muted); font-size: 10px; }
.page-dots { display: flex; justify-content: center; gap: 5px; margin-bottom: 5px; }
.page-dot { width: 5px; height: 5px; border-radius: 99px; background: #4a4d52; }
.page-dot.active { width: 14px; background: var(--accent); }

.toast { position: fixed; left: 50%; bottom: 86px; transform: translate(-50%, 16px); padding: 10px 16px; border: 1px solid #55504a; border-radius: 10px; background: #22252bea; color: #ece8e0; box-shadow: 0 12px 30px #0008; font-size: 12px; opacity: 0; pointer-events: none; transition: .2s ease; z-index: 20; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.portrait-warning { display: none; }

@media (max-width: 980px) {
  .library { width: 350px; min-width: 350px; }
  .musical-meta { display: none; }
  .stage-header { grid-template-columns: minmax(0, 1fr) auto; }
  .paper-wrap { max-height: 100%; }
}

@media (orientation: landscape) and (max-width: 760px) {
  .library { width: 280px; min-width: 280px; }
  .brand-row { height: 58px; padding: 7px 10px; gap: 8px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 10px; }
  .brand-mark span { font-size: 21px; }
  .brand-row h1 { font-size: 18px; }
  .brand-row p { display: none; }
  .icon-button { width: 34px; height: 34px; }
  .view-tabs { padding: 6px 8px 5px; grid-template-columns: repeat(3, 1fr) 34px 34px; }
  .tab { height: 30px; font-size: 10px; }
  .search-box { margin: 0 8px 5px; height: 35px; }
  .list-caption { height: 28px; padding: 0 10px; font-size: 9px; }
  .song-row { min-height: 52px; grid-template-columns: minmax(0, 1fr) 35px 38px; padding: 5px 6px 5px 9px; }
  .song-title { font-size: 12px; }
  .song-subtitle { font-size: 8px; }
  .row-button { height: 34px; }
  .library-footer { min-height: 44px; }
  .footer-button { font-size: 8px; }
  .footer-button span { display: inline; margin-right: 3px; font-size: 12px; }
  .stage { grid-template-rows: 51px auto minmax(0, 1fr) 54px; }
  .stage-header { padding: 0 9px; gap: 8px; }
  .current-meta strong { font-size: 13px; }
  .header-button { height: 31px; padding: 0 7px; font-size: 9px; }
  .viewer-shell { padding: 8px 32px; }
  .page-zone { width: 32px; font-size: 34px; }
  .transport { grid-template-columns: minmax(125px, 1fr) auto minmax(125px, 1fr); gap: 7px; padding: 5px 7px; }
  .transport-button { height: 42px; gap: 4px; padding: 1px 4px; }
  .transport-button > span { padding: 0 3px; font-size: 25px; }
  .transport-button strong { font-size: 9px; }
  .page-status { min-width: 54px; }
}

@media (orientation: portrait) {
  .app { display: none; }
  .portrait-warning { width: 100vw; height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 30px; background: radial-gradient(circle, #292317, #0f1012 65%); color: var(--text); text-align: center; }
  .portrait-warning strong { color: var(--accent); font-size: 20px; }
  .portrait-warning span { max-width: 350px; color: var(--muted); font-size: 13px; }
}
