:root {
  color-scheme: light;
  --bg-cream: #f7f0e4;
  --bg-sand: #eadfcd;
  --paper: rgba(255, 251, 245, 0.9);
  --paper-strong: rgba(255, 254, 250, 0.96);
  --ink: #20150d;
  --muted: #705d50;
  --line: rgba(82, 51, 24, 0.14);
  --accent: #c86b1f;
  --accent-deep: #8f4210;
  --accent-soft: rgba(200, 107, 31, 0.12);
  --success: #256a43;
  --danger: #b33434;
  --navy: #163246;
  --glow: radial-gradient(circle at top right, rgba(221, 153, 76, 0.18), transparent 28%);
  --shadow-lg: 0 30px 90px rgba(55, 31, 14, 0.12);
  --shadow-md: 0 14px 44px rgba(55, 31, 14, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

html.popup-page-lock,
body.popup-page-lock {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(208, 138, 69, 0.22), transparent 24%),
    radial-gradient(circle at bottom right, rgba(31, 73, 98, 0.08), transparent 28%),
    linear-gradient(180deg, #faf5ed 0%, #f4ecdf 44%, #eee2d2 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
}

body::before {
  top: 0;
  right: 0;
  width: 32vw;
  height: 32vw;
  min-width: 260px;
  min-height: 260px;
  background: radial-gradient(circle, rgba(230, 184, 120, 0.16), transparent 70%);
}

body::after {
  bottom: 0;
  left: 0;
  width: 28vw;
  height: 28vw;
  min-width: 220px;
  min-height: 220px;
  background: radial-gradient(circle, rgba(67, 126, 162, 0.08), transparent 70%);
}

code,
pre,
select,
input,
button {
  font-family: Consolas, "Courier New", monospace;
}

.page {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: 28px 0 24px;
}

.shell-page,
.simple-sections,
.upload-form,
.song-list,
.api-card__list,
.api-short-list,
.edit-shell,
.edit-preview {
  display: grid;
  gap: 20px;
}

.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  backdrop-filter: blur(14px);
}

.panel + .panel {
  margin-top: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
  padding: 16px 18px;
  border: 1px solid rgba(87, 58, 31, 0.1);
  border-radius: 999px;
  background: rgba(255, 252, 248, 0.78);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
}

.topbar__brand,
.topbar__nav a,
.button-link {
  text-decoration: none;
}

.topbar__brand {
  display: grid;
  gap: 2px;
  color: var(--ink);
}

.topbar__brand-main {
  font-size: 1.15rem;
  font-weight: 700;
}

.topbar__brand-sub {
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.topbar__nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.topbar__nav a,
.lang-switch__select {
  color: var(--ink);
  border: 1px solid rgba(87, 58, 31, 0.12);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  padding: 10px 16px;
}

.topbar__nav a.is-active {
  color: #fff8f0;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
}

.lang-switch__label {
  font-size: 0.92rem;
  color: var(--muted);
}

.shell-hero,
.hero {
  overflow: hidden;
  position: relative;
  min-height: 220px;
  background:
    var(--glow),
    linear-gradient(135deg, rgba(255, 255, 255, 0.55), rgba(255, 247, 237, 0.88));
}

.shell-hero::after,
.hero::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -40px;
  width: 220px;
  height: 220px;
  border-radius: 36px;
  background: linear-gradient(145deg, rgba(220, 159, 99, 0.16), rgba(255, 255, 255, 0.02));
  transform: rotate(18deg);
}

.eyebrow,
.nav-card__eyebrow,
.popup-modal__eyebrow,
.stat-card__label {
  margin: 0;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.hero h1,
.section-head h2,
.simple-section h2,
.api-card h2,
.player-meta h2,
.popup-modal__title {
  margin: 0;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(2.1rem, 5vw, 4rem);
  max-width: 780px;
}

.intro,
.simple-section p,
.nav-card p,
.popup-modal__message,
.api-row__meta span,
.summary,
.player-empty,
.song-item__content span,
.player-artist,
.song-list__empty,
.page-footer,
.field small {
  color: var(--muted);
  line-height: 1.65;
}

.simple-sections {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.simple-section {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  display: grid;
  gap: 14px;
}

.simple-section::before {
  content: "";
  position: absolute;
  top: 18px;
  right: 18px;
  width: 84px;
  height: 84px;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(200, 107, 31, 0.12), rgba(22, 50, 70, 0.04));
}

.button-link,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  cursor: pointer;
  font-weight: 700;
  color: #fff8f3;
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  box-shadow: 0 10px 24px rgba(149, 75, 26, 0.18);
  transition: transform 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
}

.button-link:hover,
button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(149, 75, 26, 0.2);
}

button.secondary,
.secondary-link {
  color: var(--ink);
  background: linear-gradient(180deg, #f3e6d7, #e8d6c1);
  box-shadow: none;
}

.danger-button {
  background: linear-gradient(180deg, #d24a4a, #a42f2f);
}

button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 10px;
  font-size: 0.98rem;
}

.field span {
  font-weight: 700;
}

.field select,
.field input,
.lang-switch__select {
  width: 100%;
  border: 1px solid rgba(87, 58, 31, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.84);
  padding: 14px 16px;
  color: var(--ink);
  outline: none;
}

.field input:focus,
.field select:focus,
.lang-switch__select:focus {
  border-color: rgba(200, 107, 31, 0.38);
  box-shadow: 0 0 0 4px rgba(200, 107, 31, 0.1);
}

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

.dropzone {
  padding: 18px;
  border: 1px dashed rgba(116, 42, 10, 0.24);
  border-radius: 20px;
  background:
    linear-gradient(135deg, rgba(159, 62, 18, 0.05), rgba(255, 255, 255, 0.62)),
    rgba(255, 255, 255, 0.72);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 0.8rem;
  font-weight: 700;
}

.badge.idle {
  background: #efe0d0;
  color: #735845;
}

.badge.busy {
  background: #f6d18e;
  color: #69410b;
}

.badge.success {
  background: #d4ecdd;
  color: var(--success);
}

.badge.error {
  background: #f8d7d7;
  color: var(--danger);
}

.result {
  margin: 0;
  min-height: 220px;
  max-height: 560px;
  overflow: auto;
  border: 1px solid rgba(87, 58, 31, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  padding: 18px;
  white-space: pre-wrap;
  line-height: 1.55;
}

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

.song-list {
  margin-top: 18px;
}

.song-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  width: 100%;
  text-align: left;
  border-radius: 20px;
  border: 1px solid rgba(87, 58, 31, 0.12);
  background: rgba(255, 255, 255, 0.76);
  padding: 12px;
  color: var(--ink);
  box-shadow: var(--shadow-md);
}

.song-item.is-active {
  border-color: rgba(200, 107, 31, 0.36);
  box-shadow: inset 0 0 0 1px rgba(200, 107, 31, 0.14), var(--shadow-md);
}

.song-item--link {
  text-decoration: none;
}

.song-item img {
  width: 76px;
  height: 76px;
  object-fit: cover;
  border-radius: 16px;
}

.song-item__content {
  display: grid;
  gap: 6px;
}

.song-list__empty {
  padding: 16px;
  border: 1px dashed rgba(87, 58, 31, 0.16);
  border-radius: 16px;
}

.player-panel {
  min-height: 620px;
}

.player-empty {
  display: grid;
  place-items: center;
  min-height: 100%;
  font-size: 1.06rem;
}

.player-card {
  display: grid;
  gap: 22px;
}

.player-card.is-hidden,
.player-empty.is-hidden,
.popup-backdrop.is-hidden,
.popup-progress.is-hidden,
.popup-progress__label.is-hidden,
.popup-spinner.is-hidden,
.edit-shell.is-hidden {
  display: none;
}

.player-cover,
.edit-cover {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 24px;
  border: 1px solid rgba(87, 58, 31, 0.12);
  background: #f4eadf;
}

.edit-cover {
  width: min(100%, 320px);
  border-radius: 20px;
}

.player-meta {
  display: grid;
  gap: 8px;
}

.player-artist {
  margin: 0;
  font-size: 1.05rem;
}

.player-audio {
  width: 100%;
}

.edit-result {
  min-height: 180px;
}

.api-base {
  min-height: auto;
}

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

.api-card__list {
  gap: 14px;
}

.api-row {
  display: grid;
  gap: 12px;
  border: 1px solid rgba(87, 58, 31, 0.12);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.78);
}

.api-row__meta {
  display: grid;
  gap: 8px;
}

.api-row__meta code,
.api-short-row code {
  overflow-wrap: anywhere;
}

.popup-root {
  position: relative;
  z-index: 1000;
}

.popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 15, 10, 0.58);
  display: grid;
  place-items: center;
  padding: 22px;
  backdrop-filter: blur(8px);
}

.popup-modal {
  width: min(460px, 100%);
  background: var(--paper-strong);
  border: 1px solid rgba(87, 58, 31, 0.12);
  border-radius: 26px;
  box-shadow: 0 40px 100px rgba(22, 15, 10, 0.2);
  padding: 26px;
  display: grid;
  gap: 16px;
}

.popup-modal[data-variant="danger"] .popup-modal__icon,
.popup-modal[data-variant="error"] .popup-modal__icon {
  background: rgba(211, 65, 65, 0.12);
  color: var(--danger);
}

.popup-modal[data-variant="success"] .popup-modal__icon {
  background: rgba(37, 106, 67, 0.12);
  color: var(--success);
}

.popup-modal[data-variant="loading"] .popup-modal__status {
  align-items: center;
}

.popup-modal__status {
  display: flex;
  align-items: center;
  gap: 12px;
}

.popup-modal__icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(200, 107, 31, 0.12);
  color: var(--accent-deep);
  font-weight: 700;
  font-size: 1.2rem;
}

.popup-spinner {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 4px solid rgba(200, 107, 31, 0.12);
  border-top-color: var(--accent);
  animation: popup-spin 0.8s linear infinite;
}

.popup-modal__content {
  display: grid;
  gap: 8px;
}

.popup-modal__message {
  margin: 0;
}

.popup-progress {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(200, 107, 31, 0.1);
}

.popup-progress__bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #f0b261);
  transition: width 140ms ease;
}

.popup-progress__label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-deep);
}

.popup-modal__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-footer {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto 30px;
  padding: 10px 4px 0;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 0.92rem;
}

@keyframes popup-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .simple-sections,
  .player-layout,
  .api-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .page,
  .page-footer {
    width: min(100% - 20px, 100%);
  }

  .page {
    padding-top: 18px;
  }

  .panel {
    padding: 20px;
    border-radius: 22px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    border-radius: 28px;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .popup-modal {
    padding: 22px;
  }

  .page-footer {
    padding-bottom: 18px;
  }
}
