:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e2e4e9;
  --text: #1c1f26;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

[hidden] { display: none !important; }

button {
  cursor: pointer;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  background: var(--primary);
  color: white;
  transition: background 0.15s;
}
button:hover { background: var(--primary-hover); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

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

input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"] {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}

/* Login */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  padding: 32px;
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.login-card h1 { font-size: 18px; margin: 0; }
.subtitle { color: var(--text-muted); font-size: 13px; margin: 0 0 8px; }

/* Dashboard */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.topbar h1 { font-size: 18px; margin: 0; flex: 0 0 auto; }
.counts { display: flex; gap: 8px; flex: 1; }
.count-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
}
.count-badge.full { color: var(--danger); border-color: var(--danger); }

.content {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.upload-card,
.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.upload-card h2,
.list-card h2 {
  margin-top: 0;
  font-size: 15px;
}

#upload-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}
#upload-form input[type="file"] { flex: 1 1 220px; }
#upload-form input[type="text"] { flex: 1 1 200px; }
.duration-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  width: 140px;
}

.hint { color: var(--text-muted); font-size: 13px; margin-top: -8px; }

.media-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.media-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.media-item.dragging { opacity: 0.4; }
.media-item.inactive { opacity: 0.55; }

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 18px;
  user-select: none;
  padding: 0 4px;
}

.thumb {
  width: 72px;
  height: 48px;
  object-fit: cover;
  border-radius: 6px;
  background: #000;
  flex-shrink: 0;
}

.media-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.media-name {
  font-size: 14px;
  font-weight: 600;
  border: none;
  background: transparent;
  padding: 2px 0;
  width: 100%;
  font-family: inherit;
  color: var(--text);
}
.media-name:focus { outline: 1px solid var(--primary); border-radius: 4px; }
.media-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.type-badge {
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
  background: var(--border);
  padding: 2px 6px;
  border-radius: 4px;
}

.duration-field {
  display: flex;
  align-items: center;
  gap: 4px;
}
.duration-field input {
  width: 56px;
  padding: 4px 6px;
}

.media-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
  position: absolute;
  inset: 0;
  background: #cbd0dc;
  border-radius: 999px;
  transition: 0.15s;
  cursor: pointer;
}
.toggle .slider::before {
  content: "";
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.15s;
}
.toggle input:checked + .slider { background: var(--success); }
.toggle input:checked + .slider::before { transform: translateX(18px); }

.error-text { color: var(--danger); font-size: 13px; margin: 8px 0 0; }
.info-text { color: var(--text-muted); font-size: 13px; margin: 8px 0 0; }
.empty-state { color: var(--text-muted); font-size: 14px; text-align: center; padding: 20px 0; }

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; }
  .media-item { flex-wrap: wrap; }
}
