:root {
  color-scheme: light;
  --bg-gradient: radial-gradient(circle at top left, rgba(70, 130, 180, 0.28), transparent 55%),
    radial-gradient(circle at 20% 80%, rgba(138, 43, 226, 0.22), transparent 60%),
    linear-gradient(160deg, #f7f9ff 0%, #ffffff 60%, #f0f6ff 100%);
  --surface-color: rgba(255, 255, 255, 0.88);
  --surface-border: rgba(255, 255, 255, 0.35);
  --shadow-color: rgba(22, 31, 61, 0.14);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --accent: #6366f1;
  --accent-strong: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.12);
  --success: #22c55e;
  --danger: #ef4444;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
  color: var(--text-primary);
  line-height: 1.65;
  background: #f0f4ff;
  overflow: hidden;
}

.app-body {
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  background: #f0f4ff;
  isolation: isolate;
}

.app-background {
  position: fixed;
  inset: 0;
  background: var(--bg-gradient);
  z-index: -2;
}

.app-shell {
  position: relative;
  max-width: 1140px;
  margin: 0 auto;
  padding: 48px 24px 64px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  height: 100%;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--surface-border);
  border-radius: 24px;
  padding: 24px 32px;
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.08);
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 18px;
}

.site-logo {
  font-size: 42px;
  filter: drop-shadow(0 12px 18px rgba(15, 23, 42, 0.18));
}

.site-title h1 {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.site-title p {
  margin: 6px 0 0;
  color: var(--text-secondary);
}

.app-main {
  display: flex;
  flex-direction: column;
  gap: 32px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.site-footer {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 20px;
  padding: 18px 24px;
  border: 1px solid var(--surface-border);
  backdrop-filter: blur(16px);
}

.page-wrapper {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 28px;
  height: 100%;
  min-height: 0;
}

.glass-card {
  background: var(--surface-color);
  border-radius: 26px;
  padding: 28px 32px;
  box-shadow: 0 30px 60px var(--shadow-color);
  border: 1px solid var(--surface-border);
  backdrop-filter: blur(22px);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 36px 70px rgba(15, 23, 42, 0.16);
}

.page-intro h2 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 2.4vw + 1rem, 2.45rem);
}

.page-intro p {
  margin: 0;
  color: var(--text-secondary);
  max-width: 62ch;
}

.card-grid {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 24px;
  min-height: 0;
}

.upload-card,
.music-card {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.music-card {
  min-height: 0;
  overflow: auto;
}

.upload-card h3,
.music-card h3 {
  margin: 0;
  font-size: 1.45rem;
}

.muted {
  color: var(--text-secondary);
  margin: 0;
}

.upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.file-input {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-radius: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.file-input:hover {
  background: rgba(99, 102, 241, 0.18);
  transform: translateY(-1px);
}

.file-input input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.primary,
.accent,
.ghost {
  border: none;
  border-radius: 16px;
  padding: 12px 22px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.3s ease, background 0.2s ease;
}

.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  box-shadow: 0 16px 30px rgba(79, 70, 229, 0.28);
}

.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 36px rgba(79, 70, 229, 0.32);
}

.accent {
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-strong);
  border: 1px solid rgba(99, 102, 241, 0.24);
}

.accent:hover {
  background: rgba(99, 102, 241, 0.2);
}

.ghost {
  background: transparent;
  color: var(--accent-strong);
  border: 1px dashed rgba(99, 102, 241, 0.45);
}

.ghost:hover {
  background: rgba(99, 102, 241, 0.08);
}

.err {
  color: var(--danger);
  margin: 0;
  font-weight: 500;
}

.hint {
  margin: 0;
  color: var(--text-secondary);
  text-align: center;
}

.prompt-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.prompt-meta {
  display: grid;
  gap: 12px;
  margin: 0;
}

.prompt-meta div {
  display: grid;
  gap: 4px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.14);
}

.prompt-meta dt {
  margin: 0;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.prompt-meta dd {
  margin: 0;
  font-weight: 600;
}

.prompt-grid {
  display: grid;
  gap: 16px;
}

.prompt-box {
  display: grid;
  gap: 8px;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.prompt-box textarea {
  width: 100%;
  resize: vertical;
  min-height: 112px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(248, 250, 252, 0.95);
  font-family: "JetBrains Mono", "Fira Code", "SFMono-Regular", ui-monospace, monospace;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-primary);
}

.prompt-box textarea:focus {
  outline: 3px solid rgba(99, 102, 241, 0.25);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12);
}

.reader-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 0;
  overflow: hidden;
}

.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.pager-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  text-decoration: none;
  color: var(--accent-strong);
  background: rgba(99, 102, 241, 0.08);
  transition: background 0.2s ease, transform 0.2s ease;
}

.pager-button:hover {
  background: rgba(99, 102, 241, 0.16);
  transform: translateY(-1px);
}

.pager-button[aria-disabled="True"],
.pager-button[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

.pager-label {
  font-weight: 600;
}

.pager-input {
  width: 90px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.45);
  font-size: 1rem;
  background: rgba(255, 255, 255, 0.92);
}

.pager-total {
  color: var(--text-secondary);
}

.page-content {
  background: rgba(255, 255, 255, 0.92);
  border-radius: 24px;
  padding: clamp(24px, 3vw, 40px);
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
  font-size: 1.08rem;
  line-height: 1.75;
  overflow-y: auto;
  scroll-behavior: smooth;
  flex: 1;
  min-height: 0;
}

.page-content:focus {
  outline: 3px solid rgba(99, 102, 241, 0.22);
  box-shadow: 0 0 0 6px rgba(99, 102, 241, 0.12);
}

.page-content p {
  margin: 0 0 1em;
}

.page-content .page {
  max-width: 64ch;
  margin: 0 auto;
}

.file-name {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  display: none;
}

.file-name.is-visible {
  display: block;
}

.hint-inline {
  text-align: left;
}

@media (max-width: 768px) {
  .app-shell {
    padding: 36px 18px 48px;
    height: auto;
  }

  .site-header {
    flex-direction: column;
    text-align: center;
    gap: 14px;
  }

  .glass-card {
    padding: 24px;
  }

  body {
    overflow: auto;
  }
}

@media (max-width: 1024px) {
  .page-wrapper {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
  }

  .card-grid {
    grid-template-rows: auto auto;
  }

  .music-card {
    overflow: scroll;
  }
}
