:root {
  color-scheme: dark;
  --bg: #111111;
  --panel: #1a1a1a;
  --panel2: #171717;
  --text: #f3f3f3;
  --muted: #9a9a9a;
  --line: #343434;
  --accent: #e56a2e;
  --accent2: #c9703d;
  --danger: #d95845;
  --shadow: 0 22px 70px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Pretendard, "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background:
    linear-gradient(120deg, rgba(229, 106, 46, .12), transparent 34%),
    linear-gradient(230deg, rgba(217, 88, 69, .08), transparent 36%),
    var(--bg);
}

button, input, select { font: inherit; }
button, a.download { min-height: 42px; border: 0; border-radius: 4px; color: var(--text); text-decoration: none; }
button:disabled { cursor: not-allowed; opacity: .5; }

.shell { width: min(1280px, calc(100% - 32px)); margin: 0 auto; padding: 22px 0 30px; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px; align-items: end; min-height: 138px; padding: 16px 0 18px; }
.eyebrow, .section-label { margin: 0 0 8px; color: var(--accent); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 {
  max-width: 680px;
  font-size: clamp(28px, 2vw, 30px);
  line-height: 1.15;
  color: transparent;
  background: linear-gradient(90deg, #ffffff 0%, #f3f3f3 38%, #ff8a3d 100%);
  -webkit-background-clip: text;
  background-clip: text;
}
h2 { font-size: 1.35rem; }
.lede { max-width: 660px; margin: 10px 0 0; color: var(--muted); font-size: .86rem; line-height: 1.58; }
.version-line { margin: 12px 0 0; color: #7f8a92; font-size: .82rem; }
.version-line a { color: var(--accent); text-decoration: none; }
.version-line a:hover { text-decoration: underline; }
.version-line .support-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-left: 2px;
  padding: 2px 9px;
  border: 1px solid rgba(229, 106, 46, .42);
  border-radius: 999px;
  background: rgba(229, 106, 46, .09);
  color: #f0aa80;
  font-size: 11px;
  font-weight: 700;
  box-shadow: none;
  text-decoration: none;
}
.version-line .support-link:hover {
  background: rgba(245, 196, 94, .14);
  border-color: rgba(245, 196, 94, .58);
  color: #ffd977;
  text-decoration: none;
}
.meters { display: grid; grid-template-columns: repeat(3, 96px); gap: 8px; }
.meters div { padding: 11px 12px; border: 1px solid var(--line); border-radius: 4px; background: rgba(23, 23, 23, .72); }
.meters span, .meters strong { display: block; }
.meters span { color: var(--muted); font-size: .76rem; }
.meters strong { margin-top: 7px; font-size: 1.16rem; }

.workspace { display: grid; grid-template-columns: minmax(300px, 330px) minmax(0, 1fr); gap: 14px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 4px; background: rgba(26, 26, 26, .9); box-shadow: var(--shadow); }
.controls { position: sticky; top: 16px; display: grid; gap: 13px; padding: 14px; }
.controls.is-busy .control-group, .controls.is-busy .preset-summary, .controls.is-busy .dropzone { opacity: .62; }

.dropzone { position: relative; display: grid; min-height: 132px; place-items: center; border: 1px dashed #3d3d3d; border-radius: 4px; background: var(--panel2); transition: border-color .16s, transform .16s; }
.dropzone.is-over { border-color: var(--accent); transform: translateY(-1px); }
.dropzone input { position: absolute; inset: 0; opacity: 0; }
.upload-copy { display: grid; gap: 7px; justify-items: center; padding: 18px; text-align: center; }
.upload-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 4px; background: var(--accent); color: #111111; font-size: 1.8rem; font-weight: 800; }

small, .track-meta, .track-stats, .empty span, .field > span, .range-label, .queue-head p, .hint, .preset-summary p { color: var(--muted); }
.preset-summary { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 4px; background: rgba(23, 23, 23, .7); }
.preset-summary p { margin: 8px 0 0; line-height: 1.5; }
.preset-select-button { width: 100%; min-height: 46px; border: 1px solid rgba(229, 106, 46, .55); background: rgba(229, 106, 46, .12); color: var(--accent); font-size: .94rem; font-weight: 900; }
.preset-select-button:hover { background: rgba(229, 106, 46, .2); }
.control-group { display: grid; gap: 11px; }
.field { display: grid; gap: 9px; }
select, input[type=range] { width: 100%; }
select { min-height: 44px; border: 1px solid var(--line); border-radius: 4px; padding: 0 12px; color: var(--text); background: #151515; }
input[type=range] { accent-color: var(--accent); }
.range-label { display: flex; justify-content: space-between; gap: 12px; font-size: .92rem; }
.toggle { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.toggle input { width: 18px; height: 18px; accent-color: var(--accent); }
.hint { margin: 0; font-size: .82rem; line-height: 1.5; }

.secondary { border: 1px solid var(--line); background: transparent; }
.primary { background: var(--accent); color: #111111; font-weight: 800; }
.danger { color: var(--danger); }
.button-stack button:not(:disabled) {
  transition: transform .14s ease, background .14s ease, border-color .14s ease, color .14s ease, box-shadow .14s ease;
}
.button-stack button:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
}
.button-stack button:not(:disabled):active {
  transform: translateY(1px) scale(.99);
  box-shadow: none;
}
.button-stack .primary:not(:disabled):hover {
  background: #f07a3c;
}
.button-stack .secondary:not(:disabled):hover {
  border-color: rgba(229, 106, 46, .52);
  background: rgba(229, 106, 46, .1);
  color: var(--accent);
}
.button-stack .danger:not(:disabled):hover {
  border-color: rgba(217, 88, 69, .72);
  background: rgba(217, 88, 69, .14);
  color: #ffb7b7;
}
.danger.is-stopping {
  border-color: rgba(217, 88, 69, .9);
  background: rgba(217, 88, 69, .22);
  color: #ffd4d4;
  box-shadow: 0 0 0 3px rgba(217, 88, 69, .16);
  transform: translateY(1px) scale(.99);
  opacity: 1;
  animation: stopPulse .72s ease-in-out 2;
}
.button-stack { display: grid; gap: 8px; }

@keyframes stopPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(217, 88, 69, .16); }
  50% { box-shadow: 0 0 0 7px rgba(217, 88, 69, .08); }
}

.queue {
  min-height: 520px;
  padding: 14px;
  scrollbar-color: var(--accent2) #151515;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}
.queue::-webkit-scrollbar { width: 10px; }
.queue::-webkit-scrollbar-track {
  background: #151515;
  border-left: 1px solid #2b2b2b;
}
.queue::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  border: 2px solid #151515;
  border-radius: 4px;
}
.queue::-webkit-scrollbar-thumb:hover { background: #e56a2e; }
.queue-head { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.notice { margin-bottom: 12px; padding: 12px; border: 1px solid rgba(229, 106, 46, .28); border-radius: 4px; background: rgba(229, 106, 46, .08); color: #e7b08e; font-size: .9rem; line-height: 1.5; }
.status-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.status-grid span { min-height: 36px; display: flex; align-items: center; min-width: 0; padding: 0 10px; border: 1px solid var(--line); border-radius: 4px; background: #151515; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-wrap { height: 10px; overflow: hidden; border-radius: 4px; background: #151515; }
#progressBar { width: 0; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .22s; }
.track-list { display: grid; gap: 7px; margin: 12px 0 0; padding: 0; list-style: none; }
.track { position: relative; display: grid; gap: 7px; align-items: start; padding: 10px 36px 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: rgba(23, 23, 23, .78); }
.track-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: start; min-width: 0; }
.track-main { min-width: 0; }
.track-title-row { display: flex; align-items: center; justify-content: flex-start; gap: 8px; min-width: 0; }
.track-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .95rem; line-height: 1.22; }
.badge { flex: 0 0 auto; border-radius: 4px; padding: 3px 7px; background: #202020; color: var(--muted); font-size: .68rem; font-weight: 800; line-height: 1.25; }
.badge.ready { background: rgba(95, 162, 107, .16); color: #8fbd97; }
.badge.error { background: rgba(217, 88, 69, .18); color: var(--danger); }
.badge.is-processing {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-left: 8px;
  background: rgba(229, 106, 46, .14);
  color: #f0b992;
  box-shadow: 0 0 0 1px rgba(229, 106, 46, .12), 0 0 18px rgba(229, 106, 46, .08);
  animation: processingPulse 1.25s ease-in-out infinite;
}
.badge.is-processing::before {
  content: "";
  width: 10px;
  height: 10px;
  border: 2px solid rgba(240, 185, 146, .3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: processingSpin .72s linear infinite;
}
.delete-track {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;
  border: 1px solid rgba(217, 88, 69, .36);
  border-radius: 4px;
  background: rgba(217, 88, 69, .08);
  color: #ff9a9a;
  font-size: .95rem;
  font-weight: 900;
  line-height: 1;
  transition: transform .14s, border-color .14s, background .14s, color .14s, box-shadow .14s;
}
.delete-track:hover { transform: translateY(-1px); border-color: rgba(217, 88, 69, .78); background: rgba(217, 88, 69, .18); color: #ffd0d0; box-shadow: 0 8px 20px rgba(217, 88, 69, .12); }
.track-meta { margin-top: 4px; font-size: .76rem; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-stats { margin-top: 0; font-size: .76rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.track-actions { display: flex; flex-wrap: nowrap; justify-content: flex-end; gap: 5px; align-items: center; padding-right: 28px; }
.stop-track, .single-master, .download { display: inline-grid; min-width: 56px; min-height: 30px; place-items: center; padding: 0 8px; font-size: .78rem; line-height: 1; white-space: nowrap; transition: transform .14s, border-color .14s, background .14s, color .14s, box-shadow .14s; }
.single-master { min-width: 76px; }
.download { min-width: 62px; }
.stop-track { border: 1px solid var(--line); background: #151515; color: var(--muted); }
.single-master { border: 1px solid rgba(229, 106, 46, .42); background: rgba(229, 106, 46, .12); color: var(--accent); font-weight: 800; }
.download { background: var(--accent2); color: #111111; font-weight: 800; }
.stop-track:not(:disabled):hover { transform: translateY(-1px); border-color: rgba(229, 106, 46, .58); background: rgba(229, 106, 46, .12); color: #f0b992; box-shadow: 0 8px 20px rgba(229, 106, 46, .1); }
.single-master:not(:disabled):hover { transform: translateY(-1px); border-color: rgba(229, 106, 46, .78); background: rgba(229, 106, 46, .18); color: #f0b992; box-shadow: 0 8px 20px rgba(229, 106, 46, .12); }
.download:hover { transform: translateY(-1px); filter: brightness(1.08); box-shadow: 0 8px 22px rgba(229, 106, 46, .18); }

@keyframes processingSpin {
  to { transform: rotate(360deg); }
}

@keyframes processingPulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(229, 106, 46, .12), 0 0 12px rgba(229, 106, 46, .06); }
  50% { box-shadow: 0 0 0 1px rgba(229, 106, 46, .28), 0 0 22px rgba(229, 106, 46, .15); }
}
.empty { display: grid; min-height: 320px; place-items: center; align-content: center; gap: 10px; text-align: center; }
.waveform-panel {
  grid-column: 1 / -1;
  display: grid;
  gap: 5px;
  padding-top: 2px;
}
.waveform-panel[hidden] { display: none !important; }
.waveform-row[hidden] { display: none !important; }
.waveform-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #151515;
  color: var(--muted);
  text-align: left;
  transition: border-color .14s, background .14s, box-shadow .14s;
}
.waveform-row:not(:disabled):hover {
  border-color: rgba(229, 106, 46, .52);
  background: rgba(229, 106, 46, .08);
}
.waveform-row:disabled {
  cursor: not-allowed;
  opacity: .48;
}
.waveform-row.is-loading {
  opacity: .7;
}
.waveform-row.is-active {
  border-color: var(--accent);
  background: rgba(229, 106, 46, .12);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(229, 106, 46, .24);
}
.waveform-row span {
  font-size: .76rem;
  font-weight: 900;
}
.waveform-row canvas {
  width: 100%;
  height: 34px;
  display: block;
  border-radius: 4px;
  background: rgba(255, 255, 255, .025);
}
.transport { grid-column: 1 / -1; display: grid; grid-template-columns: 58px 72px 72px 58px auto; gap: 8px; align-items: center; padding-top: 4px; }
.transport[hidden], .empty[hidden] { display: none !important; }
.transport button { min-height: 34px; border: 1px solid var(--line); background: #151515; font-size: .82rem; }
.time-readout { color: var(--muted); font-size: .82rem; white-space: nowrap; }

.preset-modal { width: min(820px, calc(100vw - 28px)); border: 1px solid var(--line); border-radius: 4px; color: var(--text); background: #171717; box-shadow: var(--shadow); }
.preset-modal::backdrop { background: rgba(0, 0, 0, .62); }
.preset-modal form { display: grid; gap: 16px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.icon-button { width: 38px; height: 38px; min-height: 38px; border: 1px solid var(--line); background: #151515; font-size: 1.4rem; }
.preset-grid { display: grid; gap: 18px; }
.preset-category { display: grid; gap: 9px; }
.preset-category h3 { margin: 0; font-size: .96rem; color: var(--accent); }
.preset-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.preset-card { min-height: 82px; display: grid; align-content: center; gap: 6px; padding: 12px; border: 1px solid var(--line); background: #202020; text-align: left; }
.preset-card strong, .preset-card span { display: block; }
.preset-card span { color: var(--muted); font-size: .82rem; line-height: 1.35; }
.preset-card.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

@media (max-width: 920px) {
  .hero, .workspace { grid-template-columns: 1fr; }
  .meters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .controls { position: static; }
  .queue { max-height: none !important; overflow: visible !important; }
}

@media (max-width: 720px) {
  .shell { width: min(100% - 22px, 1180px); padding: 18px 0; }
  .hero { min-height: auto; padding-top: 14px; }
  .meters, .track, .status-grid, .preset-summary { grid-template-columns: 1fr; }
  .track { padding-right: 34px; }
  .track-top { grid-template-columns: 1fr; gap: 7px; }
  .track-actions { width: 100%; flex-wrap: wrap; justify-content: flex-start; padding-right: 0; }
  .stop-track, .single-master, .download { width: auto; min-width: 72px; }
  .waveform-row { grid-template-columns: 54px minmax(0, 1fr); }
  .transport { grid-template-columns: repeat(4, 1fr); }
  .time-readout { grid-column: 1 / -1; }
  .preset-cards { grid-template-columns: 1fr; }
}

/* Unified AI Convenience app menu */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 12px;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 0;
  isolation: isolate;
}

.app-nav::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  z-index: 0;
  width: 100vw;
  height: 100%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(5, 6, 8, .92), rgba(5, 6, 8, .28) 72%, rgba(5, 6, 8, 0));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  pointer-events: none;
}

.app-nav > * {
  position: relative;
  z-index: 1;
}

.app-nav-links {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.app-home-chip,
.app-nav-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 15px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 4px;
  background: rgba(255, 255, 255, .035);
  color: #dce4ef;
  text-decoration: none;
  font-size: 13px;
  font-weight: 850;
  letter-spacing: -0.02em;
  white-space: nowrap;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, color .16s ease;
}

.app-home-chip {
  color: #ff8a3d;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.app-home-chip:hover,
.app-nav-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 138, 61, .42);
  background: rgba(255, 138, 61, .08);
  color: #ffffff;
}

.app-nav-btn.is-active,
.app-nav-btn[aria-current="page"] {
  pointer-events: none;
  cursor: default;
  border-color: rgba(255, 138, 61, .62);
  background: rgba(255, 138, 61, .1);
  color: #ff8a3d;
  box-shadow: inset 0 0 0 1px rgba(255, 138, 61, .08);
}

@media (max-width: 700px) {
  .app-nav {
    align-items: stretch;
    flex-direction: column;
    width: min(100% - 22px, 560px);
  }

  .app-home-chip {
    min-height: 34px;
    width: fit-content;
  }

  .app-nav-links {
    width: 100%;
    justify-content: flex-start;
  }
}
