/* 谱曲页 */

.page-studio .landscape { height: 40vh; opacity: 0.7; }
.page-studio .plum { width: min(300px, 30vw); top: 56px; opacity: 0.75; }

/* ── top bar ── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px clamp(16px, 3vw, 36px);
  background: rgba(243, 234, 215, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar::after { /* thin vermilion rule under a dark rule, like a mounted border */
  content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 3px;
  border-top: 1px solid rgba(181, 54, 42, 0.35);
}
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-text { display: grid; line-height: 1.2; }
.brand-name { font-family: var(--font-xing); font-size: 26px; letter-spacing: 0.14em; white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--ink-3); letter-spacing: 0.08em; }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 14px; }
.user { font-variant-numeric: tabular-nums; color: var(--ink-2); letter-spacing: 0.04em; }

.health { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); font-family: var(--font-kai); }
.health .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-4); }
.health.is-ok .dot { background: #4f7d5c; box-shadow: 0 0 0 3px rgba(79, 125, 92, 0.18); }
.health.is-warn .dot { background: var(--gold); }
.health.is-down .dot { background: var(--zhu); box-shadow: 0 0 0 3px var(--zhu-wash); }

/* ── layout ── */
.studio {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: minmax(340px, 460px) minmax(0, 1fr);
  gap: clamp(18px, 2.4vw, 32px);
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px) clamp(14px, 3vw, 36px) 80px;
  align-items: start;
}

.panel {
  position: relative;
  padding: 26px clamp(18px, 2.4vw, 30px) 28px;
  background:
    url("/assets/img/paper-grain.svg"),
    linear-gradient(180deg, rgba(251, 246, 234, 0.94), rgba(246, 238, 220, 0.94));
  border: 1px solid rgba(120, 90, 50, 0.22);
  border-radius: 2px;
  box-shadow: var(--shadow), 0 0 0 5px rgba(235, 223, 198, 0.7), 0 0 0 6px rgba(120, 90, 50, 0.18);
}
.compose { position: sticky; top: 84px; max-height: calc(100vh - 104px); overflow-y: auto; scrollbar-width: thin; }

.panel-head { margin-bottom: 20px; }
.panel-title { display: flex; align-items: center; gap: 12px; font-size: 28px; letter-spacing: 0.3em; }
.panel-title::before {
  content: ""; width: 10px; height: 10px; background: var(--zhu); transform: rotate(45deg); flex-shrink: 0;
}
.panel-sub { margin-top: 2px; padding-left: 22px; font-size: 13px; color: var(--ink-3); }

.group { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
.group-title {
  display: flex; align-items: baseline; gap: 10px; padding: 0; margin-bottom: 10px;
  font-family: var(--font-kai); font-size: 15px; letter-spacing: 0.1em; color: var(--ink-2);
}
.group-title small { font-family: var(--font-song); font-size: 12px; color: var(--ink-3); letter-spacing: 0; }
.compose > .field { margin-bottom: 20px; }
.compose > .field + .field { margin-top: 0; }

/* presets */
.presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.preset {
  display: grid; justify-items: center; gap: 1px;
  padding: 10px 4px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 252, 244, 0.5);
  transition: border-color 0.2s, background 0.2s, transform 0.15s;
}
.preset:hover { border-color: var(--ink-3); transform: translateY(-1px); }
.preset-name { font-family: var(--font-kai); font-size: 16px; letter-spacing: 0.02em; white-space: nowrap; }
.preset-desc { font-size: 11px; line-height: 1.4; color: var(--ink-3); text-align: center; }
.preset[aria-pressed="true"] {
  border-color: var(--zhu);
  background: var(--zhu-wash);
  box-shadow: inset 0 0 0 1px var(--zhu);
}
.preset[aria-pressed="true"] .preset-name { color: var(--zhu-deep); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  padding: 3px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 244, 0.5);
  font-family: var(--font-kai);
  font-size: 15px;
  letter-spacing: 0.06em;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--ink-3); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper-light); }

.final-prompt {
  margin: -6px 0 20px;
  padding: 8px 12px;
  border-left: 2px solid var(--gold);
  background: rgba(165, 130, 74, 0.08);
  font-size: 12px; line-height: 1.6; color: var(--ink-3);
  word-break: break-word;
}
.final-prompt span { font-family: var(--font-kai); color: var(--ink-2); }
.final-prompt em { font-style: normal; font-size: 12.5px; color: var(--ink-2); }

/* segmented */
.segmented {
  display: inline-flex; width: 100%;
  border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden;
}
.segmented button {
  flex: 1; min-height: 36px;
  border: 0; border-left: 1px solid var(--line);
  background: transparent;
  font-family: var(--font-kai); font-size: 15px; letter-spacing: 0.1em;
  transition: background 0.15s, color 0.15s;
}
.segmented button:first-child { border-left: 0; }
.segmented button:hover { background: rgba(255, 255, 255, 0.4); }
.segmented button[aria-checked="true"] { background: var(--ink); color: var(--paper-light); }
.vocal-box { margin-top: 14px; }
.vocal-box .field { margin-bottom: 14px; }
.field-label > label { display: flex; align-items: baseline; gap: 10px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-2 .field + .field { margin-top: 0; }
.hint { margin: 6px 0 18px; font-size: 12px; color: var(--ink-3); }

.slider-field { margin-bottom: 16px; }
.slider-field .field-label { margin-bottom: 0; }
.slider-value { display: inline-flex; align-items: center; gap: 12px; font-family: var(--font-song); font-size: 13px; color: var(--ink-2); letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.check { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-3); cursor: pointer; }
.check input { accent-color: var(--zhu); margin: 0; }


.compose-footer {
  position: sticky; bottom: -28px; z-index: 2;
  margin: 0 calc(-1 * clamp(18px, 2.4vw, 30px)) -28px;
  padding: 18px clamp(18px, 2.4vw, 30px) 24px;
  background: linear-gradient(180deg, rgba(247, 240, 224, 0), rgba(247, 240, 224, 0.96) 30%);
}

/* ── works ── */
.works { min-height: 560px; }
.jobs { display: grid; gap: 18px; }

.empty { display: grid; justify-items: center; text-align: center; padding: 56px 20px 40px; color: var(--ink-3); }
.enso { width: 120px; height: 120px; margin-bottom: 18px; }
.enso path {
  fill: none; stroke: var(--ink); stroke-width: 7; stroke-linecap: round; opacity: 0.7;
  stroke-dasharray: 300; stroke-dashoffset: 300;
  filter: url(#brush);
  animation: enso-draw 2.2s 0.3s ease-out forwards;
}
@keyframes enso-draw { to { stroke-dashoffset: 0; } }
.empty-verse { font-family: var(--font-kai); font-size: 20px; letter-spacing: 0.2em; color: var(--ink-2); }
.empty-cite { margin-top: 4px; font-size: 12px; letter-spacing: 0.1em; }
.empty-tip { margin-top: 22px; font-size: 13px; }

/* job card */
.job {
  position: relative;
  padding: 18px 20px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 252, 244, 0.6);
  animation: job-in 0.35s ease-out;
}
@keyframes job-in { from { opacity: 0; transform: translateY(-6px); } }
.job.is-failed { border-color: rgba(181, 54, 42, 0.4); }

.job-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.job-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.job-title h3 { font-size: 21px; letter-spacing: 0.12em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-meta { font-size: 12px; color: var(--ink-3); letter-spacing: 0.03em; }
.job-actions { display: flex; gap: 8px; flex-shrink: 0; }
.job-prompt {
  margin: 10px 0 2px; font-size: 13px; color: var(--ink-2); line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.job-progress { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 16px; margin-top: 14px; }
.job-progress .ink-spin { grid-row: span 2; }
.stage { font-family: var(--font-kai); font-size: 15px; letter-spacing: 0.08em; color: var(--ink-2); display: flex; justify-content: space-between; gap: 10px; }
.stage small { font-family: var(--font-song); font-size: 12px; color: var(--ink-3); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.brush-bar { position: relative; height: 8px; border-radius: 4px; background: rgba(34, 30, 26, 0.08); overflow: hidden; }
.brush-bar span {
  position: absolute; inset: 0 auto 0 0; width: 4%;
  background: linear-gradient(90deg, rgba(34, 30, 26, 0.55), rgba(34, 30, 26, 0.9));
  border-radius: 4px;
  filter: url(#brush);
  transition: width 0.8s ease-out;
}
.ink-spin { width: 42px; height: 42px; }
.ink-spin circle {
  fill: none; stroke: var(--ink); stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 70 200; opacity: 0.75;
  transform-origin: 50% 50%;
  animation: spin 1.6s linear infinite;
  filter: url(#brush);
}
@keyframes spin { to { transform: rotate(360deg); } }

.job-error { margin-top: 12px; color: var(--zhu); font-size: 13px; }

/* clips */
.clips { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.clip {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.35);
  transition: border-color 0.2s, background 0.2s;
}
.clip.is-playing { border-color: rgba(181, 54, 42, 0.45); background: rgba(255, 250, 240, 0.8); }
.play {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; color: #fbefe2;
  background: radial-gradient(circle at 35% 30%, #c9483a, var(--zhu) 55%, var(--zhu-deep));
  box-shadow: 0 6px 14px -6px rgba(142, 39, 30, 0.8);
  transition: transform 0.1s;
}
.play:active { transform: scale(0.95); }
.play:disabled { background: var(--ink-4); box-shadow: none; }
.play svg { width: 20px; height: 20px; }
.clip-body { min-width: 0; }
.clip-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 2px; }
.clip-name { font-family: var(--font-kai); font-size: 17px; letter-spacing: 0.12em; white-space: nowrap; flex-shrink: 0; }
.clip-tags { font-size: 12px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clip-time { margin-left: auto; font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wave { display: block; width: 100%; height: 40px; cursor: pointer; }
.clip-actions { display: flex; gap: 4px; }
.icon-btn {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid transparent; border-radius: 50%;
  color: var(--ink-2); background: transparent; text-decoration: none;
}
.icon-btn:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.5); }
.icon-btn svg { width: 20px; height: 20px; }
.clip-error { grid-column: 2 / -1; color: var(--zhu); font-size: 13px; }

/* history */
.history { margin-top: 34px; }
.history-title {
  display: flex; align-items: center; gap: 14px;
  font-size: 18px; letter-spacing: 0.3em; color: var(--ink-2); margin-bottom: 10px;
}
.history-title::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line-strong), transparent); }
.history-list { list-style: none; margin: 0; padding: 0; }
.history-item {
  display: grid; grid-template-columns: 7.5em minmax(0, 1fr) auto; align-items: baseline; gap: 14px;
  width: 100%; padding: 10px 8px;
  border: 0; border-bottom: 1px dashed var(--line);
  background: transparent; text-align: left;
  transition: background 0.15s;
}
.history-item:hover { background: rgba(255, 255, 255, 0.45); }
.history-item[aria-current="true"] { background: var(--zhu-wash); }
.h-date { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.h-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-title b { font-family: var(--font-kai); font-weight: 400; font-size: 16px; letter-spacing: 0.08em; margin-right: 8px; }
.h-title span { font-size: 12px; color: var(--ink-3); }
.h-status { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.h-status.is-failed, .h-status.is-expired { color: var(--zhu); }
.h-status.is-pending { color: var(--gold); }

/* ── responsive ── */
@media (max-width: 960px) {
  .studio { grid-template-columns: 1fr; }
  .compose { position: relative; top: 0; max-height: none; overflow: visible; }
  .compose-footer { bottom: 0; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .presets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .page-studio .plum { display: none; }
}
@media (max-width: 560px) {
  .brand-sub, .health span { display: none; }
  .brand-name { font-size: 22px; letter-spacing: 0.08em; }
  .topbar-right { gap: 10px; }
  .presets { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2 .field + .field { margin-top: 14px; }
  .clip { grid-template-columns: auto minmax(0, 1fr); }
  .clip-actions { grid-column: 1 / -1; justify-content: flex-end; margin-top: -6px; }
  .history-item { grid-template-columns: minmax(0, 1fr) auto; }
  .h-date { grid-column: 1 / -1; }
  .job-head { flex-direction: column; }
}
