:root {
  --bg: #0e0e12;
  --surface: #17171d;
  --surface-2: #1f1f27;
  --border: #2a2a34;
  --text: #f5f5f7;
  --muted: #9a9aa5;
  --accent: #ee4d2d;
  --accent-2: #ff7a45;
  --success: #34c77b;
  --danger: #ff5a5a;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(238, 77, 45, .12), transparent 60%),
    radial-gradient(900px 400px at -10% 30%, rgba(255, 122, 69, .06), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) max(16px, env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 24px) max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 20px;
}
.header__brand { display: flex; align-items: center; gap: 12px; }
.header__logo { width: 44px; height: 44px; border-radius: 12px; box-shadow: var(--shadow); }
.header__title { font-size: 1.05rem; font-weight: 700; line-height: 1.2; }
.header__title span { color: var(--accent-2); }
.header__subtitle { font-size: .8rem; color: var(--muted); margin-top: 2px; }
.btn--install { flex-shrink: 0; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 12px;
  font-size: .92rem;
  font-weight: 600;
  font-family: inherit;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform .12s ease, opacity .15s ease, background .15s ease;
  user-select: none;
  touch-action: manipulation;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  color: #fff;
  box-shadow: 0 4px 14px rgba(238, 77, 45, .35);
}
.btn--ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn--sm { padding: 9px 14px; font-size: .85rem; border-radius: 10px; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- Card de entrada ---------- */
.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.input-card__label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 10px;
}
.input-card__textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  line-height: 1.5;
  padding: 12px 14px;
  resize: vertical;
  min-height: 84px;
  outline: none;
  transition: border-color .15s ease;
}
.input-card__textarea:focus { border-color: var(--accent); }
.input-card__textarea::placeholder { color: #55555f; }
.input-card__actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}
.input-card__actions .btn--primary { flex: 1; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.toolbar__count { font-size: .88rem; color: var(--muted); font-weight: 600; }
.toolbar__actions { display: flex; gap: 8px; }

/* ---------- Progresso do ZIP ---------- */
.zip-progress { margin-top: 12px; display: flex; align-items: center; gap: 12px; }
.zip-progress__track {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.zip-progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  border-radius: 99px;
  transition: width .25s ease;
}
.zip-progress__text { font-size: .8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Lista de vídeos ---------- */
.list {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  gap: 12px;
  align-items: stretch;
  animation: cardIn .25s ease both;
}
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.card__thumb {
  width: 72px;
  min-height: 96px;
  border-radius: 10px;
  background: var(--surface-2);
  object-fit: cover;
  flex-shrink: 0;
}
.card__thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a4a55;
}
.card__thumb--placeholder svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; }

.card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card__caption {
  font-size: .88rem;
  font-weight: 600;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.card__meta { font-size: .78rem; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card__status {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 600;
  font-size: .74rem;
}
.chip--pending { background: rgba(154, 154, 165, .15); color: var(--muted); }
.chip--loading { background: rgba(255, 122, 69, .15); color: var(--accent-2); }
.chip--ready { background: rgba(52, 199, 123, .15); color: var(--success); }
.chip--error { background: rgba(255, 90, 90, .15); color: var(--danger); }
.chip--done { background: rgba(52, 199, 123, .15); color: var(--success); }

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.card__progress {
  height: 4px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 6px;
}
.card__progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width .2s ease;
}

.card__actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
  flex-shrink: 0;
}
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .12s ease, background .15s ease, opacity .15s ease;
  touch-action: manipulation;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.icon-btn--primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border: none;
  color: #fff;
}
.icon-btn--danger:hover { color: var(--danger); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Vazio ---------- */
.empty {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}
.empty__icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty__icon svg { width: 32px; height: 32px; fill: none; stroke: #4a4a55; stroke-width: 1.6; stroke-linejoin: round; }
.empty__title { font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty__text { font-size: .85rem; max-width: 300px; margin: 0 auto; line-height: 1.5; }

/* ---------- Rodapé ---------- */
.footer {
  margin-top: auto;
  padding-top: 32px;
  text-align: center;
}
.footer p { font-size: .72rem; color: #55555f; line-height: 1.5; max-width: 420px; margin: 0 auto; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: .86rem;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: calc(100vw - 32px);
  text-align: center;
  animation: toastIn .25s ease;
}
.toast--error { border-color: rgba(255, 90, 90, .4); }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Tablet ---------- */
@media (min-width: 640px) {
  .app { max-width: 860px; }
  .list { grid-template-columns: repeat(2, 1fr); }
  .header__title { font-size: 1.2rem; }
}

/* ---------- Desktop ---------- */
@media (min-width: 1024px) {
  .app { max-width: 1100px; padding-top: 32px; }
  .list { grid-template-columns: repeat(3, 1fr); }
  .input-card { padding: 20px; }
  .btn:hover:not(:disabled) { filter: brightness(1.08); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
