:root {
  --bg: #111111;
  --surface: #1a1a1a;
  --surface-2: #222222;
  --accent: #f5a623;
  --text: #ffffff;
  --text-secondary: #888888;
  --green: #2ecc71;
  --red: #e74c3c;
  --radius: 12px;
  --nav-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app {
  height: 100vh;
  height: 100dvh;
  position: relative;
}

/* --------------------------------- PAGES --------------------------------- */
.page {
  position: absolute;
  inset: 0;
  bottom: var(--nav-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page[hidden] {
  display: none;
}

.page-inner {
  flex: 1;
  overflow-y: auto;
  padding: 28px 20px 20px;
  -webkit-overflow-scrolling: touch;
}

.page-footer {
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid #000;
  background: var(--bg);
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --------------------------------- HOME --------------------------------- */
.home-inner {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-bottom: 40px;
}

.home-header {
  text-align: center;
  margin-bottom: 36px;
}

.home-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.home-sub {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 12px;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid #2a2a2a;
  border-radius: var(--radius);
  padding: 0 8px 0 44px;
  height: 56px;
  transition: border-color 0.15s;
}

.input-wrap:focus-within {
  border-color: var(--accent);
}

.input-icon-left {
  position: absolute;
  left: 14px;
  color: var(--text-secondary);
  width: 20px;
  height: 20px;
}

.url-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  height: 100%;
}

.url-input::placeholder {
  color: #555;
}

.clipboard-btn {
  background: var(--surface-2);
  border: none;
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.clipboard-btn:hover {
  color: var(--accent);
}

.fab-area {
  margin-top: 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.fab {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #111;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(245, 166, 35, 0.35);
  transition: transform 0.12s, box-shadow 0.12s;
}

.fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(245, 166, 35, 0.45);
}

.fab:active {
  transform: scale(0.95);
}

.fab i {
  width: 32px;
  height: 32px;
}

.fab-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ------------------------------- BUTTONS ------------------------------- */
.icon-btn {
  background: var(--surface);
  border: 1px solid #2a2a2a;
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.icon-btn:hover {
  color: var(--text);
}

.icon-btn.accent {
  color: var(--accent);
  border-color: rgba(245, 166, 35, 0.35);
}

.clear-btn {
  background: rgba(231, 76, 60, 0.12);
  border: 1px solid rgba(231, 76, 60, 0.4);
  color: var(--red);
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.clear-btn i {
  width: 16px;
  height: 16px;
}

.primary-btn {
  width: 100%;
  background: var(--accent);
  color: #111;
  border: none;
  height: 52px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
}

.primary-btn:hover {
  filter: brightness(1.05);
}

.primary-btn:active {
  transform: scale(0.99);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.outline-btn {
  width: 100%;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  height: 42px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.outline-btn:hover {
  background: rgba(245, 166, 35, 0.1);
}

.outline-btn i {
  width: 16px;
  height: 16px;
}

/* -------------------------------- QUEUE -------------------------------- */
.queue-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.track-card {
  background: var(--surface);
  border: 1px solid #242424;
  border-radius: var(--radius);
  overflow: hidden;
}

.track-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  cursor: pointer;
  position: relative;
}

.track-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--surface-2);
  flex-shrink: 0;
}

.track-thumb-placeholder {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.track-info {
  flex: 1;
  min-width: 0;
}

.track-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.track-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: capitalize;
  white-space: nowrap;
}

.status-ready {
  background: #2a2a2a;
  color: var(--text-secondary);
}

.status-downloading,
.status-converting,
.status-tagging {
  background: rgba(245, 166, 35, 0.18);
  color: var(--accent);
  animation: pulse 1.3s ease-in-out infinite;
}

.status-done {
  background: rgba(46, 204, 113, 0.18);
  color: var(--green);
}

.status-error {
  background: rgba(231, 76, 60, 0.18);
  color: var(--red);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.remove-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.remove-btn:hover {
  color: var(--red);
}

.remove-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.remove-btn i {
  width: 16px;
  height: 16px;
}

/* Expanded edit section */
.track-expand {
  padding: 0 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-top: 1px solid #242424;
}

.track-expand[hidden] {
  display: none;
}

.field-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  display: block;
}

.field {
  margin-top: 10px;
}

.progress-track {
  height: 4px;
  background: #2a2a2a;
  border-radius: 999px;
  overflow: hidden;
  margin: 6px 0 10px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.track-error-msg {
  font-size: 12px;
  color: var(--red);
}

/* -------------------------------- INPUTS -------------------------------- */
.text-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s;
}

.text-input:focus {
  border-color: var(--accent);
}

/* -------------------------------- LIBRARY -------------------------------- */
.library-list {
  display: flex;
  flex-direction: column;
}

.library-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid #1f1f1f;
}

.library-row .lib-icon {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(245, 166, 35, 0.12);
  display: grid;
  place-items: center;
  color: var(--accent);
  flex-shrink: 0;
}

.library-row .lib-icon i {
  width: 18px;
  height: 18px;
}

.lib-info {
  flex: 1;
  min-width: 0;
}

.lib-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lib-artist {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.lib-duration {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* -------------------------------- CARDS -------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid #242424;
  border-radius: var(--radius);
  padding: 18px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
}

.card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 6px 0 14px;
}

.resolved-path {
  font-size: 12px;
  color: var(--accent);
  margin-top: 8px;
  word-break: break-all;
}

/* ----------------------------- EMPTY STATE ----------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 80px 20px;
  color: var(--text-secondary);
  text-align: center;
}

.empty-state i {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 14px;
}

/* ----------------------------- BOTTOM NAV ----------------------------- */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #0c0c0c;
  border-top: 1px solid #1f1f1f;
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 50;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  padding: 6px 10px;
  flex: 1;
  transition: color 0.15s;
}

.nav-item i {
  width: 22px;
  height: 22px;
}

.nav-item.active {
  color: var(--accent);
}

/* ----------------------------- OVERLAYS ----------------------------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}

.loading-overlay[hidden] {
  display: none;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(245, 166, 35, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

#loading-text {
  font-size: 14px;
  color: var(--text-secondary);
}

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

/* ------------------------------- TOASTS ------------------------------- */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
  width: calc(100% - 40px);
  max-width: 420px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid #2a2a2a;
  border-left-width: 4px;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: toast-in 0.25s ease;
  pointer-events: auto;
}

.toast.success {
  border-left-color: var(--green);
}

.toast.error {
  border-left-color: var(--red);
}

.toast.info {
  border-left-color: var(--accent);
}

.toast.hide {
  animation: toast-out 0.25s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(12px);
  }
}
