@font-face {
  font-family: "GenEi LateGo";
  src: url("assets/fonts/genei-latin/GenEiLatin-Separate_v2.1/GenEiLateGoP_v2.ttf") format("truetype");
  font-display: swap;
}
:root {
  font-family: "Segoe UI", "Yu Gothic UI", sans-serif;
  color-scheme: dark;
  background: #07080c;
  color: #f4f5f7;
  --surface: rgba(19, 21, 28, .86);
  --surface-strong: #171920;
  --line: rgba(255, 255, 255, .09);
  --line-strong: rgba(255, 255, 255, .15);
  --muted: #8c919d;
  --mint: #7cf4d4;
  --pink: #ff7bad;
  --preview-viewport-height: 900px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 10% -10%, rgba(73, 52, 120, .24), transparent 32%),
    radial-gradient(circle at 92% 4%, rgba(31, 119, 111, .13), transparent 25%),
    #07080c;
}

main { width: min(1480px, 100%); margin: auto; padding: 26px 28px 18px; }

header { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.brand span { color: var(--mint); font-size: 10px; font-weight: 700; letter-spacing: .28em; }
h1 { margin: 6px 0 0; font-size: 34px; line-height: 1; letter-spacing: -.04em; }
header p { max-width: 460px; margin: 0; color: var(--muted); font-size: 13px; text-align: right; }

.drop-row { display: grid; grid-template-columns: 190px 190px 1fr; gap: 10px; margin-bottom: 12px; }
.drop {
  position: relative;
  display: grid;
  gap: 3px;
  min-height: 64px;
  padding: 13px 16px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: var(--surface);
  cursor: pointer;
  transition: border-color .18s, transform .18s, background .18s;
}
.drop:hover { transform: translateY(-1px); border-color: rgba(124, 244, 212, .48); background: rgba(24, 28, 35, .96); }
.drop.wav:hover { border-color: rgba(255, 123, 173, .48); }
.drop-kicker { color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .18em; }
.drop b { font-size: 14px; font-weight: 650; }
.drop.ust b { color: var(--mint); }
.drop.wav b { color: var(--pink); }
.drop input { position: absolute; inset: 0; display: block; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.drop-row strong { display: flex; align-items: center; justify-content: flex-end; padding: 0 16px; color: var(--muted); font-size: 12px; font-weight: 500; }

.toolbar {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--line);
}
.transport { grid-column: span 3; }
.view-tools { grid-column: span 2; }
.sliders { grid-column: span 3; }
.sync-tools { grid-column: span 2; }
.character-tools { grid-column: span 2; }
.lyric-tools { grid-column: span 5; }
.credit-tools { grid-column: span 7; }
.tool-group { display: flex; align-items: center; align-content: center; gap: 10px; flex-wrap: wrap; min-height: 88px; padding: 13px 15px; background: var(--surface); }
.group-label { width: 100%; color: #686e7a; font-size: 9px; font-weight: 700; letter-spacing: .2em; }
.button-row { display: flex; gap: 8px; flex-wrap: wrap; }
button, select, input[type=number] { font: inherit; }
.toolbar button, .range-row button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #1b1e26;
  color: #dfe2e8;
  cursor: pointer;
  transition: border-color .16s, background .16s, color .16s;
}
.toolbar button:hover:not(:disabled), .range-row button:hover:not(:disabled) { border-color: rgba(124, 244, 212, .38); background: #222630; color: #fff; }
.toolbar button.primary { border-color: rgba(124, 244, 212, .34); background: rgba(124, 244, 212, .12); color: var(--mint); }
.toolbar button:disabled, .range-row button:disabled { opacity: .32; cursor: not-allowed; }
#export, #exportPart { color: #ff9cc1; }
#exportX { color: #9ad9ff; }
#cancelExport { color: #ffb0a8; }

.tool-group label { display: flex; align-items: center; gap: 7px; color: #b7bbc5; font-size: 12px; }
.tool-group select, .tool-group input[type=number] {
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #151820;
  color: #eef0f4;
  padding: 0 9px;
}
.view-tools label { flex: 1; }
.view-tools select { min-width: 0; width: 100%; }
.sliders label:not(.check) { display: grid; flex: 1 1 118px; gap: 5px; }
.sliders label > span { display: flex; justify-content: space-between; gap: 12px; }
.sliders output { color: var(--mint); font-variant-numeric: tabular-nums; }
.check { flex: 1 0 100%; }
.sync-tools > label:first-of-type { display: grid; flex: 1; gap: 5px; }
.number-field { display: flex; }
.number-field input { width: 78px; }
.fade-field { display: grid !important; flex: 1 1 100%; gap: 5px !important; }
.fade-field > span { display: flex; justify-content: space-between; gap: 8px; width: 100%; }
.fade-field output { color: var(--mint); font-variant-numeric: tabular-nums; }
input[type=range] { min-width: 90px; accent-color: var(--mint); }
input[type=checkbox] { accent-color: var(--mint); }
.character-actions { display: flex; align-items: center; gap: 7px; width: 100%; }
.character-picker {
  position: relative;
  min-height: 34px;
  padding: 8px 10px;
  overflow: hidden;
  border: 1px solid rgba(124, 244, 212, .28);
  border-radius: 9px;
  background: rgba(124, 244, 212, .09);
  color: var(--mint) !important;
  cursor: pointer;
}
.character-picker input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.character-tools > label:not(.character-picker) { display: grid; flex: 1 1 100%; grid-template-columns: 64px 1fr; gap: 7px; }
.character-tools > label > span { display: flex; justify-content: space-between; white-space: nowrap; }
.character-tools output { color: var(--mint); font-variant-numeric: tabular-nums; }
.character-tools input[type=range] { width: 100%; min-width: 70px; }

.lyric-tools > label:not(.check) { flex: 1 1 190px; }
.lyric-tools select { flex: 1; min-width: 0; }
.lyric-tools .check { flex: 0 0 auto; }
.credit-tools { align-content: start; }
.credit-field { display: grid !important; flex: 1 1 200px; grid-template-columns: 56px 1fr; gap: 7px !important; align-items: center; }
.credit-field:has(> button) { grid-template-columns: 56px 1fr auto; }
.credit-field > button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #1b1e26;
  color: #b7bbc5;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.credit-field > button:hover { border-color: rgba(124, 244, 212, .38); color: var(--mint); }
.credit-field > span { color: #686e7a; font-size: 10px; letter-spacing: .06em; }
.credit-field input[type=text] {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: #151820;
  color: #eef0f4;
  font: inherit;
  font-size: 12px;
}
.credit-field input[type=text]::placeholder { color: #5a606b; }
.credit-field input[type=text]:focus { outline: none; border-color: rgba(124, 244, 212, .45); }

.project-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}
.project-info[hidden] { display: none; }
.pi-label { flex: none; color: #686e7a; font-size: 9px; font-weight: 700; letter-spacing: .2em; }
.pi-body { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.pi-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #151820;
  color: #c3c8d2;
  font: inherit;
  font-size: 11px;
  white-space: nowrap;
}
.pi-chip .pi-key { color: #686e7a; font-size: 9px; font-weight: 700; letter-spacing: .14em; }
.pi-chip .pi-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.pi-swatch { width: 10px; height: 10px; border-radius: 50%; box-shadow: 0 0 8px currentColor; background: currentColor; }
button.pi-chip { cursor: pointer; transition: border-color .16s, background .16s, color .16s; }
button.pi-chip:hover { border-color: rgba(124, 244, 212, .38); background: #1d222c; color: #fff; }
button.pi-chip[aria-pressed="true"] { border-color: rgba(124, 244, 212, .55); background: rgba(124, 244, 212, .1); color: #fff; }
.pi-hint { color: #686e7a; font-size: 10px; }

.range-row { display: grid; gap: 9px 16px; padding: 16px 4px 13px; }
.seek-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.seek-head em { margin-left: 10px; color: #5d636f; font-size: 10px; font-style: normal; }
.seek-head output { font-variant-numeric: tabular-nums; }

.timeline { --in: 0%; --out: 100%; --pos: 0%; display: grid; gap: 5px; }
.timeline[data-disabled="true"] { opacity: .35; pointer-events: none; }
.tl-track {
  position: relative;
  height: 46px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 1px, transparent 1px 100%) 0 0 / 10% 100%,
    linear-gradient(180deg, #151922, #0d1017);
  cursor: pointer;
  touch-action: none;
}
.tl-track:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.tl-shade { position: absolute; top: 0; bottom: 0; background: rgba(3, 5, 10, .62); pointer-events: none; }
.tl-shade.left { left: 0; width: var(--in); }
.tl-shade.right { right: 0; width: calc(100% - var(--out)); }
.tl-range {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--in);
  width: calc(var(--out) - var(--in));
  background: linear-gradient(180deg, rgba(124, 244, 212, .2), rgba(124, 244, 212, .05));
  box-shadow: inset 0 0 0 1px rgba(124, 244, 212, .3);
  pointer-events: none;
}
.tl-playhead { position: absolute; top: 0; bottom: 0; left: var(--pos); width: 2px; margin-left: -1px; background: var(--pink); box-shadow: 0 0 10px rgba(255, 123, 173, .85); pointer-events: none; }
.tl-playhead::before { content: ""; position: absolute; top: 0; left: -4px; border: 5px solid transparent; border-top-color: var(--pink); border-bottom: 0; }
.tl-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  width: 15px;
  border-radius: 5px;
  background: var(--mint);
  color: #062b23;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .06em;
  cursor: ew-resize;
  touch-action: none;
}
.tl-handle:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.tl-handle.in { left: var(--in); }
.tl-handle.out { left: var(--out); margin-left: -15px; }
.tl-handle b { transform: rotate(-90deg); }
.tl-ticks { position: relative; height: 13px; }
.tl-tick { position: absolute; top: 0; color: #5d636f; font-size: 9px; font-variant-numeric: tabular-nums; transform: translateX(-50%); white-space: nowrap; }
.tl-tick:first-child { transform: none; }
.tl-tick:last-child { transform: translateX(-100%); }

.range-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.range-actions output { min-width: 200px; color: var(--muted); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }

.stage-shell {
  position: relative;
  width: min(1120px, 100%, calc(var(--preview-viewport-height) * 1.25));
  aspect-ratio: 16 / 9;
  margin: auto;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #040509;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .42);
  transition: aspect-ratio .25s, width .25s;
}
.stage-shell::after { content: ""; position: absolute; inset: 0; border: 1px solid rgba(255,255,255,.035); border-radius: inherit; pointer-events: none; }
.stage-shell.vertical { width: min(360px, 100%, calc(var(--preview-viewport-height) * .34)); aspect-ratio: 9 / 16; }
.stage-shell.square { width: min(620px, 100%, calc(var(--preview-viewport-height) * .62)); aspect-ratio: 1; }
canvas { display: block; width: 100%; height: 100%; }
#empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 8px; text-align: center; color: #737986; pointer-events: none; }
#empty[hidden] { display: none; }
#empty b { color: #eff1f5; font-size: 22px; letter-spacing: .14em; }
#empty span { font-size: 12px; }
.export-dialog { position: absolute; z-index: 5; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(1, 3, 9, .76); backdrop-filter: blur(12px); }
.export-dialog[hidden] { display: none; }
.export-dialog-card { width: min(420px, 88%); padding: 32px; border: 1px solid rgba(124, 244, 212, .28); border-radius: 20px; background: rgba(14, 17, 26, .96); box-shadow: 0 24px 80px rgba(0, 0, 0, .52); text-align: center; }
.export-dialog-card h2 { margin: 14px 0 7px; color: #f4f6fa; font-size: 22px; }
.export-dialog-card p { margin: 0 0 18px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.export-dialog-card progress { display: block; width: 100%; height: 8px; margin: 0 0 22px; overflow: hidden; border: 0; border-radius: 999px; accent-color: var(--mint); }
.export-dialog-card .export-warning { margin: 0 0 20px; padding: 11px 12px; border: 1px solid rgba(255, 196, 116, .2); border-radius: 10px; background: rgba(255, 196, 116, .07); color: #e8c897; font-size: 11px; line-height: 1.7; }
.export-dialog-card button { min-height: 38px; padding: 9px 15px; border: 1px solid rgba(255, 176, 168, .3); border-radius: 10px; background: rgba(255, 176, 168, .08); color: #ffb0a8; font: inherit; cursor: pointer; }
.export-spinner { display: inline-block; width: 30px; height: 30px; border: 2px solid rgba(124, 244, 212, .16); border-top-color: var(--mint); border-radius: 50%; animation: export-spin .9s linear infinite; }
@keyframes export-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .export-spinner { animation: none; border-color: var(--mint); } }
footer { display: flex; justify-content: space-between; padding: 12px 4px 0; color: #555b67; font-size: 9px; letter-spacing: .13em; }
footer a { color: #6f7785; text-decoration: none; }
footer a:hover { color: var(--mint); }

@media (max-width: 1120px) {
  .toolbar { grid-template-columns: 1fr 1fr; }
  .transport, .view-tools, .sliders, .sync-tools, .character-tools { grid-column: auto; }
  .lyric-tools, .credit-tools { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  main { padding: 16px 12px; }
  header { align-items: start; flex-direction: column; gap: 8px; }
  header p { text-align: left; }
  .drop-row { grid-template-columns: 1fr 1fr; }
  .drop-row strong { grid-column: 1 / -1; justify-content: flex-start; padding: 5px 2px; }
  .toolbar { grid-template-columns: 1fr; }
  .tool-group { min-height: auto; }
  .project-info { align-items: start; flex-direction: column; gap: 8px; }
  .seek-head { flex-wrap: wrap; }
  .seek-head em { margin-left: 0; }
  .range-actions { justify-content: flex-start; }
  .range-actions output { width: 100%; text-align: left; }
  .stage-shell { max-height: none; border-radius: 12px; }
}
