:root {
  --ink: #13201f;
  --deep: #0e2f2d;
  --leaf: #1f7d6b;
  --mint: #b8f4d3;
  --aqua: #60d7c6;
  --sun: #f5b45d;
  --paper: #fbfaf5;
  --wash: #eef5f1;
  --line: #c9d8d1;
  --muted: #65716d;
  --danger: #b34436;
  --shadow: 0 18px 50px rgba(19, 32, 31, 0.12);
  --radius: 8px;
  color-scheme: light;
  font-family: "Aptos", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(31, 125, 107, 0.05) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(rgba(31, 125, 107, 0.05) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--paper);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.side-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(251, 250, 245, 0.94);
  backdrop-filter: blur(16px);
}

.brand-lockup {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 12px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  color: white;
  background: var(--deep);
  border-radius: 8px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: inset 0 -10px 18px rgba(255, 255, 255, 0.08);
}

.brand-lockup strong,
.brand-lockup small {
  display: block;
}

.brand-lockup strong {
  font-size: 1.1rem;
}

.brand-lockup small,
.eyebrow,
.drop-kicker {
  color: var(--leaf);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.rail-nav {
  display: grid;
  gap: 8px;
}

.nav-item,
.mobile-tabs button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.nav-item.active,
.mobile-tabs button.active {
  color: white;
  background: var(--deep);
}

.nav-dot {
  width: 10px;
  height: 10px;
  border: 1px solid currentColor;
  border-radius: 999px;
}

.rail-note {
  margin-top: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
}

.rail-note span,
label span,
.time-row,
.track-meta p,
.settings-block p,
.chapter-meta,
.library-card p,
.import-preview p {
  color: var(--muted);
}

.rail-note strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.main-stage {
  min-width: 0;
  padding: 28px clamp(18px, 4vw, 44px) 110px;
}

.top-bar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin: -28px calc(clamp(18px, 4vw, 44px) * -1) 22px;
  padding: 24px clamp(18px, 4vw, 44px);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 245, 0.88);
  backdrop-filter: blur(18px);
}

body[data-active-view="player"] .top-bar {
  margin-bottom: 14px;
  padding-top: 16px;
  padding-bottom: 16px;
}

body[data-active-view="player"] .top-bar h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
  line-height: 1;
}

body[data-active-view="player"] .status-strip {
  display: none;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.7rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.45rem, 2vw, 2rem);
  line-height: 1.05;
}

h3 {
  margin-bottom: 8px;
}

.top-actions,
.button-row,
.transport,
.control-row,
.library-toolbar,
.section-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.danger-btn,
.play-btn,
.icon-btn,
.mini-play {
  min-height: 48px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0 18px;
  font-weight: 900;
  color: var(--ink);
  background: #fffdf7;
}

.primary-btn,
.play-btn {
  color: white;
  border-color: var(--deep);
  background: var(--deep);
}

.secondary-btn {
  border-color: rgba(31, 125, 107, 0.28);
  background: #ecfaf4;
  color: var(--deep);
}

.ghost-btn {
  background: transparent;
}

.danger-btn {
  color: white;
  border-color: var(--danger);
  background: var(--danger);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-btn.saved {
  border-color: rgba(31, 125, 107, 0.45);
  background: var(--mint);
}

.status-strip,
.view-panel,
.chapter-panel,
.now-playing,
.settings-block,
.import-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: var(--shadow);
}

.status-strip {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 20px;
  padding: 16px 18px;
}

.status-strip > div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: center;
}

.status-strip p {
  grid-column: 2;
  margin-bottom: 0;
}

.status-light {
  grid-row: 1 / span 2;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--leaf);
  box-shadow: 0 0 0 6px rgba(31, 125, 107, 0.1);
}

.status-light.small {
  grid-row: auto;
  width: 10px;
  height: 10px;
  box-shadow: 0 0 0 5px rgba(31, 125, 107, 0.08);
}

.status-strip.warn .status-light {
  background: var(--sun);
}

.status-strip.error .status-light {
  background: var(--danger);
}

.count-pill {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border-radius: 999px;
  color: var(--deep);
  background: var(--mint);
  font-weight: 900;
  white-space: nowrap;
}

.view-panel {
  display: none;
  padding: 18px;
}

.view-panel.active {
  display: block;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.section-head.tight {
  margin-bottom: 12px;
}

.library-toolbar {
  justify-content: space-between;
  margin-bottom: 14px;
}

.search-wrap {
  flex: 1 1 320px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  color: var(--ink);
  background: #fffdf7;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--leaf);
  box-shadow: 0 0 0 4px rgba(31, 125, 107, 0.14);
}

.compact-select {
  width: min(220px, 100%);
}

.library-list {
  display: grid;
  gap: 12px;
}

.library-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 108px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  text-align: left;
}

.library-card.active {
  border-color: var(--leaf);
  box-shadow: inset 5px 0 0 var(--leaf);
}

.item-badge {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 8px;
  color: var(--deep);
  background: var(--mint);
  font-weight: 900;
}

.source-pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  padding: 0 8px;
  border-radius: 999px;
  color: var(--deep);
  background: #ecfaf4;
  font-size: 0.78rem;
  font-weight: 900;
  vertical-align: middle;
}

.source-pill.cloud {
  background: var(--mint);
}

.library-card h3 {
  margin: 0 0 6px;
  font-size: 1.08rem;
}

.library-main {
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.library-card p {
  margin: 0;
}

.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.small-btn {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--deep);
  background: #ecfaf4;
  font-weight: 900;
}

.small-btn.muted {
  background: #fffdf7;
}

.small-btn.delete {
  color: var(--danger);
  background: #fff5ef;
}

.cloud-edit-form {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 0.35fr);
  gap: 12px;
  margin-top: 4px;
  padding: 14px;
  border: 1px solid rgba(31, 125, 107, 0.22);
  border-radius: 8px;
  background: rgba(238, 250, 244, 0.72);
}

.cloud-edit-form label {
  display: grid;
  gap: 6px;
}

.cloud-edit-form .wide {
  grid-column: 1 / -1;
}

.cloud-edit-form input,
.cloud-edit-form select,
.cloud-edit-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
}

.cloud-edit-form textarea {
  min-height: 88px;
  resize: vertical;
}

.cloud-edit-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.empty-state {
  padding: clamp(28px, 7vw, 72px) 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  background: rgba(238, 245, 241, 0.7);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.player-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.55fr);
  gap: 16px;
}

.chapter-panel {
  padding: 18px;
}

.now-playing {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px);
  grid-template-areas:
    "meta art"
    "timeline art"
    "transport art"
    "controls art";
  gap: 14px 16px;
  align-items: start;
  padding: 18px;
}

.cover-art {
  position: relative;
  display: grid;
  grid-area: art;
  min-height: 220px;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 30%, rgba(245, 180, 93, 0.9), transparent 26%),
    radial-gradient(circle at 70% 60%, rgba(96, 215, 198, 0.85), transparent 32%),
    linear-gradient(135deg, #0e2f2d, #1f7d6b);
}

.cover-art span {
  z-index: 2;
  display: grid;
  width: clamp(88px, 13vw, 130px);
  height: clamp(88px, 13vw, 130px);
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.65);
  border-radius: 50%;
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.1rem, 4vw, 4rem);
  font-weight: 900;
  background: rgba(14, 47, 45, 0.58);
}

.cover-grooves {
  position: absolute;
  inset: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  box-shadow:
    0 0 0 32px rgba(255, 255, 255, 0.06),
    0 0 0 64px rgba(255, 255, 255, 0.04),
    0 0 0 96px rgba(255, 255, 255, 0.025);
}

.track-meta {
  grid-area: meta;
  margin-top: 0;
}

.track-meta h2 {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.current-chapter {
  display: inline-flex;
  max-width: 100%;
  min-height: 34px;
  align-items: center;
  margin: 4px 0 0;
  padding: 6px 10px;
  border: 1px solid rgba(31, 125, 107, 0.2);
  border-radius: 999px;
  color: var(--deep);
  background: #ecfaf4;
  font-size: 0.9rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.timeline-block {
  grid-area: timeline;
  margin: 0;
}

.seek-range {
  accent-color: var(--deep);
  padding: 0;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
}

.transport {
  grid-area: transport;
  justify-content: center;
}

.play-btn {
  min-width: 136px;
}

.icon-btn {
  width: 58px;
  padding: 0;
}

.control-row {
  grid-area: controls;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: end;
  margin-top: 0;
}

.control-row label {
  min-width: 150px;
}

.chapter-jump-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chapter-jump-controls .secondary-btn {
  min-height: 42px;
  padding: 0 14px;
}

.chapter-list {
  display: grid;
  max-height: 620px;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.chapter-btn {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf7;
  color: var(--ink);
  text-align: left;
}

.chapter-btn.active {
  border-color: var(--leaf);
  background: #ecfaf4;
}

.chapter-time {
  color: var(--deep);
  font-weight: 900;
}

.chapter-title {
  display: block;
  margin-bottom: 4px;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.chapter-meta {
  display: block;
  font-size: 0.9rem;
}

.import-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.drop-zone {
  position: relative;
  min-height: 210px;
  justify-content: center;
  padding: 20px;
  border: 2px dashed rgba(31, 125, 107, 0.36);
  border-radius: 8px;
  background: #ecfaf4;
}

.drop-zone.soft {
  background: #fff8ea;
  border-color: rgba(245, 180, 93, 0.58);
}

.drop-zone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.drop-zone strong {
  font-size: clamp(1.2rem, 3vw, 2rem);
  overflow-wrap: anywhere;
}

.drop-zone small {
  max-width: 42ch;
  color: var(--muted);
  font-size: 1rem;
}

.import-details {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.import-preview {
  margin: 14px 0;
  padding: 16px;
}

.cloud-publish-note {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(31, 125, 107, 0.26);
  border-radius: 8px;
  background: #ecfaf4;
}

.cloud-publish-note > div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  align-items: center;
}

.cloud-publish-note p {
  grid-column: 2;
  margin-bottom: 0;
  color: var(--muted);
}

.import-preview p {
  margin-bottom: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.settings-block {
  padding: 18px;
}

.block-btn {
  width: 100%;
  margin-top: 12px;
}

.code-status {
  margin: 10px 0 0;
  min-height: 24px;
  color: var(--muted);
  font-weight: 800;
}

.code-status.saved {
  color: var(--deep);
}

.danger-zone {
  border-color: rgba(179, 68, 54, 0.35);
}

.mini-player {
  position: fixed;
  z-index: 40;
  right: 18px;
  bottom: 18px;
  display: grid;
  grid-template-columns: auto minmax(180px, 330px);
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(14, 47, 45, 0.22);
  border-radius: 8px;
  background: rgba(251, 250, 245, 0.96);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.mini-meta {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
}

.mini-meta strong,
.mini-meta span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-meta span {
  color: var(--muted);
  font-weight: 800;
}

.mobile-tabs {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .side-rail {
    display: none;
  }

  .main-stage {
    padding: 18px 14px 132px;
  }

  .top-bar {
    margin: -18px -14px 14px;
    padding: 16px 14px;
  }

  h1 {
    font-size: clamp(1.85rem, 10vw, 2.65rem);
  }

  .player-layout,
  .import-grid,
  .import-details,
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .now-playing {
    grid-template-columns: minmax(0, 1fr) minmax(150px, 220px);
  }

  .cover-art {
    min-height: 190px;
  }

  .chapter-list {
    max-height: 420px;
  }

  .mini-player {
    right: 10px;
    bottom: 76px;
    left: 10px;
    grid-template-columns: auto minmax(0, 1fr);
  }

  .mobile-tabs {
    position: fixed;
    z-index: 50;
    right: 10px;
    bottom: 10px;
    left: 10px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 6px;
    border: 1px solid rgba(14, 47, 45, 0.2);
    border-radius: 8px;
    background: rgba(251, 250, 245, 0.97);
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
  }

  .mobile-tabs button {
    justify-content: center;
    min-height: 48px;
    padding: 0 4px;
    font-size: 0.82rem;
    text-align: center;
  }
}

@media (max-width: 640px) {
  .top-actions {
    justify-content: flex-end;
  }

  .top-actions .ghost-btn {
    display: none;
  }

  .status-strip,
  .section-head,
  .library-toolbar,
  .section-actions,
  .control-row {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip {
    display: grid;
  }

  .library-card {
    grid-template-columns: auto 1fr;
  }

  .library-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
  }

  .cloud-edit-form {
    grid-template-columns: 1fr;
  }

  .chapter-jump-controls,
  .chapter-jump-controls .secondary-btn {
    width: 100%;
  }

  .cover-art {
    min-height: 150px;
  }

  .now-playing {
    grid-template-columns: 1fr;
    grid-template-areas:
      "meta"
      "timeline"
      "transport"
      "controls"
      "art";
    gap: 12px;
    padding: 14px;
  }

  body[data-active-view="player"] .top-bar {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  body[data-active-view="player"] .top-bar h1 {
    font-size: 1.7rem;
  }

  body[data-active-view="player"] .top-actions {
    display: none;
  }

  body[data-active-view="player"] .main-stage {
    padding-top: 14px;
  }
}
