:root {
  --bg: #f3efe5;
  --bg-soft: #ebe4d6;
  --ink: #17201d;
  --muted: #68716b;
  --line: #d7cfbe;
  --field: #fffaf0;
  --green: #244c43;
  --green-2: #2f6b5e;
  --blue: #486a78;
  --amber: #bd8738;
  --danger: #a64e3f;
  --shadow: 0 18px 50px rgba(35, 43, 37, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(72, 106, 120, 0.12), transparent 34rem),
    linear-gradient(225deg, rgba(189, 135, 56, 0.16), transparent 30rem),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 1.05rem;
  height: 1.05rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(16rem, 21rem) minmax(0, 1fr);
  min-height: 100vh;
}

.history-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding: 1.4rem;
  background: rgba(23, 32, 29, 0.94);
  color: #f8f1e6;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-block h1,
.input-band h2,
.history-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo {
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.brand-block h1 {
  max-width: 12rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2rem;
  line-height: 1;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--amber);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.history-head h2 {
  font-size: 1rem;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  color: #f8f1e6;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
}

.history-list {
  display: grid;
  gap: 0.55rem;
}

.history-item {
  width: 100%;
  padding: 0.7rem 0.75rem;
  color: #f8f1e6;
  text-align: left;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item:hover,
.history-item:focus-visible,
.icon-button:hover,
.icon-button:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  outline: none;
}

.empty-copy {
  margin: 0;
  color: rgba(248, 241, 230, 0.62);
  font-size: 0.9rem;
  line-height: 1.45;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 1rem;
  min-width: 0;
  padding: 1.2rem;
}

.input-band {
  display: grid;
  grid-template-columns: minmax(12rem, 24rem) minmax(18rem, 1fr);
  align-items: end;
  gap: 1rem;
  padding: 1rem;
  background: rgba(255, 250, 240, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-band h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.75rem;
  line-height: 1.05;
}

.link-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
}

.link-form input {
  min-width: 0;
  height: 2.9rem;
  padding: 0 0.9rem;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.link-form input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(72, 106, 120, 0.18);
}

.primary-button,
.download-button,
.match-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 2.9rem;
  padding: 0 1rem;
  color: #fffaf0;
  background: var(--green);
  border: 1px solid rgba(23, 32, 29, 0.08);
  border-radius: 8px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button:hover,
.download-button:hover,
.match-button:hover,
.primary-button:focus-visible,
.download-button:focus-visible,
.match-button:focus-visible {
  background: var(--green-2);
  outline: none;
}

.primary-button:disabled,
.download-button:disabled,
.match-button:disabled {
  cursor: wait;
  opacity: 0.62;
}

.match-button {
  color: var(--green);
  background: transparent;
  border-color: var(--line);
}

.match-button:hover,
.match-button:focus-visible {
  color: #fffaf0;
}

.status-line {
  min-height: 2.4rem;
  padding: 0.65rem 0.9rem;
  color: var(--muted);
  background: rgba(255, 250, 240, 0.55);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-line.error {
  color: var(--danger);
  border-color: rgba(166, 78, 63, 0.35);
}

.preview-panel {
  min-width: 0;
}

.initial-state {
  display: grid;
  place-items: center;
  gap: 1rem;
  min-height: 22rem;
  padding: 2rem;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 250, 240, 0.5);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.initial-mark {
  width: 4rem;
  height: 4rem;
  background:
    linear-gradient(90deg, var(--green) 45%, transparent 45%),
    linear-gradient(var(--amber) 45%, transparent 45%),
    var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.result-head h2 {
  margin: 0.15rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  line-height: 1.12;
}

.result-summary {
  margin: 0;
  color: var(--muted);
}

.track-list {
  display: grid;
  gap: 0.75rem;
}

.track-row {
  display: grid;
  grid-template-columns: minmax(15rem, 1.05fr) minmax(16rem, 1fr) auto;
  align-items: center;
  gap: 0.9rem;
  padding: 0.75rem;
  background: rgba(255, 250, 240, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.track-main,
.match-block {
  display: grid;
  grid-template-columns: 4.25rem minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.cover,
.match-cover {
  width: 4.25rem;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.track-copy,
.match-copy {
  min-width: 0;
}

.track-index,
.match-label {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.track-row h3,
.track-row h4,
.artist-line,
.match-artist {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-row h3,
.track-row h4 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.2;
}

.track-row h4 {
  color: var(--green);
}

.artist-line,
.match-artist {
  margin: 0.22rem 0;
  color: var(--muted);
}

.meta-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.duration-delta {
  color: var(--blue);
  font-weight: 800;
}

.track-actions {
  display: grid;
  justify-items: end;
  gap: 0.45rem;
}

.secondary-link {
  color: var(--blue);
  font-size: 0.84rem;
  font-weight: 800;
  text-decoration: none;
}

.secondary-link:hover,
.secondary-link:focus-visible {
  text-decoration: underline;
}

[hidden] {
  display: none !important;
}

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

  .history-panel {
    min-height: auto;
    border-right: 0;
  }

  .history-list {
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  }

  .input-band,
  .track-row {
    grid-template-columns: 1fr;
  }

  .track-actions {
    grid-template-columns: 1fr auto;
    align-items: center;
    justify-items: start;
  }
}

@media (max-width: 560px) {
  .history-panel,
  .workspace {
    padding: 0.85rem;
  }

  .brand-block h1 {
    font-size: 1.55rem;
  }

  .input-band h2 {
    font-size: 1.35rem;
  }

  .link-form {
    grid-template-columns: 1fr;
  }

  .track-main,
  .match-block {
    grid-template-columns: 3.4rem minmax(0, 1fr);
  }

  .cover,
  .match-cover {
    width: 3.4rem;
  }

  .track-actions {
    grid-template-columns: 1fr;
    justify-items: stretch;
  }

  .download-button,
  .match-button {
    width: 100%;
  }
}
