:root {
  --explora-primary: #0f766e;
  --explora-primary-dark: #0b5a54;
  --bg: #f5f7f6;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --success: #16a34a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

header.brand {
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 32px 16px 8px;
}

header.brand img {
  height: 160px;
  max-width: 90vw;
  object-fit: contain;
}

main {
  flex: 1;
  width: 100%;
  max-width: 640px;
  padding: 24px 16px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.subtitle {
  color: var(--muted);
  text-align: center;
  margin: 0;
  font-size: 0.95rem;
}

.title-field {
  width: 100%;
}

.title-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.title-field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--card-bg);
  color: var(--text);
}

.title-field .hint {
  margin: 6px 0 0;
}

.dropzone {
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: 16px;
  background: var(--card-bg);
  padding: 56px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--explora-primary);
  background: #f0fdfa;
}

.dropzone .icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.dropzone .main-text {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0 0 6px;
}

.dropzone .hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

#file-input {
  display: none;
}

.tiktok-section {
  width: 100%;
}

.tiktok-section label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.tiktok-row {
  display: flex;
  gap: 8px;
}

.tiktok-row input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--card-bg);
  color: var(--text);
}

.uploads-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.upload-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}

.upload-item .filename {
  font-weight: 600;
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-track {
  margin-top: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

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

.progress-pct {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 4px;
}

.result-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.result-link {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.82rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--explora-primary);
  color: #fff;
  transition: background 0.15s ease;
}

button:hover {
  background: var(--explora-primary-dark);
}

button.secondary {
  background: transparent;
  color: var(--explora-primary);
  border: 1px solid var(--explora-primary);
}

button.secondary:hover {
  background: #f0fdfa;
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 8px;
}

button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

button.danger:hover {
  background: #fef2f2;
}

.gallery-section {
  width: 100%;
  max-width: 1100px;
  padding: 8px 16px 48px;
}

.gallery-title {
  font-size: 1.1rem;
  margin: 0 0 16px;
}

#gallery-empty {
  display: none;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 860px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .gallery-grid {
    grid-template-columns: 1fr;
  }
}

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

.thumb-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 0;
  overflow: hidden;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.thumb-img.hidden {
  display: none;
}

.thumb-fallback {
  display: none;
  font-size: 2rem;
  color: #94a3b8;
}

.thumb-wrap.no-thumb .thumb-fallback {
  display: flex;
}

.gallery-info {
  padding: 10px 12px 0;
}

.gallery-filename {
  font-weight: 600;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.gallery-actions {
  display: flex;
  gap: 6px;
  padding: 10px 12px 12px;
  margin-top: auto;
}

.gallery-actions button {
  flex: 1;
  padding: 6px 8px;
  font-size: 0.75rem;
}

footer {
  width: 100%;
  text-align: center;
  padding: 18px;
  color: var(--muted);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* Login page */
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  margin-top: 40px;
}

.login-card h1 {
  font-size: 1.1rem;
  margin: 0 0 20px;
  text-align: center;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.login-card button {
  width: 100%;
  padding: 10px;
}

.topbar {
  width: 100%;
  max-width: 640px;
  display: flex;
  justify-content: flex-end;
  padding: 0 16px;
}

.topbar button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.topbar button:hover {
  color: var(--text);
  border-color: var(--muted);
  background: transparent;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111827;
    --card-bg: #1f2937;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --border: #374151;
  }
  .dropzone:hover,
  .dropzone.dragover {
    background: #0f2e2b;
  }
  button.secondary:hover {
    background: #0f2e2b;
  }
}
