:root {
  --bg: #f7f9fc;
  --bg-soft: #eef3f9;
  --surface: #ffffff;
  --text: #111827;
  --body: #3f4b5d;
  --muted: #6e7989;
  --line: rgba(15, 20, 26, 0.12);
  --accent: #6721ff;
  --accent-strong: #5a1ae6;
  --accent-soft: rgba(103, 33, 255, 0.12);
  --blue: #4f9cff;

  /* Inter carries Latin, Noto Sans SC carries CJK. Keeping one stack for both
     avoids the squashed CJK fallback the previous display font produced. */
  --font: "Inter", "Noto Sans SC", system-ui, -apple-system, "PingFang SC",
    "Microsoft YaHei", sans-serif;

  --shadow-sm: 0 6px 18px rgba(15, 20, 26, 0.05);
  --shadow: 0 18px 50px rgba(15, 20, 26, 0.08);
  --header-h: 68px;
  --footer-h: 62px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  /* CJK needs noticeably more leading than Latin to avoid looking cramped. */
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 {
  /* Negative tracking squashes CJK glyphs, so headings stay at neutral. */
  letter-spacing: 0;
  line-height: 1.4;
  font-weight: 700;
}
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }
img { max-width: 100%; }
svg { display: block; flex: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); border: 0;
}

.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(680px 520px at 74% 12%, rgba(103, 33, 255, 0.14), transparent 68%),
    radial-gradient(560px 440px at 14% 4%, rgba(79, 156, 255, 0.10), transparent 70%),
    linear-gradient(180deg, #f7f9fc 0%, #eef3f9 45%, #f7f9fc 100%);
}

.container {
  width: 100%;
  max-width: 1080px;
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 2rem);
}

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(247, 249, 252, 0.85);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  min-height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
}
.brand {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-weight: 700; font-size: 1.05rem;
  letter-spacing: -0.02em; white-space: nowrap;
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(145deg, var(--accent), #9b6cff 55%, var(--blue));
  color: #fff;
  box-shadow: 0 8px 22px rgba(103, 33, 255, 0.28);
}
.nav { display: flex; align-items: center; gap: 1rem; }
.nav-user {
  color: var(--body); font-size: 0.925rem; max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  border: 1px solid transparent; border-radius: 999px;
  padding: 0.6rem 1.15rem; cursor: pointer;
  font-weight: 600; line-height: 1.2; letter-spacing: 0.01em;
  transition: transform .15s ease, filter .2s ease, background .2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: #fff;
  box-shadow: 0 10px 28px rgba(103, 33, 255, 0.26);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.75);
  border-color: var(--line); color: var(--text);
}
.btn-ghost:hover { background: #fff; }
.btn-sm { padding: 0.45rem 0.95rem; font-size: 0.9rem; }
.btn-lg { padding: 0.85rem 1.3rem; }
.btn-xs { padding: 0.32rem 0.7rem; font-size: 0.8rem; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- Hero ---------- */
.hero {
  display: flex; align-items: center;
  min-height: calc(100svh - var(--header-h) - var(--footer-h));
  padding-block: clamp(2.5rem, 7vw, 4.5rem);
}
.hero-inner {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
}
.badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  margin-bottom: 1.75rem;
  padding: 0.45rem 1rem; border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(103, 33, 255, 0.2);
  color: var(--muted);
  font-size: 0.875rem; line-height: 1.4; letter-spacing: 0.02em;
}
.badge svg { color: var(--accent); }

.hero-title {
  margin: 0 0 1.25rem;
  display: grid; gap: 0.45rem;
}
.hero-title-brand {
  /* Latin-only, so tight tracking reads as intentional here. */
  font-size: clamp(2rem, 5.6vw, 3.75rem);
  font-weight: 800; line-height: 1.12; letter-spacing: -0.03em;
  text-wrap: balance;
  background: linear-gradient(115deg, #111827 6%, var(--accent) 52%, var(--blue));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-title-main {
  font-size: clamp(1.5rem, 3.6vw, 2.25rem);
  font-weight: 700; line-height: 1.5; letter-spacing: 0.02em;
  color: var(--text);
}
.lede {
  max-width: 36rem; margin: 0 auto 2.5rem;
  color: var(--body);
  font-size: clamp(1rem, 1.5vw, 1.075rem);
  line-height: 1.85; letter-spacing: 0.01em;
  text-wrap: balance;
}

/* ---------- Export panel ---------- */
.export-panel { width: 100%; max-width: 680px; margin-inline: auto; }
.export-bar {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.4rem 0.4rem 1rem;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.export-icon { display: inline-flex; color: var(--muted); }
.export-bar input {
  flex: 1 1 auto; min-width: 0;
  border: 0; outline: none; background: transparent;
  padding: 0.85rem 0.25rem;
  font-size: 1rem; line-height: 1.5;
}
.export-bar input::placeholder { color: var(--muted); letter-spacing: 0.01em; }
.export-bar:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, white);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}
.btn-export {
  flex: none; height: 48px; padding-inline: 1.4rem; border-radius: 12px;
  font-size: 0.95rem;
}

.hint {
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 0.85rem; line-height: 1.7; word-break: break-all;
}
.quota-bar {
  margin-top: 1rem; padding-top: 0.9rem;
  border-top: 1px solid var(--line);
  display: flex; justify-content: center; align-items: center;
  gap: 0.4rem 1.5rem; flex-wrap: wrap;
  color: var(--muted); font-size: 0.9rem;
}
.quota-bar strong { color: var(--text); font-weight: 700; }
.quota-bar a { color: var(--accent); font-weight: 600; }

.status {
  margin-top: 1rem; padding: 0.85rem 1rem; border-radius: 12px;
  background: var(--accent-soft); color: #4c1d95;
  border: 1px solid rgba(103, 33, 255, 0.18);
  font-size: 0.92rem; line-height: 1.7; text-align: left;
}
.status.error {
  background: rgba(225, 29, 72, 0.08); color: #9f1239;
  border-color: rgba(225, 29, 72, 0.2);
}
.status.ok {
  background: rgba(16, 185, 129, 0.1); color: #065f46;
  border-color: rgba(16, 185, 129, 0.2);
}

.export-panel.has-preview {
  max-width: 860px;
  transition: max-width 0.28s ease;
}

.preview {
  margin-top: 1.15rem;
  display: grid;
  gap: 1rem;
  text-align: left;
}

.sheet {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: sheet-in 0.32s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.sheet-glow {
  position: absolute; inset: -20% -10% auto;
  height: 58%;
  background-size: cover; background-position: center;
  filter: blur(48px) saturate(1.15);
  opacity: 0.28;
  pointer-events: none;
}
.sheet-body { position: relative; padding: 1.25rem; }

.sheet-hero {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 1.35rem;
  align-items: start;
}
.sheet-cover-wrap {
  position: relative;
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(15, 20, 26, 0.16);
}
.sheet-cover {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  background: var(--bg-soft);
}
.sheet-cover-empty {
  background: linear-gradient(145deg, var(--accent), #9b6cff 50%, var(--blue));
}

.sheet-info { min-width: 0; }
.sheet-kicker {
  margin: 0 0 0.35rem;
  color: var(--accent);
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.sheet-info h3 {
  margin: 0 0 0.2rem;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  font-weight: 800; line-height: 1.3;
  overflow-wrap: anywhere;
}
.sheet-artist {
  color: var(--body);
  font-size: 0.975rem; font-weight: 600;
}

.sheet-facts {
  display: flex; flex-wrap: wrap; gap: 0.65rem 1.15rem;
  margin: 0.85rem 0 0; padding: 0;
}
.sheet-facts div { min-width: 4.5rem; }
.sheet-facts dt {
  color: var(--muted); font-size: 0.72rem; letter-spacing: 0.04em;
}
.sheet-facts dd {
  margin: 0.05rem 0 0;
  font-size: 0.92rem; font-weight: 600;
}

.sheet-tags {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin: 0.95rem 0 1.1rem;
}
.tag {
  padding: 0.2rem 0.65rem; border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(103, 33, 255, 0.14);
  color: var(--accent);
  font-size: 0.75rem; line-height: 1.55;
}

.sheet-lyrics {
  margin-top: 1.2rem;
  padding: 1rem 1.1rem 1.05rem;
  border-radius: 16px;
  background: rgba(247, 249, 252, 0.86);
  border: 1px solid var(--line);
}
.sheet-lyrics.is-empty {
  color: var(--muted); font-size: 0.9rem; text-align: center;
}
.sheet-lyrics-head h4 {
  margin: 0 0 0.7rem;
  font-size: 0.8rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.lyrics-scroll {
  max-height: 360px; overflow: auto;
  padding-right: 0.35rem;
}
.lyric-mark {
  margin: 1rem 0 0.35rem;
  color: var(--accent);
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
}
.lyric-mark:first-child { margin-top: 0; }
.lyric-line {
  margin: 0;
  color: var(--text);
  font-size: 0.975rem; line-height: 1.85;
}
.lyric-gap { height: 0.55rem; margin: 0; }

@keyframes sheet-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Capability cards ---------- */
.capability-grid {
  list-style: none; padding: 0;
  margin: 3rem auto 0; width: 100%; max-width: 920px;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem;
}
.capability-grid li {
  display: flex; flex-direction: column; align-items: center; gap: 0.8rem;
  padding: 1.4rem 1rem; border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  color: var(--body);
  font-size: 0.9rem; line-height: 1.65; letter-spacing: 0.01em;
}
.capability-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
}

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 1.15rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.footer-inner {
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.75rem 1.5rem; flex-wrap: wrap;
}
.footer-copy { line-height: 1.6; }
.footer-side { display: flex; align-items: center; gap: 1.25rem; }
.footer-status { display: inline-flex; align-items: center; gap: 0.5rem; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.16);
}

/* ---------- Login modal ---------- */
body.modal-open { overflow: hidden; }
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 20, 26, 0.45);
  backdrop-filter: blur(4px);
  animation: fade-in 0.18s ease both;
}
.modal-card {
  position: relative;
  width: min(400px, 100%);
  padding: 2.25rem 1.75rem 2rem;
  border-radius: 20px; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 30px 70px rgba(15, 20, 26, 0.22);
  animation: modal-rise 0.22s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
.modal-close {
  position: absolute; top: 0.85rem; right: 0.85rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: 0; border-radius: 9px; cursor: pointer;
  background: transparent; color: var(--muted);
  transition: background .2s ease, color .2s ease;
}
.modal-close:hover { background: rgba(15, 20, 26, 0.06); color: var(--text); }
.modal-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; margin-bottom: 1.1rem;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--accent), #9b6cff 55%, var(--blue));
  color: #fff;
  box-shadow: 0 12px 28px rgba(103, 33, 255, 0.3);
}
.modal-title {
  margin: 0 0 0.35rem;
  font-size: 1.5rem; line-height: 1.4; letter-spacing: 0.01em;
}
.modal-sub {
  color: var(--muted); font-size: 0.925rem; line-height: 1.7;
}
.modal-fine {
  margin-top: 0.9rem;
  color: var(--muted); font-size: 0.8rem; line-height: 1.7;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-rise {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

/* ---------- Login ---------- */
.login-section {
  min-height: calc(100svh - var(--header-h) - var(--footer-h));
  display: grid; place-items: center;
  padding: clamp(2.5rem, 7vw, 4.5rem) clamp(1rem, 4vw, 2rem);
}
.login-card {
  width: min(440px, 100%); padding: 2.25rem 1.75rem;
  border-radius: 18px; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.login-card .brand { justify-content: center; margin-bottom: 1.15rem; }
.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.55rem; line-height: 1.5; letter-spacing: 0.01em;
}
.login-card .lede { margin-bottom: 0.5rem; font-size: 0.975rem; }
.google-btn-wrap {
  display: flex; justify-content: center;
  margin: 1.5rem 0 0; min-height: 44px;
}
.admin-login-form { display: grid; gap: 0.9rem; margin-top: 1.3rem; text-align: left; }
.admin-login-form label {
  display: grid; gap: 0.4rem;
  color: var(--muted); font-size: 0.9rem;
}
.admin-login-form input {
  width: 100%; min-height: 50px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff;
  padding: 0.75rem 1rem; outline: none;
}
.admin-login-form input:focus {
  border-color: color-mix(in srgb, var(--accent) 45%, white);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.admin-login-body { background: var(--bg); min-height: 100vh; }

/* ---------- Admin ---------- */
.admin-body { background: var(--bg-soft); }
.admin-layout { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.admin-nav {
  padding: 1.3rem 1rem; border-right: 1px solid var(--line);
  background: #fff; display: flex; flex-direction: column; gap: 0.35rem;
}
.admin-nav .brand { margin-bottom: 1rem; }
.admin-label {
  margin: 0.4rem 0; color: var(--muted); font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.admin-nav a { padding: 0.62rem 0.75rem; border-radius: 10px; color: var(--body); }
.admin-nav a.active, .admin-nav a:hover { background: var(--accent-soft); color: var(--accent); }
.admin-who { margin-top: auto; color: var(--muted); font-size: 0.85rem; }
.admin-main { padding: 1.5rem clamp(1rem, 3vw, 2rem) 2.5rem; }
.admin-header h1 { margin: 0 0 0.3rem; font-size: 1.6rem; }
.admin-header p { margin-bottom: 1.4rem; color: var(--muted); }
.stat-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem; margin-bottom: 1.4rem;
}
.stat, .admin-panel {
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.stat { padding: 1.1rem 1.15rem; border-radius: 14px; }
.stat-label { display: block; margin-bottom: 0.3rem; color: var(--muted); font-size: 0.85rem; }
.stat strong { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.02em; }
.admin-panel { border-radius: 14px; padding: 1.1rem; }
.admin-panel h2 { margin: 0 0 0.85rem; font-size: 1.05rem; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td {
  text-align: left; padding: 0.75rem 0.55rem;
  border-bottom: 1px solid var(--line); vertical-align: top;
  line-height: 1.6;
}
th { color: var(--muted); font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8rem; }
.truncate { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.actions form { display: inline; }
.pill {
  display: inline-block; padding: 0.15rem 0.55rem;
  border-radius: 999px; font-size: 0.75rem;
  background: rgba(15, 20, 26, 0.06);
}
.pill.ok { background: rgba(16, 185, 129, 0.12); color: #047857; }
.pill.error { background: rgba(225, 29, 72, 0.1); color: #be123c; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .capability-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid { grid-template-columns: 1fr; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-nav {
    flex-direction: row; flex-wrap: wrap; align-items: center;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .admin-who { margin: 0; }
}
@media (max-width: 700px) {
  .nav-user { display: none; }
  .brand { font-size: 0.95rem; }
  .footer-inner { flex-direction: column; }
  .footer-meta { text-align: left; }
}
@media (max-width: 720px) {
  .sheet-hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .sheet-cover-wrap { width: min(220px, 70vw); }
  .sheet-facts { justify-content: center; }
  .sheet-tags { justify-content: center; }
  .sheet-lyrics { text-align: left; }
}
@media (max-width: 560px) {
  .capability-grid { grid-template-columns: 1fr; }
  .export-bar { flex-wrap: wrap; padding: 0.75rem; row-gap: 0.6rem; }
  .export-bar input { flex-basis: calc(100% - 2rem); }
  .btn-export { width: 100%; }
  .sheet-body { padding: 1rem; }
}
