:root {
  --bg: #0f1115;
  --card: #1a1d24;
  --border: #2a2e38;
  --fg: #e6e9ef;
  --muted: #8b93a7;
  --accent: #0d6efd;
  --accent-hover: #3b7ddd;
  --success: #2dd4bf;
  --danger: #ef4444;
}

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

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}

.app {
  max-width: 768px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  background: var(--accent);
  color: #fff;
  transition: background 0.15s, transform 0.05s;
  white-space: nowrap;
}

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

.btn:active {
  transform: scale(0.98);
}

.btn.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--fg);
}

.btn.secondary:hover {
  background: var(--border);
}

.btn.danger {
  background: var(--danger);
}

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

.btn:disabled:hover {
  background: var(--accent);
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 2rem 1rem;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover, .dropzone.drag {
  border-color: var(--accent);
  background: rgba(13, 110, 253, 0.08);
  color: var(--fg);
}

.dropzone input[type=file] {
  display: none;
}

label.btn input[type=file] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.url-row {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.url-input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--fg);
  font-size: 0.9rem;
  outline: none;
}

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

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

.video-wrap {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  aspect-ratio: 4/3;
  margin-top: 0.5rem;
}

.video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.video-wrap .overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-wrap .overlay .frame {
  width: 60%;
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
}

.status {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.5rem;
  text-align: center;
}

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

.status.ok {
  color: var(--success);
}

.result {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.result .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-align: center;
}

.result .value {
  width: 100%;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.95rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  word-break: break-all;
  white-space: pre-wrap;
  max-height: 12rem;
  overflow-y: auto;
}

.result .actions {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.result .actions .btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.result .auto-clear-note {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  margin-top: 0.25rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--success);
  color: #08332b;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
  z-index: 99;
  animation: toast-in 0.2s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
.spinner {
  width: 32px;
  height: 32px;
  margin: 1rem auto;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.dropzone:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
}

footer a {
  color: var(--accent-hover);
  text-decoration: none;
}

@media (max-width: 600px) {
  .app {
    padding: 1rem 0.75rem 3rem;
  }
  header h1 {
    font-size: 1.25rem;
  }
  .btn-row {
    flex-direction: column;
    align-items: stretch;
  }
  .btn {
    width: 100%;
    justify-content: center;
  }
  .url-row {
    flex-direction: column;
    align-items: stretch;
  }
  .url-input {
    width: 100%;
  }
  .url-row .btn {
    width: 100%;
  }
}
