:root {
  color-scheme: dark;
  --bg: #0c0d0f;
  --panel: #171717;
  --panel-soft: #1c1c1c;
  --field: #111213;
  --line: #353535;
  --line-soft: #2b2b2b;
  --text: #f4f4f2;
  --muted: #9ca1a8;
  --accent: #e56a2e;
  --accent-soft: #f0a277;
  --danger: #e56a60;
  --shadow: 0 24px 70px rgba(0, 0, 0, .38);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(rgba(255, 255, 255, .018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .018) 1px, transparent 1px),
    radial-gradient(circle at 16% 4%, rgba(229, 106, 46, .09), transparent 29%),
    #101010;
  background-size: 36px 36px, 36px 36px, auto, auto;
  font-family: "Pretendard", "Noto Sans KR", "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border-radius: 4px;
}

button,
.file-button {
  transition: border-color .16s ease, background .16s ease, color .16s ease, transform .16s ease;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
.file-button:focus-visible,
.drag-handle:focus-visible {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(229, 106, 46, .16);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  width: min(1280px, calc(100% - 32px));
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 auto;
  padding: 12px 0 10px;
}

.app-nav::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: 0 0 auto;
  height: 62px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(13, 13, 13, .9);
  backdrop-filter: blur(18px);
}

.app-home-chip,
.app-nav-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .13);
  border-radius: 4px;
  background: rgba(255, 255, 255, .035);
  color: #dce4ef;
  text-decoration: none;
  font-size: 12px;
  font-weight: 850;
  letter-spacing: -.02em;
}

.app-home-chip {
  flex: 0 0 auto;
  color: #ff8a3d;
  font-weight: 950;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.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: #fff;
}

.app-nav-links {
  min-width: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.app-nav-btn.is-active,
.app-nav-btn[aria-current="page"] {
  pointer-events: none;
  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);
}

.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(350px, .74fr) minmax(0, 1.26fr);
  gap: 16px;
  align-items: start;
}

.settings-panel,
.output-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(23, 23, 23, .96);
  box-shadow: var(--shadow);
}

.settings-panel {
  display: grid;
  gap: 14px;
  padding: 20px;
}

.output-panel {
  padding: 22px;
}

.package-intro {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.version-label {
  display: inline-block;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.package-intro h1,
.output-heading h2,
.preview-heading h3,
.section-heading h2 {
  margin: 0;
  letter-spacing: -.04em;
}

.package-intro h1 {
  font-size: clamp(25px, 2.3vw, 32px);
}

.package-intro > p:not(.app-meta) {
  margin: 8px 0 0;
  color: #a4a9b0;
  font-size: 13px;
  line-height: 1.65;
  word-break: keep-all;
}

.app-meta {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.app-meta > a:not(.support-link) {
  color: var(--accent-soft);
}

.app-meta .support-link {
  margin-left: 7px;
}

.local-notice {
  display: grid;
  gap: 3px;
  margin-top: 14px;
  padding: 11px 12px;
  border: 1px solid rgba(229, 106, 46, .28);
  border-radius: 4px;
  background: rgba(229, 106, 46, .06);
}

.local-notice strong {
  font-size: 13px;
}

.local-notice span {
  color: #969da6;
  font-size: 11px;
  line-height: 1.5;
}

.setting-section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #343434;
  border-radius: 4px;
  background: rgba(20, 20, 20, .76);
}

.section-heading {
  padding-bottom: 10px;
  border-bottom: 1px solid #303030;
}

.section-heading > span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.section-heading h2 {
  margin-top: 3px;
  font-size: 16px;
}

.dropzone {
  position: relative;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 22px;
  text-align: center;
  border: 1px dashed rgba(229, 106, 46, .46);
  background:
    radial-gradient(circle at center, rgba(229, 106, 46, .08), transparent 66%),
    #121212;
}

.dropzone.is-dragover {
  border-color: #ff985f;
  background: rgba(229, 106, 46, .12);
  box-shadow: inset 0 0 0 1px rgba(229, 106, 46, .18);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-icon {
  width: 56px;
  height: 48px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 5px;
  margin-bottom: 3px;
}

.upload-icon i {
  width: 5px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f2a275, #c34e20);
}

.upload-icon i:nth-child(1) { height: 24px; }
.upload-icon i:nth-child(2) { height: 42px; }
.upload-icon i:nth-child(3) { height: 31px; }

.dropzone strong {
  font-size: 14px;
}

.dropzone > span {
  color: var(--muted);
  font-size: 11px;
}

.file-button,
.action-grid button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, .14);
  background: #181818;
  color: #f5f5f5;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.file-button {
  margin-top: 5px;
  padding: 0 18px;
  border-color: rgba(229, 106, 46, .52);
  background: rgba(229, 106, 46, .1);
}

.file-button:hover,
.action-grid button:hover:not(:disabled) {
  border-color: rgba(240, 162, 119, .75);
  background: rgba(229, 106, 46, .15);
  transform: translateY(-1px);
}

.privacy-note {
  margin: 0;
  color: #8f949b;
  font-size: 11px;
  line-height: 1.55;
}

.field-grid {
  display: grid;
  gap: 10px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: #d9dadd;
  font-size: 12px;
  font-weight: 800;
}

.field input,
.field select,
.track-row input {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid #393939;
  background: var(--field);
  color: var(--text);
}

.field input[aria-invalid="true"],
.track-duration-input[aria-invalid="true"] {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(229, 106, 96, .12);
}

.field-error {
  min-height: 0;
  color: #ff928b;
  font-size: 10px;
  font-weight: 600;
  line-height: 1.4;
}

.field-error:empty {
  display: none;
}

.check-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.check-list.single-option {
  grid-template-columns: 1fr;
}

.check-list label {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #303030;
  background: #141414;
  color: #c8cbd0;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.check-list input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.header-field[hidden] {
  display: none;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.action-grid .primary-action {
  border-color: #c85723;
  background: linear-gradient(180deg, #d87543, #bd5728);
  color: #fff;
}

.action-grid .danger-action {
  border-color: rgba(229, 106, 96, .35);
  color: #ffaaa4;
}

.action-grid button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.action-status {
  min-height: 20px;
  margin: -3px 0 0;
  color: var(--accent-soft);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.55;
}

.action-status.is-error {
  color: #ff928b;
}

.action-status.is-success {
  color: #79dbb2;
}

.leave-dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 1px solid rgba(229, 106, 46, .48);
  background: #171717;
  color: var(--text);
  box-shadow: 0 28px 90px rgba(0, 0, 0, .72);
}

.leave-dialog::backdrop {
  background: rgba(5, 5, 5, .76);
  backdrop-filter: blur(5px);
}

.leave-dialog-card {
  padding: 26px;
  border-top: 3px solid var(--accent);
}

.leave-dialog h2 {
  margin-top: 8px;
  font-size: clamp(22px, 4vw, 30px);
}

.leave-dialog p {
  margin: 12px 0 22px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.leave-dialog-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.leave-dialog-actions button {
  min-height: 42px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: #111;
  color: #f5f5f5;
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.leave-dialog-actions button:hover {
  border-color: rgba(240, 162, 119, .75);
}

.leave-dialog-actions .leave-confirm {
  border-color: rgba(229, 106, 96, .5);
  color: #ffaaa4;
}

body:has(.leave-dialog[open]) {
  overflow: hidden;
}

.output-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.output-heading h2 {
  font-size: clamp(24px, 2.5vw, 34px);
}

.output-heading p {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.track-summary {
  min-width: 88px;
  display: grid;
  place-items: center;
  padding: 11px 16px;
  border: 1px solid rgba(229, 106, 46, .32);
  background: rgba(229, 106, 46, .06);
}

.track-summary strong {
  font-size: 22px;
  line-height: 1;
}

.track-summary span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.track-list-shell {
  min-height: 290px;
  margin-top: 16px;
}

.track-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.track-row {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 30px 34px minmax(170px, 1fr) minmax(118px, 140px) auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line-soft);
  background: #151515;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
}

.track-row:hover {
  border-color: #414141;
  background: #181818;
}

.track-row.is-dragging {
  opacity: .56;
  transform: scale(.993);
  border-color: rgba(229, 106, 46, .6);
}

.track-row.drop-before::before,
.track-row.drop-after::after {
  content: "";
  position: absolute;
  z-index: 3;
  right: 7px;
  left: 7px;
  height: 2px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(229, 106, 46, .7);
}

.track-row.drop-before::before { top: -5px; }
.track-row.drop-after::after { bottom: -5px; }

.drag-handle {
  width: 30px;
  height: 40px;
  display: grid;
  grid-template-columns: repeat(2, 4px);
  grid-template-rows: repeat(3, 4px);
  place-content: center;
  gap: 4px;
  padding: 0;
  border: 1px solid transparent;
  background: transparent;
  cursor: grab;
}

.drag-handle:active {
  cursor: grabbing;
}

.drag-handle span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #85898f;
}

.track-number {
  color: var(--accent-soft);
  font-size: 12px;
  font-weight: 950;
  text-align: center;
}

.track-title-field,
.track-duration-field {
  min-width: 0;
}

.track-duration-field {
  position: relative;
  display: grid;
  gap: 3px;
}

.duration-label {
  display: none;
}

.track-row input {
  min-height: 40px;
  font-size: 12px;
}

.track-duration-input {
  font-variant-numeric: tabular-nums;
}

.track-duration-input:disabled {
  color: #888d94;
  opacity: 1;
}

.duration-status {
  min-height: 12px;
  color: #8e949c;
  font-size: 9px;
  line-height: 1.2;
}

.duration-status.is-error {
  color: #ff928b;
}

.track-actions {
  display: flex;
  align-items: center;
  gap: 5px;
}

.track-actions button {
  width: 34px;
  height: 36px;
  padding: 0;
  border: 1px solid #383838;
  background: #111;
  color: #d5d8dc;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}

.track-actions button:hover:not(:disabled) {
  border-color: rgba(229, 106, 46, .55);
  color: #fff;
}

.track-actions button:disabled {
  opacity: .28;
  cursor: not-allowed;
}

.track-actions .delete-track {
  border-color: rgba(229, 106, 96, .3);
  color: #ff9189;
}

.empty-state {
  min-height: 290px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
  border: 1px dashed #303030;
  background: rgba(15, 15, 15, .52);
}

.empty-state[hidden] {
  display: none;
}

.empty-visual {
  height: 58px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 14px;
}

.empty-visual span {
  width: 6px;
  border-radius: 999px;
  background: #474747;
}

.empty-visual span:nth-child(1) { height: 22px; }
.empty-visual span:nth-child(2) { height: 46px; background: #ad5127; }
.empty-visual span:nth-child(3) { height: 34px; }
.empty-visual span:nth-child(4) { height: 18px; }

.empty-state strong {
  font-size: 16px;
}

.empty-state p {
  max-width: 410px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.preview-panel {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  background: #121212;
}

.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.preview-heading h3 {
  font-size: 18px;
}

.preview-state {
  padding: 6px 9px;
  border: 1px solid #343434;
  color: #a8adb4;
  font-size: 10px;
  font-weight: 850;
}

#tracklistPreview {
  min-height: 210px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  border: 1px solid #2e2e2e;
  background: #0d0d0d;
  color: #e9e9e7;
  font: 13px/1.75 "Cascadia Mono", "Noto Sans Mono CJK KR", Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 1080px) {
  .track-row {
    grid-template-columns: 30px 34px minmax(140px, 1fr) 120px;
  }

  .track-actions {
    grid-column: 3 / -1;
    justify-content: flex-end;
  }
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-nav {
    position: relative;
    min-height: 0;
    align-items: stretch;
    flex-direction: column;
    padding-top: 10px;
  }

  .app-nav::before {
    display: none;
  }

  .app-nav-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-nav-btn {
    padding: 0 9px;
    text-align: center;
  }

  .output-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .track-summary {
    width: 100%;
    grid-template-columns: auto auto;
    justify-content: center;
    gap: 7px;
  }
}

@media (max-width: 620px) {
  .app-shell,
  .app-nav {
    width: min(100% - 22px, 560px);
  }

  .settings-panel,
  .output-panel {
    padding: 15px;
  }

  .two-columns,
  .check-list,
  .action-grid {
    grid-template-columns: 1fr;
  }

  .leave-dialog-actions {
    grid-template-columns: 1fr;
  }

  .track-row {
    grid-template-columns: 30px 32px minmax(0, 1fr);
    align-items: start;
  }

  .track-number {
    padding-top: 13px;
  }

  .track-duration-field {
    grid-column: 3;
  }

  .duration-label {
    display: block;
    color: #8f949b;
    font-size: 10px;
  }

  .track-actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
    padding-top: 2px;
    border-top: 1px solid #282828;
  }

  .preview-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
