:root {
  --bg: #0f1115;
  --bg-elev: #181b21;
  --bg-elev-2: #20242c;
  --border: #2a2f3a;
  --text: #e6e8ec;
  --text-dim: #9aa1ad;
  --accent: #4f8cff;
  --danger: #e5484d;
  --ok: #30a46c;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
}

.nav-link {
  font-weight: 500;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.gallery-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.gallery-head h1 {
  margin: 0;
  font-size: 1.6rem;
}

.usage {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.thumb {
  position: relative;
  display: block;
  aspect-ratio: 16 / 9;
  background: #000;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.thumb .play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease;
  background: rgba(0, 0, 0, 0.25);
}

.thumb:hover .play {
  opacity: 1;
}

.thumb .play::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 26px solid rgba(255, 255, 255, 0.9);
  border-top: 16px solid transparent;
  border-bottom: 16px solid transparent;
}

.thumb .duration {
  position: absolute;
  right: 0.4rem;
  bottom: 0.4rem;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
}

.card-body {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.card-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.card-links {
  display: flex;
  gap: 0.9rem;
  margin-top: auto;
  font-size: 0.85rem;
}

.empty {
  color: var(--text-dim);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  color: var(--text-dim);
}

.btn {
  display: inline-block;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  background: #282d37;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #3d7bf0;
}

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

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.center {
  text-align: center;
  padding: 4rem 1rem;
}

.upload-wrap,
.watch-wrap {
  max-width: 720px;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field span {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.field input[type="text"],
.field input[type="password"] {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-size: 0.95rem;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 2.5rem 1rem;
  border: 2px dashed var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--bg-elev);
}

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

.dropzone-text {
  font-size: 1rem;
  font-weight: 500;
}

.dropzone-hint {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.hidden {
  display: none !important;
}

.progress {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  height: 2rem;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.1s linear;
}

.progress-meta {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.result {
  margin-top: 1.5rem;
  background: var(--bg-elev);
  border: 1px solid var(--ok);
  border-radius: 10px;
  padding: 1rem;
}

.result h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  color: var(--ok);
}

.result-row {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.result-row span {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.result input[type="text"] {
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.5rem 0.6rem;
  font-size: 0.85rem;
  width: 100%;
}

.result-actions {
  display: flex;
  gap: 0.6rem;
}

.watch-wrap video {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.watch-head {
  margin-top: 1rem;
}

.watch-head h1 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  word-break: break-word;
}

.watch-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

.watch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 1rem 0;
}

.watch-links {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.watch-links input[type="text"] {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  padding: 0.5rem 0.6rem;
  font-size: 0.8rem;
  width: 100%;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  z-index: 10;
}

@media (max-width: 640px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .gallery-head {
    flex-direction: column;
    gap: 0.25rem;
  }
}
