:root {
  color-scheme: light;
  --ink: #171717;
  --paper: #fafaf8;
  --muted: #686864;
  --line: #d8d8d2;
  --accent: #0d6b43;
  --danger: #b4232b;
  font-family: "Pretendard Variable", Pretendard, "Noto Sans KR", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  min-width: 0;
  font-size: 18.667px;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  word-break: keep-all;
  overflow-wrap: break-word;
}

button,
textarea { font: inherit; }

button,
a { -webkit-tap-highlight-color: transparent; }

button:focus-visible,
a:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.page-shell {
  width: min(960px, calc(100% - 64px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

.site-header {
  display: block;
}

.brand {
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 760;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.workspace-heading p,
footer p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

main { margin-top: clamp(100px, 17vw, 180px); }

.workspace { max-width: 760px; }

.workspace-heading h1 {
  max-width: 12ch;
  margin: 0;
  font-size: clamp(2.8rem, 7vw, 5.3rem);
  font-weight: 670;
  line-height: 1.04;
  letter-spacing: -0.055em;
}

.workspace-heading p {
  margin-top: 28px;
  max-width: 34ch;
}

.link-form { margin-top: 72px; }

.link-form label,
.field-label,
.result-type {
  display: block;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 540;
}

.link-form label { margin-bottom: 12px; }

textarea {
  display: block;
  width: 100%;
  min-height: 132px;
  resize: vertical;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  padding: 20px 0;
  color: var(--ink);
  background: transparent;
  font-size: 1rem;
  line-height: 1.55;
  word-break: break-all;
  overflow-wrap: anywhere;
}

textarea::placeholder { color: #969690; }

.form-actions,
.result-actions,
.track-actions {
  display: flex;
  align-items: center;
  gap: 24px;
}

.form-actions {
  justify-content: flex-end;
  margin-top: 22px;
}

.primary-button,
.text-button {
  border-radius: 0;
  font-size: 1rem;
  font-weight: 620;
  cursor: pointer;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 48px;
  min-width: 190px;
  border: 1px solid var(--ink);
  padding: 14px 16px;
  color: var(--paper);
  background: var(--ink);
}

.primary-button:hover { background: var(--accent); }

.primary-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.text-button {
  border: 0;
  border-bottom: 1px solid currentColor;
  padding: 5px 0;
  color: var(--ink);
  background: transparent;
}

.text-button:hover,
.text-button.emphasized,
.youtube-link { color: var(--accent); }

.status-panel,
.error-panel {
  display: flex;
  align-items: center;
  gap: 18px;
  max-width: 760px;
  margin-top: 64px;
}

.status-panel[hidden],
.error-panel[hidden],
.result-panel[hidden],
.toast[hidden] { display: none; }

.status-panel p,
.error-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.spinner {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.error-panel { color: var(--danger); }

.error-panel > strong {
  font-size: 1.5rem;
  line-height: 1;
}

.error-panel h2 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.result-panel { margin-top: clamp(120px, 20vw, 220px); }

.result-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 40px;
}

.result-heading { min-width: 0; }

.result-heading h2 {
  margin: 12px 0 0;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 660;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.result-heading > p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.result-actions { flex: 0 0 auto; }

.table-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 24px;
  margin-top: 64px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--ink);
}

.table-toolbar p { margin: 0; }

.youtube-link {
  font-size: 1rem;
  font-weight: 560;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
}

.track-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.track-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}

.track-number {
  align-self: start;
  padding-top: 4px;
  color: var(--muted);
  font-size: 1rem;
}

.track-copy-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 32px;
  min-width: 0;
}

.track-list[data-order="artist-first"] .track-copy-fields {
  grid-template-columns: minmax(0, 0.75fr) minmax(0, 1.25fr);
}

.text-field {
  min-width: 0;
  border: 0;
  padding: 0;
  text-align: left;
  color: var(--ink);
  background: transparent;
  cursor: copy;
}

.text-field:hover .field-value { color: var(--accent); }

.field-label { margin-bottom: 7px; }

.field-value {
  display: block;
  min-width: 0;
  font-size: 1rem;
  font-weight: 620;
  line-height: 1.45;
  white-space: normal;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.title-value-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.explicit-badge {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
}

.track-actions { justify-content: flex-end; }

.result-notice {
  margin: 28px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.55;
}

footer {
  margin-top: 160px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.ai-guide { margin-bottom: 18px; }

.ai-guide summary {
  display: inline-block;
  border-bottom: 1px solid currentColor;
  padding: 5px 0;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 620;
  cursor: pointer;
}

.ai-guide summary:hover { color: var(--accent); }

.ai-guide ol {
  margin: 16px 0 0;
  padding-left: 1.4em;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

.ai-guide li + li { margin-top: 8px; }

.ai-guide code {
  color: var(--ink);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.ai-guide code.prompt {
  display: block;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid var(--line);
}

.ai-guide p { margin: 12px 0 0; color: var(--muted); }

.ai-advanced { margin-top: 16px; }

.ai-advanced summary {
  display: inline-block;
  padding: 0;
  border-bottom: 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
}

.ai-advanced ul {
  margin: 12px 0 0;
  padding-left: 1.4em;
  color: var(--muted);
  line-height: 1.7;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 10;
  max-width: min(520px, calc(100vw - 40px));
  padding: 13px 18px;
  color: var(--paper);
  background: var(--ink);
  font-size: 1rem;
  font-weight: 560;
  transform: translateX(-50%);
}

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

@media (max-width: 720px) {
  .page-shell {
    width: calc(100% - 36px);
    padding-top: 24px;
  }

  main { margin-top: 100px; }

  .workspace-heading h1 {
    max-width: 9ch;
    font-size: clamp(2.7rem, 14vw, 4.2rem);
  }

  .link-form { margin-top: 56px; }

  .result-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .table-toolbar { margin-top: 48px; }

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

  .track-copy-fields,
  .track-list[data-order="artist-first"] .track-copy-fields {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .track-actions {
    grid-column: 2;
    justify-content: flex-start;
  }

  footer { margin-top: 110px; }
}

@media (max-width: 420px) {
  .form-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .form-actions .text-button { align-self: flex-start; }
  .primary-button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
