/* YouTube miniaturas — client-side thumbnail downloader */

.ytm-intro {
  margin-bottom: 12px;
  color: var(--dica-body);
}

.ytm-intro strong {
  color: var(--dica-ink);
}

.ytm-privacy {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--dica-border);
  background: var(--dica-surface-soft);
  color: var(--dica-body);
  font-size: 0.92rem;
  line-height: 1.45;
}

.ytm-privacy svg {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  fill: var(--dica-action);
  max-width: none;
}

.ytm-privacy strong {
  color: var(--dica-ink);
}

.ytm-privacy-short {
  display: none;
}

.ytm-app {
  --ytm-accent: var(--dica-action, #2f5da8);
  --ytm-accent-hover: var(--dica-action-hover, #244a86);
  --ytm-accent-soft: var(--dica-action-soft, rgba(47, 93, 168, 0.12));
  --ytm-accent-border: var(--dica-action-border, rgba(47, 93, 168, 0.35));
  --ytm-yt: #ff0033;
  --ytm-good: #079455;
  --ytm-warn: #dc6803;
  --ytm-bad: #d92d20;
  box-shadow: 0 0 0 1px var(--dica-border), 0 12px 32px var(--dica-shadow);
  border-radius: 16px;
  margin-bottom: 28px;
  background: var(--dica-surface);
  color: var(--dica-body);
  overflow: hidden;
}

.ytm-app *,
.ytm-app *::before,
.ytm-app *::after {
  box-sizing: border-box;
}

.ytm-app p {
  margin: 0;
}

.ytm-app button,
.ytm-app input,
.ytm-app select {
  font: inherit;
  color: inherit;
}

/* toolbar */
.ytm-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--dica-border);
  background: var(--dica-surface-soft);
}

.ytm-toolbar-spacer {
  flex: 1 1 auto;
  min-width: 4px;
}

.ytm-app .ytm-btn,
.ytm-app a.ytm-btn {
  appearance: none;
  border: 1px solid var(--dica-border);
  background: var(--dica-surface);
  color: var(--dica-ink) !important;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  white-space: nowrap;
}

.ytm-app .ytm-btn:hover,
.ytm-app a.ytm-btn:hover {
  border-color: var(--ytm-accent-border);
  background: var(--ytm-accent-soft);
  color: var(--dica-ink) !important;
}

.ytm-app .ytm-btn:focus-visible {
  outline: none;
  border-color: var(--ytm-accent);
  box-shadow: 0 0 0 3px var(--ytm-accent-soft);
}

.ytm-app .ytm-btn-primary,
.ytm-app .ytm-btn-primary:hover {
  background: var(--ytm-accent);
  border-color: var(--ytm-accent);
  color: #fff !important;
}

.ytm-app .ytm-btn-primary:hover {
  background: var(--ytm-accent-hover);
  border-color: var(--ytm-accent-hover);
}

.ytm-app .ytm-btn:disabled {
  background: var(--dica-surface-soft) !important;
  border-color: var(--dica-border) !important;
  color: var(--dica-muted) !important;
  cursor: not-allowed;
}

.ytm-app .ytm-btn-sm {
  padding: 6px 10px;
  font-size: 0.78rem;
  border-radius: 8px;
}

.ytm-app .ytm-btn-yt {
  border-color: color-mix(in srgb, var(--ytm-yt) 40%, var(--dica-border));
  color: var(--ytm-yt) !important;
}

.ytm-app .ytm-btn-yt:hover {
  background: color-mix(in srgb, var(--ytm-yt) 10%, var(--dica-surface));
  border-color: var(--ytm-yt);
  color: var(--ytm-yt) !important;
}

/* shell */
.ytm-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(240px, 0.75fr);
  gap: 0;
  border-bottom: 1px solid var(--dica-border);
}

.ytm-main,
.ytm-side {
  min-width: 0;
  padding: 18px;
}

.ytm-main {
  border-right: 1px solid var(--dica-border);
  background: var(--dica-surface);
}

.ytm-side {
  background: var(--dica-surface-soft);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ytm-section-title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--dica-ink);
  line-height: 1.25;
}

.ytm-fields {
  display: grid;
  gap: 14px;
}

.ytm-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ytm-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--dica-ink);
}

.ytm-hint {
  font-size: 0.78rem;
  color: var(--dica-muted);
  line-height: 1.35;
}

.ytm-input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.ytm-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--dica-border);
  border-radius: 10px;
  background: var(--dica-surface);
  color: var(--dica-ink);
  padding: 12px 14px;
  line-height: 1.35;
}

.ytm-input:focus {
  outline: none;
  border-color: var(--ytm-accent);
  box-shadow: 0 0 0 3px var(--ytm-accent-soft);
}

.ytm-input::placeholder {
  color: var(--dica-muted);
}

.ytm-format {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--dica-border);
  background: var(--dica-surface-soft);
}

.ytm-format-btn {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--dica-muted);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 750;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.ytm-format-btn:hover {
  color: var(--dica-ink);
}

.ytm-format-btn.is-active {
  background: var(--dica-surface);
  color: var(--dica-ink);
  box-shadow: 0 1px 3px var(--dica-shadow);
}

.ytm-status {
  min-height: 1.25em;
  font-size: 0.84rem;
  color: var(--dica-muted);
}

.ytm-status.is-ok {
  color: var(--ytm-good);
  font-weight: 700;
}

.ytm-status.is-error {
  color: var(--ytm-bad);
  font-weight: 700;
}

.ytm-status.is-loading {
  color: var(--ytm-accent);
  font-weight: 700;
}

/* side cards */
.ytm-card {
  background: var(--dica-surface);
  border: 1px solid var(--dica-border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 1px 2px var(--dica-shadow);
}

.ytm-card-label {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--dica-ink);
  opacity: 0.78;
  margin-bottom: 10px;
}

.ytm-meta {
  display: grid;
  gap: 8px;
}

.ytm-meta-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.88rem;
}

.ytm-meta-label {
  color: var(--dica-muted);
  font-weight: 600;
}

.ytm-meta-value {
  font-weight: 800;
  color: var(--dica-ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.ytm-meta-value a {
  color: var(--ytm-accent) !important;
  text-decoration: none !important;
  font-weight: 750;
}

.ytm-meta-value a:hover {
  text-decoration: underline !important;
}

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

.ytm-tips li {
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--dica-muted);
  padding-left: 14px;
  position: relative;
}

.ytm-tips li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ytm-accent);
  opacity: 0.7;
}

/* results */
.ytm-results {
  padding: 14px 16px 18px;
  background: var(--dica-surface);
}

.ytm-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.ytm-results-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--dica-ink);
}

.ytm-results-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.ytm-results-count {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--dica-muted);
  font-variant-numeric: tabular-nums;
}

.ytm-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--dica-muted);
  cursor: pointer;
  user-select: none;
}

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

.ytm-meta-value.is-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-width: 12rem;
}

.ytm-empty {
  margin: 0;
  padding: 28px 16px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--dica-muted);
  font-style: italic;
  border: 1px dashed var(--dica-border);
  border-radius: 12px;
  background: var(--dica-surface-soft);
}

.ytm-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.article .ytm-app .ytm-grid,
.article .ytm-app .ytm-tips {
  list-style: none;
  margin: 0;
  padding: 0;
}

.article .ytm-app .ytm-grid li::before {
  display: none !important;
  content: none !important;
}

.ytm-item {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--dica-border);
  border-radius: 14px;
  background: var(--dica-surface);
  box-shadow: 0 1px 2px var(--dica-shadow);
  overflow: hidden;
  min-width: 0;
}

.ytm-item.is-missing {
  opacity: 0.55;
}

.ytm-item.is-best {
  border-color: color-mix(in srgb, var(--ytm-accent) 45%, var(--dica-border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--ytm-accent) 25%, transparent), 0 8px 20px var(--dica-shadow);
}

.ytm-thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(45deg, #e8edf3 25%, transparent 25%),
    linear-gradient(-45deg, #e8edf3 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8edf3 75%),
    linear-gradient(-45deg, transparent 75%, #e8edf3 75%);
  background-size: 14px 14px;
  background-position: 0 0, 0 7px, 7px -7px, -7px 0;
  background-color: var(--dica-surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ytm-thumb {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0f1115;
}

.ytm-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  background: rgba(15, 17, 21, 0.82);
  color: #fff;
  backdrop-filter: blur(4px);
}

.ytm-badge.is-best {
  background: var(--ytm-accent);
}

.ytm-badge.is-missing {
  background: rgba(217, 45, 32, 0.9);
}

.ytm-item-body {
  padding: 12px;
  display: grid;
  gap: 10px;
}

.ytm-item-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--dica-ink);
  line-height: 1.25;
}

.ytm-item-meta {
  font-size: 0.78rem;
  color: var(--dica-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.ytm-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ytm-item-actions .ytm-btn {
  flex: 1 1 auto;
}

/* toast */
.ytm-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(12px);
  z-index: 9999;
  background: var(--dica-ink, #1e293b);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: min(90vw, 380px);
  text-align: center;
}

.ytm-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* responsive */
@media (max-width: 820px) {
  .ytm-shell {
    grid-template-columns: 1fr;
  }

  .ytm-main {
    border-right: 0;
    border-bottom: 1px solid var(--dica-border);
  }

  .ytm-input-row {
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .ytm-privacy-full {
    display: none;
  }

  .ytm-privacy-short {
    display: inline;
  }

  .ytm-main,
  .ytm-side {
    padding: 14px;
  }

  .ytm-toolbar .ytm-btn {
    flex: 1 1 auto;
  }

  .ytm-grid {
    grid-template-columns: 1fr;
  }
}

html[data-theme="dark"] .ytm-app {
  color-scheme: dark;
}

html[data-theme="dark"] .ytm-thumb-wrap {
  background-color: #0f1115;
  background-image:
    linear-gradient(45deg, #1e293b 25%, transparent 25%),
    linear-gradient(-45deg, #1e293b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1e293b 75%),
    linear-gradient(-45deg, transparent 75%, #1e293b 75%);
}
